Skip to content

Commit a596dc4

Browse files
committed
Update: check context.report({fix})
1 parent c309853 commit a596dc4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/rules/fixer-return.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = {
3434
shouldCheck: false,
3535
node: null,
3636
};
37+
let contextIdentifiers;
3738

3839
/**
3940
* Checks whether or not the last code path segment is reachable.
@@ -56,20 +57,27 @@ module.exports = {
5657
}
5758

5859
return {
60+
Program (node) {
61+
contextIdentifiers = utils.getContextIdentifiers(context, node);
62+
},
5963

6064
// Stacks this function's information.
6165
onCodePathStart (codePath, node) {
6266
const parent = node.parent;
67+
const shouldCheck = node.type === 'FunctionExpression' &&
68+
node.body.type === 'BlockStatement' &&
69+
// check if it is context.report({fix})
70+
utils.getKeyName(parent) === 'fix' &&
71+
parent.parent.type === 'ObjectExpression' &&
72+
parent.parent.parent.type === 'CallExpression' &&
73+
contextIdentifiers.has(parent.parent.parent.callee.object) &&
74+
parent.parent.parent.callee.property.name === 'report';
6375

6476
funcInfo = {
6577
upper: funcInfo,
6678
codePath,
6779
hasReturn: false,
68-
shouldCheck:
69-
node.type === 'FunctionExpression' &&
70-
node.body.type === 'BlockStatement' &&
71-
// check if it is naming fix
72-
utils.getKeyName(parent) === 'fix',
80+
shouldCheck,
7381
node,
7482
};
7583
},

0 commit comments

Comments
 (0)