-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint.config.cjs
123 lines (117 loc) · 3.58 KB
/
eslint.config.cjs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const nx = require("@nx/eslint-plugin");
const tseslint = require("typescript-eslint");
const a11y = require("eslint-plugin-jsx-a11y");
const cypress = require("eslint-plugin-cypress");
const importPlugin = require("eslint-plugin-import");
const react = require("eslint-plugin-react");
const reactHooks = require("eslint-plugin-react-hooks");
const reactRefresh = require("eslint-plugin-react-refresh");
const globals = require("globals");
delete globals.browser["AudioWorkletGlobalScope "]; // some weird bug
const baseConfig = {
name: "Base Config",
files: ["**/*.ts", "**/*.tsx"],
plugins: {
import: importPlugin,
"jsx-a11y": a11y,
nx,
react,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
"@typescript-eslint": tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2022,
tsconfigRootDir: __dirname,
EXPERIMENTAL_useProjectService: true,
//allowDefaultProjectForFiles: [ "./*.json" ], // TODO Limit Scope
ecmaFeatures: {
jsx: true,
modules: true,
},
sourceType: "module",
},
globals: {
__dirname: "readonly",
...globals.browser,
},
},
rules: {
...tseslint.configs.strictTypeChecked.rules,
...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
...a11y.configs.recommended.rules,
...importPlugin.configs.recommended.rules,
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"jsx-a11y/anchor-is-valid": "warn",
"jsx-a11y/alt-text": "warn",
"jsx-a11y/aria-role": ["warn",
{
"allowedInvalidRoles": ["sync"], // TODO update react-cismap to use other name for role prop
}
],
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/interactive-supports-focus": "warn",
"jsx-a11y/label-has-associated-control": "warn",
"jsx-a11y/no-autofocus": "warn",
"jsx-a11y/no-noninteractive-element-interactions": "warn",
"jsx-a11y/no-static-element-interactions": "warn",
"react/display-name": "off",
"react/jsx-key": "warn",
"react/jsx-no-undef": ["error", { allowGlobals: true }],
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react/jsx-no-target-blank": "off", // noopener now set by browsers
"react/no-unescaped-entities": "off", // TODO discuss template format
"react/prop-types": "warn",
"react/react-in-jsx-scope": "off", // not needed with jsx since react 17
"react-hooks/exhaustive-deps": [
"warn",
],
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"nx/enforce-module-boundaries": [
"error",
{
enforceBuildableLibDependency: true,
allow: [],
depConstraints: [
{
sourceTag: "*",
onlyDependOnLibsWithTags: ["*"],
},
],
},
],
},
settings: {
"import/parsers": {
espree: [".js", ".cjs", ".mjs", ".jsx"],
"@typescript-eslint/parser": [".ts", ".tsm", ".tsx"],
},
"import/resolver": {
...importPlugin.configs.typescript.settings["import/resolver"],
typescript: {
project: ["./tsconfig.*.json"],
},
},
react: {
version: "detect",
},
},
};
const cypressConfig = {
name: "E2E Cypress Config",
...baseConfig,
...cypress.recommended,
//plugins: { ...baseConfig.plugins, cypress },
files: ["e2e/**/*.cy.ts"],
//ignores: [],
};
// order here specific to least specific
module.exports = [baseConfig, cypressConfig];