-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patheslint.config.mjs
More file actions
102 lines (94 loc) 路 3.53 KB
/
Copy patheslint.config.mjs
File metadata and controls
102 lines (94 loc) 路 3.53 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
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
import * as eslintPluginImportX from 'eslint-plugin-import-x';
import eslintPluginJsxA11y from 'eslint-plugin-jsx-a11y';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintPluginReact from 'eslint-plugin-react';
import * as eslintPluginReactHooks from 'eslint-plugin-react-hooks';
import * as tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
eslintPluginImportX.flatConfigs.recommended,
eslintPluginImportX.flatConfigs.typescript,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
eslintPluginJsxA11y.flatConfigs.recommended,
eslintPluginReact.configs.flat.recommended,
eslintPluginPrettierRecommended,
eslintConfigPrettier,
// https://eslint.org/docs/latest/use/configure/configuration-files#excluding-files-with-ignores
// When in their own config block without files, it tells ESLint to ignore those files.
// When in a config block with files, it stops that specific config block from affecting those ignored files.
{
ignores: ['!.*', 'node_modules', 'dist', 'compiled', 'build'],
},
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
'import-x/resolver-next': [createTypeScriptImportResolver()],
react: { version: 'detect' },
},
},
{
files: ['**/*.{js,ts,jsx,tsx}'],
plugins: {
'react-hooks': eslintPluginReactHooks,
},
rules: {
...eslintPluginReactHooks.configs.recommended.rules,
'react/react-in-jsx-scope': 'off',
'prefer-template': 'error',
'no-nested-ternary': 'error',
'no-unneeded-ternary': 'error',
'spaced-comment': 'error',
'no-console': 'error',
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'typeAlias',
format: ['PascalCase'],
},
{
// Generic type parameter must start with letter T, followed by any uppercase letter.
selector: 'typeParameter',
format: ['PascalCase'],
custom: { regex: '^T[A-Z]', match: true },
},
],
'import-x/no-default-export': 'error',
'import-x/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},
},
{
files: ['stories/**/*'],
rules: {
'import-x/no-default-export': 'off',
},
},
);