-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patheslint.config.mjs
More file actions
60 lines (57 loc) · 1.89 KB
/
Copy patheslint.config.mjs
File metadata and controls
60 lines (57 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import js from "@eslint/js";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import reactPlugin from "eslint-plugin-react";
import jsxA11y from "eslint-plugin-jsx-a11y";
import globals from "globals";
/**
* Accessibility (WCAG 2.2 AA) lint rules.
*
* The jsx-a11y "recommended" ruleset is enabled as ERRORS — the existing
* codebase has been triaged and is clean (intentional exceptions carry scoped
* `eslint-disable` comments with justifications). The dedicated `lint:a11y`
* CI gate (eslint.a11y.config.mjs) enforces the same rules on every PR.
*
* See docs/accessibility.md for the full accessibility governance setup.
*/
const A11Y_SEVERITY = "error";
// Apply the jsx-a11y "recommended" ruleset, overriding only the severity while
// preserving each rule's original options. Rules the preset disables ("off")
// stay off. A rule entry is either a bare severity ("error" | "off") or a
// tuple [severity, options]; keep the options and swap the severity.
const a11yRecommendedRules = Object.fromEntries(
Object.entries(jsxA11y.flatConfigs.recommended.rules).map(([ruleName, config]) => {
const [severity, ...options] = Array.isArray(config) ? config : [config];
if (severity === "off" || severity === 0) return [ruleName, config];
return [ruleName, [A11Y_SEVERITY, ...options]];
}),
);
export default [
js.configs.recommended,
...tsPlugin.configs["flat/recommended"],
reactPlugin.configs.flat.recommended,
{
languageOptions: {
globals: globals.browser,
},
settings: {
react: {
version: "detect",
},
},
rules: {
"react/prop-types": "off",
"no-empty": "off",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-comment": "off",
},
},
// Accessibility rules — applied to all JSX/TSX source.
{
files: ["**/*.{ts,tsx,js,jsx}"],
plugins: {
"jsx-a11y": jsxA11y,
},
rules: a11yRecommendedRules,
},
];