Skip to content

[Fix] disallow extra properties in rule options #1053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/src/rules/label-has-for-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ruleTester.run('label-has-for', rule, {
{ code: '<label><input /></label>', options: optionsRequiredNesting },
{ code: '<label htmlFor="input"><input /></label>', options: optionsRequiredEvery },
{ code: '<label><input /></label>', options: optionsChildrenAllowed },
{ code: '<Descriptor htmlFor="foo">Test!</Descriptor>', options: [assign({}, optionsComponents, optionsChildrenAllowed)] },
{ code: '<Descriptor htmlFor="foo">Test!</Descriptor>', options: [assign({}, optionsComponents[0], optionsChildrenAllowed[0])] },
{ code: '<label>Test!</label>', options: optionsChildrenAllowed },
{ code: '<label htmlFor="foo">Test!</label>', options: optionsChildrenAllowed },
{ code: '<label>{children}</label>', options: optionsChildrenAllowed },
Expand Down
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const recommendedRules = {
'tree',
'treegrid',
],
includeRoles: ['alert', 'dialog'],
},
],
'jsx-a11y/heading-has-content': 'error',
Expand Down Expand Up @@ -235,7 +234,6 @@ const strictRules = {
'tree',
'treegrid',
],
includeRoles: ['alert', 'dialog'],
},
],
'jsx-a11y/heading-has-content': 'error',
Expand Down
1 change: 1 addition & 0 deletions src/rules/label-has-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const schema = {
},
allowChildren: { type: 'boolean' },
},
additionalProperties: false,
};
// Breadth-first search, assuming that HTML for forms is shallow.
function validateNesting(node) {
Expand Down
11 changes: 10 additions & 1 deletion src/rules/no-noninteractive-element-interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ export default ({
url: 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/no-noninteractive-element-interactions.md',
description: 'Non-interactive elements should not be assigned mouse or keyboard event listeners.',
},
schema: [schema],
schema: [{
...schema,
additionalProperties: {
type: 'array',
items: {
type: 'string',
},
uniqueItems: true,
},
}],
},

create: (context: ESLintContext): ESLintVisitorSelectorConfig => {
Expand Down
3 changes: 3 additions & 0 deletions src/rules/no-noninteractive-tabindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const schema = generateObjSchema({
...arraySchema,
description: 'An array of HTML tag names',
},
allowExpressionValues: {
type: 'boolean',
},
});

export default ({
Expand Down
3 changes: 3 additions & 0 deletions src/rules/no-static-element-interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const defaultInteractiveProps = [].concat(
);
const schema = generateObjSchema({
handlers: arraySchema,
allowExpressionValues: {
type: 'boolean',
},
});

export default ({
Expand Down
1 change: 1 addition & 0 deletions src/util/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export const generateObjSchema = (properties = {}, required = undefined) => ({
type: 'object',
properties,
required,
additionalProperties: false,
});