Skip to content

Commit ed04d87

Browse files
marcusdscrookedstorm
authored andcommitted
feat: add eslint-plugin-jsx-a11y for accessibility linting (ASTD-198) (#431)
* feat: add eslint-plugin-jsx-a11y for accessibility linting (ASTD-198) - Add eslint-plugin-jsx-a11y to pnpm catalog - Add per-package a11y ESLint configs (eslint.config.a11y.js) for studio and common - Add lint:a11y npm script to both packages with warning baselines - studio: 73 warnings - common: 18 warnings - All jsx-a11y rules run at warn level initially Signed-off-by: mschwab <mschwab@nvidia.com> * refactor(studio): consolidate a11y eslint config to web root The per-package eslint.config.a11y.js files in common and studio were byte-identical. Move to a single web/eslint.config.a11y.js and point both lint:a11y scripts at it (../../eslint.config.a11y.js), keeping per-package --max-warnings. Move eslint-plugin-jsx-a11y and globals to the root package.json since the shared config resolves them from there. Resolves CodeRabbit finding about missing globals dependency in web/packages/common/package.json by eliminating the duplicate config. Signed-off-by: mschwab <mschwab@nvidia.com> --------- Signed-off-by: mschwab <mschwab@nvidia.com>
1 parent c637d63 commit ed04d87

6 files changed

Lines changed: 980 additions & 24 deletions

File tree

web/eslint.config.a11y.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import tsEslintParser from '@typescript-eslint/parser';
5+
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
6+
import globals from 'globals';
7+
8+
export default [
9+
{
10+
files: ['**/*.{ts,tsx}'],
11+
languageOptions: {
12+
ecmaVersion: 2022,
13+
sourceType: 'module',
14+
parser: tsEslintParser,
15+
globals: {
16+
...globals.browser,
17+
...globals.node,
18+
},
19+
},
20+
plugins: {
21+
'jsx-a11y': jsxA11yPlugin,
22+
},
23+
rules: {
24+
...Object.fromEntries(
25+
Object.keys(jsxA11yPlugin.rules).map((rule) => [`jsx-a11y/${rule}`, 'warn'])
26+
),
27+
},
28+
},
29+
];

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"concurrently": "^10.0.3",
4040
"eslint": "10.2.1",
4141
"eslint-plugin-import-x": "^4.16.2",
42+
"eslint-plugin-jsx-a11y": "catalog:",
4243
"eslint-plugin-no-only-tests": "^3.3.0",
4344
"eslint-plugin-react-hooks": "^5.2.0",
4445
"eslint-plugin-react-refresh": "^0.4.20",

web/packages/common/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"format:fix": "prettier --write './**/*.{js,jsx,ts,tsx}'",
1111
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
1212
"lint:fix": "eslint . --fix --report-unused-disable-directives --max-warnings 0",
13+
"lint:a11y": "eslint . --config ../../eslint.config.a11y.js --no-config-lookup --no-inline-config --max-warnings 18",
1314
"test": "vitest --run",
1415
"test:ci": "vitest run --coverage",
1516
"test:watch": "vitest watch",

web/packages/studio/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dev:preview": "pnpm build:dev && vite preview",
1818
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
1919
"lint:fix": "eslint . --fix --report-unused-disable-directives --max-warnings 0",
20+
"lint:a11y": "eslint . --config ../../eslint.config.a11y.js --no-config-lookup --no-inline-config --max-warnings 73",
2021
"format": "prettier --check './**/*.{js,jsx,ts,tsx}'",
2122
"format:fix": "prettier --write './**/*.{js,jsx,ts,tsx}'",
2223
"preview": "vite preview",
@@ -111,7 +112,6 @@
111112
"@vitest/coverage-v8": "catalog:",
112113
"@vitest/ui": "catalog:",
113114
"blob-polyfill": "^9.0.20240710",
114-
"globals": "^15.11.0",
115115
"happy-dom": "catalog:",
116116
"js-yaml": "^4.2.0",
117117
"jsdom": "catalog:",

0 commit comments

Comments
 (0)