💼 This rule is enabled in the ✅ recommended
config.
In a fixable rule, a fixer function is useless if it never returns anything.
This rule enforces that a fixer function returns a fix in at least one situation.
Examples of incorrect code for this rule:
/* eslint eslint-plugin/fixer-return: error */
module.exports = {
create(context) {
context.report({
fix(fixer) {
fixer.insertTextAfter(node, 'foo');
},
});
},
};
Examples of correct code for this rule:
/* eslint eslint-plugin/fixer-return: error */
module.exports = {
create(context) {
context.report({
fix(fixer) {
return fixer.insertTextAfter(node, 'foo');
},
});
},
};
/* eslint eslint-plugin/fixer-return: error */
module.exports = {
create(context) {
context.report({
fix(fixer) {
if (foo) {
return; // no autofix in this situation
}
return fixer.insertTextAfter(node, 'foo');
},
});
},
};