-
-
Notifications
You must be signed in to change notification settings - Fork 534
Expand file tree
/
Copy patheslint.config.mjs
More file actions
156 lines (150 loc) · 4.6 KB
/
Copy patheslint.config.mjs
File metadata and controls
156 lines (150 loc) · 4.6 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
156
// @ts-check
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import typegen from 'eslint-typegen'
import perfectionist from 'eslint-plugin-perfectionist'
// @see reference https://github.com/nuxt/nuxt/blob/ec59aceeba3c9564ec0c3c2dfa5b468fbc464c10/eslint.config.mjs
export default createConfigForNuxt({
features: {
stylistic: {
commaDangle: 'always-multiline',
},
tooling: true,
typescript: true,
},
})
.prepend(
// ignores
{
ignores: [
'.nuxt',
'dist',
'playground',
'specs',
'test',
'coverage',
'docs',
],
},
// for global and environment
{
languageOptions: {
globals: {
$fetch: 'readonly',
NodeJS: 'readonly',
},
},
},
)
.override('nuxt/javascript', {
rules: {
'curly': ['error', 'all'], // Including if blocks with a single statement
'dot-notation': 'error',
'logical-assignment-operators': ['error', 'always', { enforceForIfStatements: true }],
'no-console': ['warn', { allow: ['warn', 'error', 'debug'] }],
'no-lonely-if': 'error', // No single if in an "else" block
'no-useless-rename': 'error',
'object-shorthand': 'error',
'prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: false }],
'require-await': 'error',
'sort-imports': ['error', { ignoreDeclarationSort: true }],
},
})
.override('nuxt/typescript/rules', {
rules: {
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
},
],
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
varsIgnorePattern: '',
},
],
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/unified-signatures': 'off',
...{
// TODO: Discuss if we want to enable this
'@typescript-eslint/ban-types': 'off',
// '@typescript-eslint/no-invalid-void-type': 'off',
},
},
})
// Stylistic rules
.override('nuxt/stylistic', {
rules: {
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
'@stylistic/indent-binary-ops': 'off',
'@stylistic/max-statements-per-line': 'off',
'@stylistic/operator-linebreak': 'off',
'@stylistic/quote-props': ['error', 'consistent'],
'@stylistic/space-before-function-paren': ['error', { 'anonymous': 'always', 'asyncArrow': 'always', 'catch': 'always', 'named': 'never' }],
},
})
.append(
// The parameterized routing/detection layer receives flags as config, reads live at composition points
{
files: [
'src/runtime/kit/**',
'src/runtime/routing/context.ts',
'src/runtime/routing/domain.ts',
'src/runtime/routing/head.ts',
'src/runtime/routing/navigation.ts',
'src/runtime/routing/utils.ts',
'src/runtime/server/utils/redirect.ts',
'src/runtime/shared/detection.ts',
'src/runtime/shared/domain.ts',
],
name: 'local/no-flag-reads',
rules: {
'no-restricted-globals': [
'error',
...[
'__I18N_DOMAINS__',
'__I18N_STRATEGY__',
'__I18N_ROUTING__',
'__TRAILING_SLASH__',
'__I18N_STRICT_SEO__',
'__I18N_COMPACT_ROUTES__',
].map(name => ({ message: 'Pass the flag through the factory config, flags are read at composition points.', name })),
],
},
},
{
rules: {
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'always' }],
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true }],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
varsIgnorePattern: '',
},
],
'jsdoc/empty-tags': ['off'],
},
},
// Sort rule keys in eslint config
// @ts-ignore type issues with eslint
{
files: ['**/eslint.config.mjs'],
name: 'local/sort-eslint-config',
plugins: {
perfectionist,
},
rules: {
'perfectionist/sort-objects': 'error',
},
},
)
// Generate type definitions for the eslint config
.onResolved(configs => typegen(configs))