💼 This rule is enabled in the ✅ recommended config.
Since ESLint v9.15.0, rules' default options are supported using meta.defaultOptions. Additionally defining them using the default property in meta.schema is confusing, error-prone, and can be ambiguous for complex schemas.
This rule disallows the default property in rules' meta.schema.
Examples of incorrect code for this rule:
/* eslint eslint-plugin/no-meta-schema-default: error */
module.exports = {
meta: {
schema: [
{
elements: { type: 'string' },
type: 'array',
default: [],
},
],
},
create() {},
};
module.exports = {
meta: {
schema: {
type: 'object',
properties: {
foo: { type: 'string', default: 'bar' },
baz: { type: 'number', default: 42 },
},
},
},
create() {},
};Examples of correct code for this rule:
/* eslint eslint-plugin/no-meta-schema-default: error */
module.exports = {
meta: {
schema: [
{
elements: { type: 'string' },
type: 'array',
},
],
defaultOptions: [[]],
},
create() {},
};
module.exports = {
meta: {
schema: {
type: 'object',
properties: {
foo: { type: 'string' },
baz: { type: 'number' },
},
},
defaultOptions: [{ foo: 'bar', baz: 42 }],
},
create() {},
};When using eslint-doc-generator to generate documentation for your rules, you may want to disable this rule to include the default property in the generated documentation. This is because eslint-doc-generator does not yet support meta.defaultOptions, see bmish/eslint-doc-generator#513.