-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy patheslint.config.ts
More file actions
123 lines (114 loc) · 3.96 KB
/
eslint.config.ts
File metadata and controls
123 lines (114 loc) · 3.96 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
import cspellPlugin from '@cspell/eslint-plugin';
import eslint from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import eslintConfigPrettier from 'eslint-config-prettier';
import react from 'eslint-plugin-react';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
import tsEslint, { ConfigArray } from 'typescript-eslint';
import { fileURLToPath } from 'url';
/**
* @see{@link https://github.com/typescript-eslint/typescript-eslint/blob/main/eslint.config.mjs}
*/
const tsconfigRootDir = fileURLToPath(new URL('.', import.meta.url));
const config: ConfigArray = tsEslint.config(
// register all of the plugins up-front
{
plugins: {
'@typescript-eslint': tsEslint.plugin,
react,
'@stylistic': stylistic,
'simple-import-sort': simpleImportSortPlugin,
'@cspell': cspellPlugin
}
},
{
// config with just ignores is the replacement for `.eslintignore`
ignores: [
'**/node_modules/**',
'dist/**',
'.parcel-cache/**',
'docs/**'
]
},
// extends ...
eslint.configs.recommended,
...tsEslint.configs.recommended,
// base config
{
languageOptions: {
globals: { ...globals.es2020, ...globals.browser, ...globals.node },
parserOptions: {
projectService: true,
tsconfigRootDir,
warnOnUnsupportedTypeScriptVersion: false
}
},
rules: {
'arrow-body-style': ['error', 'as-needed'],
'no-empty-pattern': 'warn',
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
'consistent-return': 'warn',
'prefer-destructuring': ['error', { object: true, array: true }],
// react
'react/no-unescaped-entities': 'off',
'react/self-closing-comp': [
'error',
{ component: true, html: true }
],
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' }
],
'react/jsx-no-target-blank': 'warn',
'react/jsx-sort-props': [
'error',
{
reservedFirst: true,
callbacksLast: true,
noSortAlphabetically: true
}
],
// typescript
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',
// stylistic
'@stylistic/padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: 'directive', next: '*' },
{ blankLine: 'any', prev: 'directive', next: 'directive' },
{
blankLine: 'always',
prev: '*',
next: ['enum', 'interface', 'type']
}
],
// simple-import-sort
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
// spellchecker
'@cspell/spellchecker': [
'warn',
{
cspell: {
language: 'en',
dictionaries: [
'typescript',
'node',
'html',
'css',
'bash',
'npm',
'pnpm'
]
}
}
]
}
},
eslintConfigPrettier
);
export default config;