diff --git a/rules/no-zero-fractions.js b/rules/no-zero-fractions.js index 3cd4847afa..cf173ae125 100644 --- a/rules/no-zero-fractions.js +++ b/rules/no-zero-fractions.js @@ -3,6 +3,7 @@ const {isParenthesized} = require('eslint-utils'); const needsSemicolon = require('./utils/needs-semicolon.js'); const {isNumber, isDecimalInteger} = require('./utils/numeric.js'); const toLocation = require('./utils/to-location.js'); +const {fixSpaceAroundKeyword} = require('./fix/index.js'); const MESSAGE_ZERO_FRACTION = 'zero-fraction'; const MESSAGE_DANGLING_DOT = 'dangling-dot'; @@ -41,7 +42,7 @@ const create = context => { return { loc: toLocation([start, end], sourceCode), messageId: isDanglingDot ? MESSAGE_DANGLING_DOT : MESSAGE_ZERO_FRACTION, - fix: fixer => { + * fix (fixer) { let fixed = formatted; if ( node.parent.type === 'MemberExpression' && @@ -56,7 +57,8 @@ const create = context => { } } - return fixer.replaceText(node, fixed); + yield fixer.replaceText(node, fixed); + yield * fixSpaceAroundKeyword(fixer, node, sourceCode); }, }; }, diff --git a/test/snapshots/no-zero-fractions.mjs.md b/test/snapshots/no-zero-fractions.mjs.md index 4a04390d0b..e91b617b82 100644 --- a/test/snapshots/no-zero-fractions.mjs.md +++ b/test/snapshots/no-zero-fractions.mjs.md @@ -2726,7 +2726,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | function foo(){return0}␊ + 1 | function foo(){return 0}␊ ` > Error 1/1 diff --git a/test/snapshots/no-zero-fractions.mjs.snap b/test/snapshots/no-zero-fractions.mjs.snap index 8ab5f9e930..91eb924e6c 100644 Binary files a/test/snapshots/no-zero-fractions.mjs.snap and b/test/snapshots/no-zero-fractions.mjs.snap differ