Skip to content

Commit

Permalink
Fix space after keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jul 24, 2021
1 parent f5acb43 commit 907602e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rules/no-zero-fractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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' &&
Expand All @@ -56,7 +57,8 @@ const create = context => {
}
}

return fixer.replaceText(node, fixed);
yield fixer.replaceText(node, fixed);
yield * fixSpaceAroundKeyword(fixer, node, sourceCode);
},
};
},
Expand Down
2 changes: 1 addition & 1 deletion test/snapshots/no-zero-fractions.mjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ Generated by [AVA](https://avajs.dev).
> Output
`␊
1 | function foo(){return0}␊
1 | function foo(){return 0}␊
`

> Error 1/1
Expand Down
Binary file modified test/snapshots/no-zero-fractions.mjs.snap
Binary file not shown.

0 comments on commit 907602e

Please sign in to comment.