-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy patheslint.config.js
134 lines (121 loc) · 3.12 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
import jseslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import fileExtensionInImportTs from 'eslint-plugin-file-extension-in-import-ts';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';
import tseslint, { configs as tseslintConfigs } from 'typescript-eslint';
/*
* https://typescript-eslint.io/packages/typescript-eslint/#config
* Method Description and instructions
*/
const eslintConfigs = tseslint.config(
{
// replacement for `.eslintignore`
files: ['**/*.js', '**/*.ts'],
ignores: ['**/node_modules', '**/dist/*'],
},
jseslint.configs.recommended,
importPlugin.flatConfigs.recommended,
tseslintConfigs.strict,
tseslintConfigs.stylistic,
importPlugin.flatConfigs.typescript,
{
languageOptions: {
globals: {
...globals.node,
},
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
extraFileExtensions: ['.json'],
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: import.meta.dirname,
},
},
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
plugins: {
'file-extension-in-import-ts': fileExtensionInImportTs,
// 'sort-exports': exportSortPlugin,
},
rules: {
'@typescript-eslint/consistent-type-exports': 'warn',
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-empty-interface': [
'warn',
{
allowSingleExtends: false,
},
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-var-requires': 'warn',
'@typescript-eslint/no-unused-expressions': [
'warn',
{
allowShortCircuit: true,
allowTernary: true,
},
],
'file-extension-in-import-ts/file-extension-in-import-ts': [
'error',
'always',
{
extMapping: {
'.jsx': '.js',
'.ts': '.js',
'.tsx': '.js',
},
},
],
'import/newline-after-import': 'warn',
'import/order': [
'warn',
{
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
distinctGroup: true,
// NOTE: default groups order
groups: ['builtin', 'external', 'internal', 'unknown', 'parent', 'sibling', 'index', 'object'],
'newlines-between': 'always',
pathGroups: [
{
pattern: '^#',
group: 'internal',
position: 'before',
},
],
warnOnUnassignedImports: true,
},
],
'prefer-const': ['warn'],
// 'sort-exports/sort-exports': ['warn', { sortDir: 'asc', sortExportKindFirst: 'none' }],
},
settings: {
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
typescript: {
alwaysTryTypes: true,
extensionAlias: {
'.js': ['.js', `.jsx`, '.ts', '.tsx'],
},
},
},
'import/internal-regex': '^#',
},
},
eslintConfigPrettier,
);
// eslintConfigs.forEach((config) => {
// config?.rules &&
// Object.entries(config.rules).forEach(([rule, value]) => {
// rule.includes('import') && console.log('\n\n', rule, value);
// });
// });
export default eslintConfigs;