💼 This rule is enabled in the ✅ recommended
config.
ESLint requires fixable rules to specify a valid meta.fixable
property (with value code
or whitespace
).
This rule aims to require fixable ESLint rules to have a valid meta.fixable
property.
Examples of incorrect code for this rule:
/* eslint eslint-plugin/require-meta-fixable: "error" */
module.exports = {
meta: {}, // missing `fixable` property
create(context) {
context.report({
node,
message: 'foo',
fix(fixer) {
return fixer.remove(node);
},
});
},
};
/* eslint eslint-plugin/require-meta-fixable: "error" */
module.exports = {
meta: { fixable: 'not a valid meta.fixable value' },
create(context) {
context.report({
node,
message: 'foo',
fix(fixer) {
return fixer.remove(node);
},
});
},
};
/* eslint eslint-plugin/require-meta-fixable: ["error", { catchNoFixerButFixableProperty: true }] */
module.exports = {
meta: { fixable: 'code' }, // property enabled but no fixer detected
create(context) {
context.report({ node, message: 'foo' });
},
};
Examples of correct code for this rule:
/* eslint eslint-plugin/require-meta-fixable: "error" */
module.exports = {
meta: { fixable: 'code' },
create(context) {
context.report({
node,
message: 'foo',
fix(fixer) {
return fixer.remove(node);
},
});
},
};
/* eslint eslint-plugin/require-meta-fixable: "error" */
module.exports = {
meta: {},
create(context) {
context.report({
node,
message: 'foo',
});
},
};
Name | Description | Type | Default |
---|---|---|---|
catchNoFixerButFixableProperty |
Whether the rule should attempt to detect rules that do not have a fixer but enable the meta.fixable property. This option is off by default because it increases the chance of false positives since fixers can't always be detected when helper functions are used. |
Boolean | false |