Skip to content

Commit

Permalink
Create rule schema to support "allowComments"
Browse files Browse the repository at this point in the history
eslint v9 made schema mandatory for options supported
by rules:
https://eslint.org/docs/latest/extend/custom-rules#options-schemas

Previously we didn't use the meta object on the rules
so now we create the meta object and populate the `schema` property.

Thanks to @BePo65 for providing context, docs and the schema itself.
  • Loading branch information
azeemba committed May 26, 2024
1 parent 8a999c6 commit caa50b0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,25 @@ const reportComment = (errorName, context) => {
}, fileComments[context.getFilename()]);
};

const ruleSchema = [
{
anyOf: [
{
enum: ['allowComments'],
},
{
type: 'object',
properties: {
allowComments: {type: 'boolean'},
},
additionalProperties: false,
},
],
},
];

const makeRule = (errorName, reporters) => ({
meta: {schema: ruleSchema},
create(context) {
return {
Program() {
Expand Down

0 comments on commit caa50b0

Please sign in to comment.