-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.js
128 lines (124 loc) · 2.85 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
import fs from 'node:fs';
import cspellESLintPluginRecommended from '@cspell/eslint-plugin/recommended';
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginAstro from 'eslint-plugin-astro';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
import tsESLint from 'typescript-eslint';
const dirs = fs
.readdirSync('./src', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
export default tsESLint.config(
eslint.configs.recommended,
...tsESLint.configs.recommended,
eslintConfigPrettier,
cspellESLintPluginRecommended,
...eslintPluginAstro.configs.recommended,
{
rules: {
'@cspell/spellchecker': [
'error',
{
configFile: new URL(
'./cspell.config.yaml',
import.meta.url,
).toString(),
checkScope: [
['ImportDeclaration[moduleSpecifier] StringLiteral', true],
],
},
],
},
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
'no-console': 2,
'no-unused-vars': 0,
'@typescript-eslint/no-unused-expressions': 0,
'@typescript-eslint/no-unused-vars': [
2,
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/explicit-function-return-type': [
2,
{
allowExpressions: true,
allowHigherOrderFunctions: true,
},
],
'@typescript-eslint/consistent-type-imports': [
2,
{
prefer: 'type-imports',
fixStyle: 'inline-type-imports',
},
],
'@typescript-eslint/naming-convention': [
2,
{
selector: ['interface', 'typeAlias'],
format: ['StrictPascalCase'],
},
],
},
},
{
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
'simple-import-sort/imports': [
2,
{
groups: [
// Side effect imports.
['^\\u0000'],
// Node.js builtins prefixed with `node:`.
['^node:', '^astro:'],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^@?\\w'],
// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything not matched in another group.
['^'],
// Custom imports.
dirs.map((dir) => `^${dir}`),
// Relative imports.
// Anything that starts with a dot.
['^\\.'],
// style files
['\\.css$', '\\.scss$'],
],
},
],
'simple-import-sort/exports': 'error',
},
},
{
files: ['src/env.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off',
},
},
{
files: ['src/**/*.astro/*.ts'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
);