Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
155 lines (153 loc) · 5.73 KB
/
Copy patheslint.config.js
File metadata and controls
155 lines (153 loc) · 5.73 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
import js from '@eslint/js';
import ts from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';
import { importX } from 'eslint-plugin-import-x';
import importNewlinesPlugin from 'eslint-plugin-import-newlines';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import globals from 'globals';
const importResolverSettings = {
'import-x/resolver': {
typescript: {
project: ['./tsconfig.json'],
alwaysTryTypes: true,
noWarnOnMultipleProjects: true
},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
}
},
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import-x/external-module-folders': ['node_modules', 'node_modules/@types']
};
export default ts.config([
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
stylistic,
'import-x': importX,
'import-newlines': importNewlinesPlugin
},
extends: [
js.configs.recommended,
ts.configs.strictTypeChecked,
ts.configs.stylisticTypeChecked,
importX.flatConfigs.recommended,
stylistic.configs.customize({
quotes: 'single',
semi: true,
indent: 4,
jsx: true
})
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: import.meta.dirname
},
globals: {
...globals.node,
...globals.es2021
}
},
settings: {
...importResolverSettings
},
rules: {
'no-control-regex': 'off', // We intentionally match ANSI escape sequences
'eqeqeq': 'error',
// One spelling for the number helpers. Number.isNaN/isFinite also skip
// the string coercion the globals do (isNaN('abc') is true).
'no-restricted-globals': ['error',
{ name: 'parseInt', message: 'Use Number.parseInt instead.' },
{ name: 'parseFloat', message: 'Use Number.parseFloat instead.' },
{ name: 'isNaN', message: 'Use Number.isNaN instead; it does not coerce its argument.' },
{ name: 'isFinite', message: 'Use Number.isFinite instead; it does not coerce its argument.' }
],
'import-x/order': ['error', {
alphabetize: {
'order': 'asc',
'orderImportKind': 'asc',
'caseInsensitive': false
},
named: {
'enabled': true,
'types': 'types-last'
},
pathGroupsExcludedImportTypes: ["builtin"],
groups: [
['builtin', 'external'],
'internal',
'parent',
'sibling',
'index',
'unknown'
],
'newlines-between': 'always'
}],
'import-newlines/enforce': ['error', {
items: 1,
semi: true
}],
'@typescript-eslint/no-unused-vars': ['error', { 'args': 'none', 'ignoreRestSiblings': true }],
'@typescript-eslint/no-empty-function': ['error', { 'allow': ['private-constructors'] }],
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-inferrable-types': ['error', { 'ignoreProperties': true }],
'@typescript-eslint/restrict-template-expressions': 'off',
'@stylistic/indent': ['error', 4, {
'ImportDeclaration': 1
}],
'@stylistic/key-spacing': 'off',
'@stylistic/comma-dangle': ['error', 'never'],
'@stylistic/no-multi-spaces': 'off',
'@stylistic/brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
'@stylistic/max-statements-per-line': ['error', { 'max': 2 }],
'@stylistic/operator-linebreak': ['error', 'before'],
'@stylistic/padding-line-between-statements': 'error',
'@stylistic/implicit-arrow-linebreak': ['error', 'beside'],
'@stylistic/no-extra-semi': 'error',
'@stylistic/nonblock-statement-body-position': ['error', 'below'],
'@stylistic/object-curly-newline': ['error', { 'multiline': true }],
'@stylistic/switch-colon-spacing': 'error',
'@stylistic/eol-last': ['error', 'always'],
'@stylistic/jsx-quotes': ['error', 'prefer-single'],
'@stylistic/multiline-ternary': 'off',
'import-x/no-unresolved': ['error'],
'import-x/no-named-as-default': 'off',
'import-x/no-named-as-default-member': 'off',
'import-x/default': 'off'
}
},
{
files: ['**/*.tsx', '**/*.jsx'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin
},
settings: {
...importResolverSettings,
react: {
version: 'detect'
}
},
rules: {
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn'
}
},
{
ignores: [
'**/dist/',
'**/node_modules/',
'**/*.js',
'!eslint.config.js'
]
}
]);