-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
170 lines (164 loc) · 6.26 KB
/
eslint.config.js
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import jsPlugin from '@eslint/js';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import prettierConfig from 'eslint-config-prettier';
import canonicalPlugin from 'eslint-plugin-canonical';
import importPlugin from 'eslint-plugin-import';
import jestPlugin from 'eslint-plugin-jest';
import jestDOMPlugin from 'eslint-plugin-jest-dom';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import markdownPlugin from 'eslint-plugin-markdown';
import perfectionistPlugin from 'eslint-plugin-perfectionist';
import reactPlugin from 'eslint-plugin-react';
import reactCompilerPlugin from 'eslint-plugin-react-compiler';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import testingLibraryPlugin from 'eslint-plugin-testing-library';
import globals from 'globals';
export default [
jsPlugin.configs.recommended,
jsxA11yPlugin.flatConfigs.strict,
prettierConfig,
perfectionistPlugin.configs['recommended-alphabetical'],
// Global ignores
{
ignores: [
'.pnp.cjs',
'superflare.env.d.ts',
'worker-configuration.d.ts',
'.wrangler/',
'.yarn/',
'build/',
'public/',
],
},
// Typescript and React
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
projectService: { allowDefaultProject: ['eslint.config.js'] },
},
},
plugins: {
'@typescript-eslint': tsPlugin,
canonical: canonicalPlugin,
import: importPlugin,
react: reactPlugin,
'react-compiler': reactCompilerPlugin,
'react-hooks': reactHooksPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,
...tsPlugin.configs.stylistic.rules,
...importPlugin.configs.recommended.rules,
...importPlugin.configs.typescript.rules,
...reactPlugin.configs.recommended.rules,
...reactPlugin.configs['jsx-runtime'].rules,
...reactHooksPlugin.configs.recommended.rules,
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/no-deprecated': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrors: 'none',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
{ ignorePrimitives: { boolean: true, string: true } },
],
'@typescript-eslint/strict-boolean-expressions': [
'error',
{ allowNullableBoolean: true, allowNullableString: true },
],
'canonical/filename-match-exported': 'error',
'canonical/prefer-inline-type-import': 'error',
'canonical/sort-react-dependencies': 'error',
// 'import/extensions': ['error', 'always', { ignorePackages: true }],
'import/order': 'off',
'jsx-a11y/control-has-associated-label': 'error',
'no-duplicate-imports': 'error',
'no-shadow': 'error',
'no-undef': 'off', // typescript handles undefined variable detection
'perfectionist/sort-modules': [
'error',
{
partitionByComment: true,
type: 'alphabetical',
},
],
'prefer-const': ['error', { destructuring: 'all' }],
'react-compiler/react-compiler': 'warn',
'react-hooks/exhaustive-deps': [
'warn',
{ enableDangerousAutofixThisMayCauseInfiniteLoops: true },
],
'react/jsx-no-leaked-render': ['warn', { validStrategies: ['ternary'] }],
'react/jsx-sort-props': 'off',
'react/no-unknown-property': 'error',
'sort-imports': 'off',
'sort-keys': 'off',
},
settings: {
formComponents: ['Form'],
'import/external-module-folders': ['.yarn'],
'import/internal-regex': '^~/',
'import/resolver': { typescript: { alwaysTryTypes: true } },
linkComponents: [
{ linkAttribute: 'to', name: 'Link' },
{ linkAttribute: 'to', name: 'NavLink' },
],
react: { version: 'detect' },
},
},
// Markdown
{
files: ['**/*.md'],
plugins: { markdown: markdownPlugin },
processor: 'markdown/markdown',
// The markdown plugin exposes three configuration blocks and is supposed
// to be included as ...markdownPlugin.configs.recommended, but doing so in
// this config makes it so that issues in markdown code blocks are missed.
rules: markdownPlugin.configs.recommended[2].rules,
},
// Jest/Vitest
{
files: ['**/*.test.{js,jsx,ts,tsx}'],
plugins: {
jest: jestPlugin,
'jest-dom': jestDOMPlugin,
'testing-library': testingLibraryPlugin,
},
settings: {
jest: {
// we're using vitest which has a very similar API to jest
// (so the linting plugins work nicely), but it means we have to explicitly
// set the jest version.
version: 28,
},
},
rules: {
...jestPlugin.configs.recommended.rules,
...jestDOMPlugin.configs.recommended.rules,
...testingLibraryPlugin.configs.react.rules,
'testing-library/no-manual-cleanup': 'off',
// the following rules require setup-test-env: import '@testing-library/jest-dom/vitest';
'jest-dom/prefer-empty': 'off',
'jest-dom/prefer-in-document': 'off',
'jest-dom/prefer-to-have-value': 'off',
},
},
// Node
{
files: ['worker.ts', 'mocks/**/*.js'],
languageOptions: {
globals: {
...globals.node,
},
},
},
];