-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
174 lines (171 loc) · 5.81 KB
/
Copy patheslint.config.mjs
File metadata and controls
174 lines (171 loc) · 5.81 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
import importPlugin from 'eslint-plugin-import-x';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import prettierPlugin from 'eslint-plugin-prettier';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
import securityPlugin from 'eslint-plugin-security';
import storybookPlugin from 'eslint-plugin-storybook';
import unusedImportsPlugin from 'eslint-plugin-unused-imports';
import globals from 'globals';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default [
{
ignores: [
'node_modules/**/*',
'public/assets/models/draco/**',
'coverage/**',
'reports/**',
'dist/**',
'dist-ssr/**',
'storybook-static/**',
'.tanstack/**',
'**/*.cjs',
// Generated, not source.
'src/i18n/messages/*.ts', // lingui compile
'src/routeTree.gen.ts',
'**/*.d.ts'
]
},
js.configs.recommended,
{
files: ['**/*.{js,jsx,mjs,ts,tsx}'],
languageOptions: {
globals: {
...globals.browser,
...globals.es2020,
...globals.node,
React: 'readonly',
NodeJS: 'readonly',
__APP_VERSION__: 'readonly'
},
parser: typescriptParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: true,
tsconfigRootDir: __dirname
}
},
settings: {
react: { version: 'detect' },
// Lets import-x follow the @/* alias, for no-unresolved and the internal group of order.
'import-x/resolver-next': [createTypeScriptImportResolver({ project: './tsconfig.json' })]
},
plugins: {
'import-x': importPlugin,
'jsx-a11y': jsxA11yPlugin,
prettier: prettierPlugin,
security: securityPlugin,
'unused-imports': unusedImportsPlugin,
'@typescript-eslint': typescriptPlugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'react-refresh': reactRefreshPlugin
},
rules: {
'no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }
],
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: true
}
],
'import-x/no-unresolved': 'error',
'import-x/order': [
'error',
{
groups: ['builtin', 'external', 'internal', ['sibling', 'parent'], 'index', 'unknown'],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true }
}
],
'react/jsx-sort-props': [
'warn',
{
ignoreCase: false,
callbacksLast: true,
shorthandFirst: true,
noSortAlphabetically: false,
multiline: 'last',
reservedFirst: true
}
],
// Warn only — a leftover console.log is fine on a feature branch.
// Shared branches run --max-warnings 0 so it still blocks there.
'no-console': 'warn',
'prettier/prettier': 'error',
'max-len': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/ban-types': 'off',
'react/no-unescaped-entities': 'error',
'react/jsx-key': 'error',
'react/jsx-no-target-blank': 'error',
'react/no-children-prop': 'error',
'react/no-danger-with-children': 'error',
'react/no-deprecated': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
...jsxA11yPlugin.flatConfigs.recommended.rules,
...securityPlugin.configs.recommended.rules,
// These two scream on every arr[i] / path.join in a frame loop. Not useful here.
'security/detect-object-injection': 'off',
'security/detect-non-literal-fs-filename': 'off'
}
},
{
// Fast Refresh only swaps a module in place if it exports components and nothing else.
files: ['src/**/*.tsx'],
rules: {
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }]
}
},
{
// Routes export `Route` next to the component — Fast Refresh can't hot-swap those.
files: ['src/routes/**/*.tsx'],
rules: { 'react-refresh/only-export-components': 'off' }
},
{
// .mjs isn't in the tsconfig. No type-aware rule on these anyway.
files: ['**/*.mjs'],
languageOptions: { parserOptions: { project: false } }
},
{
// Scripts are CLIs, their output is the interface.
files: ['scripts/**/*.{js,mjs}', 'initialize.js', '*.config.{ts,mjs}'],
rules: { 'no-console': 'off' }
},
{
// The rule is about user input reaching a regex engine, which never happens in a unit test.
files: ['tests/**/*.{ts,tsx}'],
rules: { 'security/detect-non-literal-regexp': 'off' }
},
{
// Only place allowed to name `console`.
files: ['src/utils/logger/**/*.{ts,tsx}'],
rules: { 'no-console': 'off' }
},
{
// Tests and tooling report to the terminal, not through the app logger.
files: ['tests/**/*.{ts,tsx}', 'e2e/**/*.{ts,tsx}'],
rules: { 'no-console': ['warn', { allow: ['info', 'warn', 'error'] }] }
},
...storybookPlugin.configs['flat/recommended']
];