Skip to content

Commit

Permalink
Add rule S6807 (jsx-a11y/role-has-required-aria-props): DOM element…
Browse files Browse the repository at this point in the history
…s with ARIA roles should have the required properties (#4262)
  • Loading branch information
alex-sonar authored Oct 10, 2023
1 parent a92b609 commit 4785439
Show file tree
Hide file tree
Showing 13 changed files with 303 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@
"file-for-rules:S6766.js": [
0
],
"file-for-rules:S6807.js": [
0
],
"file-for-rules:boundOrAssignedEvalOrArguments.js": [
0
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
"file-for-rules:S6766.js": [
2
],
"file-for-rules:S6807.js": [
2
],
"file-for-rules:boundOrAssignedEvalOrArguments.js": [
2,
8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"file-for-rules:S6807.js": [
4
]
}
6 changes: 6 additions & 0 deletions its/sources/jsts/custom/S6807.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
function MyComponent(){
return (
<div role="checkbox">{/* Noncompliant: aria-checked is missing */} Unchecked</div>
);
}
180 changes: 180 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"builtin-modules": "3.3.0",
"bytes": "3.1.2",
"eslint": "8.47.0",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-sonarjs": "0.21.0",
Expand Down Expand Up @@ -116,6 +117,7 @@
"builtin-modules",
"bytes",
"eslint",
"eslint-plugin-jsx-a11y",
"eslint-plugin-react",
"eslint-plugin-react-hooks",
"eslint-plugin-sonarjs",
Expand Down
3 changes: 2 additions & 1 deletion packages/jsts/src/linter/bundle-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { eslintRules } from '../rules/core';
import { tsEslintRules } from '../rules/typescript-eslint';
import { rules as pluginRules } from 'eslint-plugin-sonarjs';
import { rules as reactESLintRules } from 'eslint-plugin-react';
import { rules as reactA11yRules } from 'eslint-plugin-jsx-a11y';
import { rules as internalRules } from '../rules';
import { customRules as internalCustomRules, CustomRule } from './custom-rules';
import { debug, getContext } from '@sonar/shared/helpers';
Expand Down Expand Up @@ -57,7 +58,7 @@ const loaders: { [key: string]: Function } = {
* Core ESLint rules could be overridden by the implementation from specific
* dependencies, which should be the default behaviour in most cases.
*/
const dependencies = [eslintRules, tsEslintRules, reactESLintRules];
const dependencies = [eslintRules, tsEslintRules, reactESLintRules, reactA11yRules];
for (const dependencyRules of dependencies) {
for (const [name, module] of Object.entries(dependencyRules)) {
externalRules[name] = module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public static List<Class<? extends JavaScriptCheck>> getAllChecks() {
RequireRenderReturnCheck.class,
ReturnInSetterCheck.class,
ReturnOfBooleanExpressionCheck.class,
RoleHasRequiredAriaPropsCheck.class,
RulesOfHooksCheck.class,
SameLineConditionalCheck.class,
SelfAssignmentCheck.class,
Expand Down
Loading

0 comments on commit 4785439

Please sign in to comment.