-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patheslint.config.mjs
More file actions
146 lines (143 loc) · 5.32 KB
/
eslint.config.mjs
File metadata and controls
146 lines (143 loc) · 5.32 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
import storybook from 'eslint-plugin-storybook'
import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import pluginReact from 'eslint-plugin-react'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import importPlugin from 'eslint-plugin-import'
import reactRefresh from 'eslint-plugin-react-refresh'
export default [
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.strictTypeChecked,
pluginReact.configs.flat.recommended,
jsxA11y.flatConfigs.recommended,
pluginReact.configs.flat['jsx-runtime'],
reactRefresh.configs.vite,
{
plugins: {
'react-hooks': pluginReactHooks,
import: importPlugin,
},
rules: {
// Enforce a consistent order for imports
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'never',
},
],
'import/extensions': [
'error',
{ js: 'never', svg: 'always', png: 'always', scss: 'always', json: 'always' },
],
// Enable error for unused imports (and variables)
'@typescript-eslint/no-unused-vars': ['error'],
// Pin to the rules enforced by eslint-plugin-react-hooks < v7.
// v7's "recommended" preset additionally turns on React Compiler rules
// (refs, purity, set-state-in-effect, immutability, preserve-manual-memoization,
// static-components, globals, incompatible-library, etc.) which flag 170+
// pre-existing sites across the SDK. We intentionally keep the scope of this
// upgrade limited to avoid regressions; the new compiler rules can be
// adopted incrementally in follow-up PRs.
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: [
'**/*.config.*',
'**/*.d.ts',
'**/*.test.ts',
'**/assets/',
'**/build/',
'**/coverage/',
'**/dist/',
'**/docs/',
'**/e2e/',
'**/eslint-rules/',
'**/stylelint-rules/',
'**/generated/**/*',
'**/jest.setup.*',
'**/.prettierrc.js',
'.storybook/**/*',
'storybook-static/**/*',
],
},
{
settings: {
react: {
version: 'detect',
},
},
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unnecessary-condition': ['error', { checkTypePredicates: true }],
'@typescript-eslint/no-unnecessary-type-assertion': 'off', // TODO: fix instances; auto-fix in typescript-eslint 8.59 removes `as` casts that tsc still requires
'@typescript-eslint/no-deprecated': 'off', // TODO: fix instances
'@typescript-eslint/no-misused-promises': 'off', // TODO: fix instances
'@typescript-eslint/no-non-null-assertion': 'off', // TODO: fix instances
'@typescript-eslint/no-unsafe-argument': 'off', // TODO: fix instances
'@typescript-eslint/no-unsafe-assignment': 'off', // TODO: fix instances
'@typescript-eslint/no-unsafe-member-access': 'off', // TODO: fix instances
'@typescript-eslint/no-unsafe-return': 'off', // TODO: fix instances
'@typescript-eslint/no-unused-expressions': 'off', // TODO: fix instances
'@typescript-eslint/unified-signatures': 'off', // TODO: re-enable when bug is fixed in typescript-eslint
'no-console': 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'react-aria',
message:
'Use of react-aria is not allowed outside of the UI directory. If you need to use it, create a component in the UI directory that uses it instead and make it available via the useComponentContext hook.',
},
{
name: 'react-aria-components',
message:
'Use of react-aria-components is not allowed outside of the UI directory. If you need to use it, create a component in the UI directory that uses it instead and make it available via the useComponentContext hook.',
},
],
patterns: [
{
regex: '.*\/UI\/(?!.*Types(\.ts)?$).*',
message:
"Please use the useComponentContext hook instead: import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext' and get the component from that hook.",
},
],
},
],
},
},
{
files: [
'src/components/Common/UI/**/*.{ts,tsx}',
'src/components/Common/DateRangeFilter/**/*.{ts,tsx}',
],
rules: {
'no-restricted-imports': 'off',
},
},
{
files: ['src/components/InformationRequests/InformationRequestForm/InformationRequestForm.tsx'],
rules: {
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
},
},
...storybook.configs['flat/recommended'],
]