@ntnyq/eslint-config 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/index.js +2 -0
- package/lib/astro.js +1 -2
- package/lib/js.js +346 -5
- package/lib/jsonc.js +10 -7
- package/lib/markdown.js +6 -3
- package/lib/presets.js +40 -4
- package/lib/prettier.js +1 -4
- package/lib/shared.js +13 -12
- package/lib/ts.js +10 -3
- package/lib/vue.js +42 -3
- package/lib/yml.js +1 -2
- package/package.json +20 -19
package/README.md
CHANGED
|
@@ -5,6 +5,25 @@
|
|
|
5
5
|
[](https://github.com/ntnyq/eslint-config/actions)
|
|
6
6
|
[](https://www.npmjs.com/package/@ntnyq/eslint-config/v/next)
|
|
7
7
|
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @ntnyq/eslint-config@next eslint-define-config -D
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Config in `eslint.config.{js,cjs,mjs}`:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { defineFlatConfig } from 'eslint-define-config'
|
|
20
|
+
import { all } from '@ntnyq/eslint-config'
|
|
21
|
+
|
|
22
|
+
export default defineFlatConfig(all)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Make sure to config `"eslint.experimental.useFlatConfig": true` in `.vscode/settings.json`
|
|
26
|
+
|
|
8
27
|
## Credits
|
|
9
28
|
|
|
10
29
|
- [@sxzz/eslint-config](https://github.com/sxzz/eslint-config)
|
package/index.js
CHANGED
package/lib/astro.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import astroPlugin, { configs } from 'eslint-plugin-astro'
|
|
2
2
|
import astroParser from 'astro-eslint-parser'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_ASTRO } from './shared.js'
|
|
4
4
|
|
|
5
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
6
|
export const astro = [
|
|
7
7
|
{
|
|
8
8
|
files: [GLOB_ASTRO],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
9
|
plugins: {
|
|
11
10
|
astro: astroPlugin,
|
|
12
11
|
},
|
package/lib/js.js
CHANGED
|
@@ -2,7 +2,6 @@ import globals from 'globals'
|
|
|
2
2
|
import jsConfig from '@eslint/js'
|
|
3
3
|
import importPlugin from 'eslint-plugin-import'
|
|
4
4
|
import unicornPlugin from 'eslint-plugin-unicorn'
|
|
5
|
-
import { GLOB_EXCLUDE } from './shared.js'
|
|
6
5
|
|
|
7
6
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
8
7
|
export const js = [
|
|
@@ -16,12 +15,349 @@ export const js = [
|
|
|
16
15
|
},
|
|
17
16
|
sourceType: 'module',
|
|
18
17
|
},
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
rules: {
|
|
20
|
+
// standard v 17.0.0
|
|
21
|
+
'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
|
|
22
|
+
'array-bracket-spacing': ['error', 'never'],
|
|
23
|
+
'arrow-spacing': ['error', { before: true, after: true }],
|
|
24
|
+
'block-spacing': ['error', 'always'],
|
|
25
|
+
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
|
26
|
+
camelcase: [
|
|
27
|
+
'error',
|
|
28
|
+
{
|
|
29
|
+
allow: ['^UNSAFE_'],
|
|
30
|
+
properties: 'never',
|
|
31
|
+
ignoreGlobals: true,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
'comma-spacing': ['error', { before: false, after: true }],
|
|
35
|
+
'comma-style': ['error', 'last'],
|
|
36
|
+
'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
|
|
37
|
+
'constructor-super': 'error',
|
|
38
|
+
curly: ['error', 'multi-line'],
|
|
39
|
+
'default-case-last': 'error',
|
|
40
|
+
'dot-location': ['error', 'property'],
|
|
41
|
+
'dot-notation': ['error', { allowKeywords: true }],
|
|
42
|
+
'eol-last': 'error',
|
|
43
|
+
'func-call-spacing': ['error', 'never'],
|
|
44
|
+
indent: [
|
|
45
|
+
'error',
|
|
46
|
+
2,
|
|
47
|
+
{
|
|
48
|
+
SwitchCase: 1,
|
|
49
|
+
VariableDeclarator: 1,
|
|
50
|
+
outerIIFEBody: 1,
|
|
51
|
+
MemberExpression: 1,
|
|
52
|
+
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
53
|
+
FunctionExpression: { parameters: 1, body: 1 },
|
|
54
|
+
CallExpression: { arguments: 1 },
|
|
55
|
+
ArrayExpression: 1,
|
|
56
|
+
ObjectExpression: 1,
|
|
57
|
+
ImportDeclaration: 1,
|
|
58
|
+
flatTernaryExpressions: false,
|
|
59
|
+
ignoreComments: false,
|
|
60
|
+
ignoredNodes: [
|
|
61
|
+
'TemplateLiteral *',
|
|
62
|
+
'JSXElement',
|
|
63
|
+
'JSXElement > *',
|
|
64
|
+
'JSXAttribute',
|
|
65
|
+
'JSXIdentifier',
|
|
66
|
+
'JSXNamespacedName',
|
|
67
|
+
'JSXMemberExpression',
|
|
68
|
+
'JSXSpreadAttribute',
|
|
69
|
+
'JSXExpressionContainer',
|
|
70
|
+
'JSXOpeningElement',
|
|
71
|
+
'JSXClosingElement',
|
|
72
|
+
'JSXFragment',
|
|
73
|
+
'JSXOpeningFragment',
|
|
74
|
+
'JSXClosingFragment',
|
|
75
|
+
'JSXText',
|
|
76
|
+
'JSXEmptyExpression',
|
|
77
|
+
'JSXSpreadChild',
|
|
78
|
+
],
|
|
79
|
+
offsetTernaryExpressions: true,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
|
83
|
+
'keyword-spacing': ['error', { before: true, after: true }],
|
|
84
|
+
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
|
85
|
+
'multiline-ternary': ['error', 'always-multiline'],
|
|
86
|
+
'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
|
|
87
|
+
'new-parens': 'error',
|
|
88
|
+
'no-array-constructor': 'error',
|
|
89
|
+
'no-async-promise-executor': 'error',
|
|
90
|
+
'no-caller': 'error',
|
|
91
|
+
'no-class-assign': 'error',
|
|
92
|
+
'no-compare-neg-zero': 'error',
|
|
93
|
+
'no-cond-assign': 'error',
|
|
94
|
+
'no-const-assign': 'error',
|
|
95
|
+
'no-constant-condition': ['error', { checkLoops: false }],
|
|
96
|
+
'no-control-regex': 'error',
|
|
97
|
+
'no-debugger': 'error',
|
|
98
|
+
'no-delete-var': 'error',
|
|
99
|
+
'no-dupe-args': 'error',
|
|
100
|
+
'no-dupe-class-members': 'error',
|
|
101
|
+
'no-dupe-keys': 'error',
|
|
102
|
+
'no-duplicate-case': 'error',
|
|
103
|
+
'no-useless-backreference': 'error',
|
|
104
|
+
'no-empty': ['error', { allowEmptyCatch: true }],
|
|
105
|
+
'no-empty-character-class': 'error',
|
|
106
|
+
'no-empty-pattern': 'error',
|
|
107
|
+
'no-eval': 'error',
|
|
108
|
+
'no-ex-assign': 'error',
|
|
109
|
+
'no-extend-native': 'error',
|
|
110
|
+
'no-extra-bind': 'error',
|
|
111
|
+
'no-extra-boolean-cast': 'error',
|
|
112
|
+
'no-extra-parens': ['error', 'functions'],
|
|
113
|
+
'no-fallthrough': 'error',
|
|
114
|
+
'no-floating-decimal': 'error',
|
|
115
|
+
'no-func-assign': 'error',
|
|
116
|
+
'no-global-assign': 'error',
|
|
117
|
+
'no-implied-eval': 'error',
|
|
118
|
+
'no-import-assign': 'error',
|
|
119
|
+
'no-invalid-regexp': 'error',
|
|
120
|
+
'no-irregular-whitespace': 'error',
|
|
121
|
+
'no-iterator': 'error',
|
|
122
|
+
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
|
123
|
+
'no-lone-blocks': 'error',
|
|
124
|
+
'no-loss-of-precision': 'error',
|
|
125
|
+
'no-misleading-character-class': 'error',
|
|
126
|
+
'no-prototype-builtins': 'error',
|
|
127
|
+
'no-useless-catch': 'error',
|
|
128
|
+
'no-mixed-operators': [
|
|
129
|
+
'error',
|
|
130
|
+
{
|
|
131
|
+
groups: [
|
|
132
|
+
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
|
133
|
+
['&&', '||'],
|
|
134
|
+
['in', 'instanceof'],
|
|
135
|
+
],
|
|
136
|
+
allowSamePrecedence: true,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
'no-mixed-spaces-and-tabs': 'error',
|
|
140
|
+
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
141
|
+
'no-new': 'error',
|
|
142
|
+
'no-new-func': 'error',
|
|
143
|
+
'no-new-object': 'error',
|
|
144
|
+
'no-new-symbol': 'error',
|
|
145
|
+
'no-new-wrappers': 'error',
|
|
146
|
+
'no-obj-calls': 'error',
|
|
147
|
+
'no-octal': 'error',
|
|
148
|
+
'no-octal-escape': 'error',
|
|
149
|
+
'no-proto': 'error',
|
|
150
|
+
'no-redeclare': ['error', { builtinGlobals: false }],
|
|
151
|
+
'no-regex-spaces': 'error',
|
|
152
|
+
'no-self-assign': ['error', { props: true }],
|
|
153
|
+
'no-self-compare': 'error',
|
|
154
|
+
'no-sequences': 'error',
|
|
155
|
+
'no-shadow-restricted-names': 'error',
|
|
156
|
+
'no-sparse-arrays': 'error',
|
|
157
|
+
'no-tabs': 'error',
|
|
158
|
+
'no-template-curly-in-string': 'error',
|
|
159
|
+
'no-this-before-super': 'error',
|
|
160
|
+
'no-throw-literal': 'error',
|
|
161
|
+
'no-trailing-spaces': 'error',
|
|
162
|
+
'no-undef': 'error',
|
|
163
|
+
'no-undef-init': 'error',
|
|
164
|
+
'no-unexpected-multiline': 'error',
|
|
165
|
+
'no-unmodified-loop-condition': 'error',
|
|
166
|
+
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
|
|
167
|
+
'no-unreachable': 'error',
|
|
168
|
+
'no-unreachable-loop': 'error',
|
|
169
|
+
'no-unsafe-finally': 'error',
|
|
170
|
+
'no-unsafe-negation': 'error',
|
|
171
|
+
'no-unused-expressions': [
|
|
172
|
+
'error',
|
|
173
|
+
{
|
|
174
|
+
allowShortCircuit: true,
|
|
175
|
+
allowTernary: true,
|
|
176
|
+
allowTaggedTemplates: true,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
'no-unused-vars': [
|
|
180
|
+
'error',
|
|
181
|
+
{
|
|
182
|
+
args: 'none',
|
|
183
|
+
caughtErrors: 'none',
|
|
184
|
+
ignoreRestSiblings: true,
|
|
185
|
+
vars: 'all',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
'no-useless-call': 'error',
|
|
189
|
+
'no-useless-computed-key': 'error',
|
|
190
|
+
'no-useless-constructor': 'error',
|
|
191
|
+
'no-useless-rename': 'error',
|
|
192
|
+
'no-useless-return': 'error',
|
|
193
|
+
'no-whitespace-before-property': 'error',
|
|
194
|
+
'object-curly-newline': ['error', { multiline: true, consistent: true }],
|
|
195
|
+
'object-curly-spacing': ['error', 'always'],
|
|
196
|
+
'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
|
|
197
|
+
'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
|
|
198
|
+
'prefer-promise-reject-errors': 'error',
|
|
199
|
+
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
|
|
200
|
+
'quote-props': ['error', 'as-needed'],
|
|
201
|
+
'rest-spread-spacing': ['error', 'never'],
|
|
202
|
+
semi: ['error', 'never'],
|
|
203
|
+
'semi-spacing': ['error', { before: false, after: true }],
|
|
204
|
+
'space-before-blocks': ['error', 'always'],
|
|
205
|
+
'space-before-function-paren': ['error', 'always'],
|
|
206
|
+
'space-in-parens': ['error', 'never'],
|
|
207
|
+
'space-infix-ops': 'error',
|
|
208
|
+
'space-unary-ops': ['error', { words: true, nonwords: false }],
|
|
209
|
+
'symbol-description': 'error',
|
|
210
|
+
'template-tag-spacing': ['error', 'never'],
|
|
211
|
+
'unicode-bom': ['error', 'never'],
|
|
212
|
+
'use-isnan': [
|
|
213
|
+
'error',
|
|
214
|
+
{
|
|
215
|
+
enforceForSwitchCase: true,
|
|
216
|
+
enforceForIndexOf: true,
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
'valid-typeof': ['error', { requireStringLiterals: true }],
|
|
220
|
+
'wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
|
|
221
|
+
'yield-star-spacing': ['error', 'both'],
|
|
222
|
+
yoda: ['error', 'never'],
|
|
223
|
+
|
|
224
|
+
// es6+
|
|
225
|
+
'no-var': 'error',
|
|
226
|
+
'prefer-rest-params': 'error',
|
|
227
|
+
'prefer-spread': 'error',
|
|
228
|
+
'prefer-template': 'error',
|
|
229
|
+
'template-curly-spacing': 'error',
|
|
230
|
+
'generator-star-spacing': 'off',
|
|
231
|
+
'no-empty-static-block': 'error',
|
|
232
|
+
'no-new-native-nonconstructor': 'error',
|
|
233
|
+
'arrow-parens': [
|
|
234
|
+
'error',
|
|
235
|
+
'as-needed',
|
|
236
|
+
{
|
|
237
|
+
requireForBlockBody: false,
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
quotes: [
|
|
241
|
+
'error',
|
|
242
|
+
'single',
|
|
243
|
+
{
|
|
244
|
+
avoidEscape: true,
|
|
245
|
+
allowTemplateLiterals: false,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
'prefer-const': [
|
|
249
|
+
'error',
|
|
250
|
+
{
|
|
251
|
+
destructuring: 'all',
|
|
252
|
+
ignoreReadBeforeAssign: true,
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
'prefer-arrow-callback': [
|
|
256
|
+
'error',
|
|
257
|
+
{
|
|
258
|
+
allowNamedFunctions: false,
|
|
259
|
+
allowUnboundThis: true,
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
'object-shorthand': [
|
|
263
|
+
'error',
|
|
264
|
+
'always',
|
|
265
|
+
{
|
|
266
|
+
ignoreConstructors: false,
|
|
267
|
+
avoidQuotes: true,
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
'spaced-comment': [
|
|
271
|
+
'error',
|
|
272
|
+
'always',
|
|
273
|
+
{
|
|
274
|
+
line: {
|
|
275
|
+
markers: ['/'],
|
|
276
|
+
exceptions: ['/', '#'],
|
|
277
|
+
},
|
|
278
|
+
block: {
|
|
279
|
+
markers: ['!'],
|
|
280
|
+
exceptions: ['*'],
|
|
281
|
+
balanced: true,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
|
|
286
|
+
// best-practice
|
|
287
|
+
eqeqeq: ['error', 'smart'],
|
|
288
|
+
complexity: ['error', { max: 30 }],
|
|
289
|
+
'array-callback-return': 'error',
|
|
290
|
+
'block-scoped-var': 'error',
|
|
291
|
+
'consistent-return': 'off',
|
|
292
|
+
'no-alert': 'error',
|
|
293
|
+
'no-case-declarations': 'error',
|
|
294
|
+
'no-multi-spaces': 'error',
|
|
295
|
+
'no-multi-str': 'error',
|
|
296
|
+
'no-with': 'error',
|
|
297
|
+
'no-void': 'error',
|
|
298
|
+
'no-useless-escape': 'off',
|
|
299
|
+
'vars-on-top': 'error',
|
|
300
|
+
'require-await': 'off',
|
|
301
|
+
'no-return-assign': 'off',
|
|
302
|
+
'one-var': ['error', 'never'],
|
|
303
|
+
'operator-linebreak': ['error', 'before'],
|
|
304
|
+
'comma-dangle': ['error', 'always-multiline'],
|
|
305
|
+
'max-params': ['error', { max: 5 }],
|
|
306
|
+
'max-depth': ['error', { max: 5 }],
|
|
307
|
+
'max-nested-callbacks': ['error', { max: 10 }],
|
|
308
|
+
'max-statements-per-line': ['error', { max: 2 }],
|
|
309
|
+
'max-lines': [
|
|
310
|
+
'error',
|
|
311
|
+
{
|
|
312
|
+
max: 1000,
|
|
313
|
+
skipComments: true,
|
|
314
|
+
skipBlankLines: true,
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
'max-lines-per-function': [
|
|
318
|
+
'error',
|
|
319
|
+
{
|
|
320
|
+
max: 100,
|
|
321
|
+
skipComments: true,
|
|
322
|
+
skipBlankLines: true,
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
'no-use-before-define': [
|
|
326
|
+
'error',
|
|
327
|
+
{
|
|
328
|
+
functions: false,
|
|
329
|
+
classes: false,
|
|
330
|
+
variables: true,
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
'max-len': [
|
|
334
|
+
'error',
|
|
335
|
+
{
|
|
336
|
+
code: 200,
|
|
337
|
+
tabWidth: 2,
|
|
338
|
+
comments: 200,
|
|
339
|
+
ignoreUrls: true,
|
|
340
|
+
ignoreStrings: true,
|
|
341
|
+
ignoreRegExpLiterals: true,
|
|
342
|
+
ignoreTemplateLiterals: true,
|
|
343
|
+
ignoreTrailingComments: true,
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
'sort-imports': [
|
|
347
|
+
'error',
|
|
348
|
+
{
|
|
349
|
+
ignoreCase: false,
|
|
350
|
+
ignoreDeclarationSort: true,
|
|
351
|
+
ignoreMemberSort: false,
|
|
352
|
+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
|
353
|
+
allowSeparatedGroups: false,
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
},
|
|
20
357
|
},
|
|
21
358
|
|
|
22
359
|
{
|
|
23
360
|
files: ['**/scripts/*', '**/cli.*'],
|
|
24
|
-
ignores: GLOB_EXCLUDE,
|
|
25
361
|
rules: {
|
|
26
362
|
'no-console': 'off',
|
|
27
363
|
},
|
|
@@ -40,7 +376,6 @@ export const js = [
|
|
|
40
376
|
export const jsx = [
|
|
41
377
|
{
|
|
42
378
|
files: ['**/*.jsx'],
|
|
43
|
-
ignores: GLOB_EXCLUDE,
|
|
44
379
|
languageOptions: {
|
|
45
380
|
parserOptions: {
|
|
46
381
|
ecmaFeatures: {
|
|
@@ -59,10 +394,15 @@ export const imports = [
|
|
|
59
394
|
},
|
|
60
395
|
settings: {
|
|
61
396
|
'import/resolver': {
|
|
62
|
-
node: { extensions: ['.js', '.mjs', '.ts', '.d.ts'] },
|
|
397
|
+
node: { extensions: ['.js', '.mjs', '.ts', '.mts', '.d.ts'] },
|
|
63
398
|
},
|
|
64
399
|
},
|
|
65
400
|
rules: {
|
|
401
|
+
'import/no-unresolved': 'off',
|
|
402
|
+
'import/no-absolute-path': 'off',
|
|
403
|
+
'import/no-named-as-default-member': 'off',
|
|
404
|
+
|
|
405
|
+
'import/newline-after-import': 'error',
|
|
66
406
|
'import/first': 'error',
|
|
67
407
|
'import/no-mutable-exports': 'error',
|
|
68
408
|
'import/no-duplicates': 'error',
|
|
@@ -79,6 +419,7 @@ export const imports = [
|
|
|
79
419
|
'object',
|
|
80
420
|
'type',
|
|
81
421
|
],
|
|
422
|
+
'newlines-between': 'never',
|
|
82
423
|
pathGroups: [{ pattern: '@/**', group: 'internal' }],
|
|
83
424
|
pathGroupsExcludedImportTypes: ['type'],
|
|
84
425
|
},
|
package/lib/jsonc.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import jsoncPlugin, { configs } from 'eslint-plugin-jsonc'
|
|
2
2
|
import jsoncParser from 'jsonc-eslint-parser'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from './shared.js'
|
|
4
4
|
|
|
5
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
6
|
export const jsonc = [
|
|
7
7
|
{
|
|
8
8
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, '**/*rc'],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
9
|
plugins: {
|
|
11
10
|
jsonc: jsoncPlugin,
|
|
12
11
|
},
|
|
@@ -55,13 +54,13 @@ export const pkgOrder = [
|
|
|
55
54
|
{
|
|
56
55
|
pathPattern: '^$',
|
|
57
56
|
order: [
|
|
57
|
+
'publisher',
|
|
58
58
|
'name',
|
|
59
|
+
'displayName',
|
|
59
60
|
'type',
|
|
60
61
|
'version',
|
|
61
62
|
'private',
|
|
62
63
|
'packageManager',
|
|
63
|
-
'publisher',
|
|
64
|
-
'displayName',
|
|
65
64
|
'description',
|
|
66
65
|
'keywords',
|
|
67
66
|
'license',
|
|
@@ -69,15 +68,17 @@ export const pkgOrder = [
|
|
|
69
68
|
'homepage',
|
|
70
69
|
'repository',
|
|
71
70
|
'funding',
|
|
71
|
+
'exports',
|
|
72
72
|
'main',
|
|
73
73
|
'module',
|
|
74
|
-
'types',
|
|
75
74
|
'unpkg',
|
|
76
75
|
'jsdelivr',
|
|
77
|
-
|
|
78
|
-
'
|
|
76
|
+
// workaround for `type: "module"` with TS `moduleResolution: "node16"`
|
|
77
|
+
'types',
|
|
78
|
+
'typesVersions',
|
|
79
79
|
'bin',
|
|
80
80
|
'icon',
|
|
81
|
+
'files',
|
|
81
82
|
'sideEffects',
|
|
82
83
|
'scripts',
|
|
83
84
|
'peerDependencies',
|
|
@@ -90,6 +91,8 @@ export const pkgOrder = [
|
|
|
90
91
|
'categories',
|
|
91
92
|
'engines',
|
|
92
93
|
'pnpm',
|
|
94
|
+
'overrides',
|
|
95
|
+
'resolutions',
|
|
93
96
|
'husky',
|
|
94
97
|
'prettier',
|
|
95
98
|
'nano-staged',
|
package/lib/markdown.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import markdownPlugin from 'eslint-plugin-markdown'
|
|
2
|
-
import
|
|
2
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
3
|
+
import { GLOB_MARKDOWN, GLOB_SRC, GLOB_VUE } from './shared.js'
|
|
3
4
|
|
|
4
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
5
6
|
export const markdown = [
|
|
6
7
|
{
|
|
7
8
|
files: [GLOB_MARKDOWN],
|
|
8
|
-
ignores: GLOB_EXCLUDE,
|
|
9
9
|
plugins: {
|
|
10
10
|
markdown: markdownPlugin,
|
|
11
11
|
},
|
|
12
12
|
processor: 'markdown/markdown',
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
files: [
|
|
15
|
+
files: [`**/*.md/${GLOB_SRC}`, `**/*.md/${GLOB_VUE}`],
|
|
16
16
|
languageOptions: {
|
|
17
17
|
parserOptions: {
|
|
18
18
|
ecmaFeatures: {
|
|
@@ -20,6 +20,9 @@ export const markdown = [
|
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
+
plugins: {
|
|
24
|
+
'@typescript-eslint': tsPlugin,
|
|
25
|
+
},
|
|
23
26
|
rules: {
|
|
24
27
|
...markdownPlugin.configs.recommended.overrides[1].rules,
|
|
25
28
|
'no-undef': 'off',
|
package/lib/presets.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
2
3
|
import { ts } from './ts.js'
|
|
3
4
|
import { yml } from './yml.js'
|
|
4
5
|
import { vue } from './vue.js'
|
|
6
|
+
import { astro } from './astro.js'
|
|
7
|
+
import { prettier } from './prettier.js'
|
|
5
8
|
import { markdown } from './markdown.js'
|
|
6
9
|
import { jsonc, pkgOrder } from './jsonc.js'
|
|
7
10
|
import { imports, js, jsx, unicorn } from './js.js'
|
|
8
11
|
import { eslintComments } from './eslint-comments.js'
|
|
12
|
+
import { GLOB_EXCLUDE } from './shared.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef { import('eslint-define-config').FlatESLintConfig } FlatESLintConfig
|
|
16
|
+
*/
|
|
9
17
|
|
|
10
|
-
/** @type {
|
|
11
|
-
export const
|
|
12
|
-
|
|
18
|
+
/** @type {FlatESLintConfig[]} */
|
|
19
|
+
export const basic = [
|
|
20
|
+
{ ignores: GLOB_EXCLUDE },
|
|
13
21
|
...js,
|
|
14
22
|
...jsx,
|
|
15
23
|
...ts,
|
|
@@ -22,3 +30,31 @@ export const presetBasic = [
|
|
|
22
30
|
...markdown,
|
|
23
31
|
...eslintComments,
|
|
24
32
|
]
|
|
33
|
+
|
|
34
|
+
/** @type {FlatESLintConfig[]} */
|
|
35
|
+
export const all = [...vue, ...astro, ...basic, ...prettier]
|
|
36
|
+
|
|
37
|
+
/** @type {(config?: FlatESLintConfig | FlatESLintConfig[], enables?: Partial<{
|
|
38
|
+
* vue: boolean
|
|
39
|
+
* prettier: boolean
|
|
40
|
+
* markdown: boolean
|
|
41
|
+
* }>) => FlatESLintConfig[]} */
|
|
42
|
+
export function ntnyq(
|
|
43
|
+
config = [],
|
|
44
|
+
{ vue: enableVue = true, prettier: enablePrettier = true, markdown: enableMarkdown = true } = {},
|
|
45
|
+
) {
|
|
46
|
+
const configs = [...basic]
|
|
47
|
+
if (enableVue !== false) {
|
|
48
|
+
configs.push(...vue)
|
|
49
|
+
}
|
|
50
|
+
if (enableMarkdown !== false) {
|
|
51
|
+
configs.push(...markdown)
|
|
52
|
+
}
|
|
53
|
+
if (enablePrettier !== false) {
|
|
54
|
+
configs.push(...prettier)
|
|
55
|
+
}
|
|
56
|
+
if (Object.keys(config).length > 0) {
|
|
57
|
+
configs.push(...(Array.isArray(config) ? config : [config]))
|
|
58
|
+
}
|
|
59
|
+
return configs
|
|
60
|
+
}
|
package/lib/prettier.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import prettierPlugin from 'eslint-plugin-prettier'
|
|
2
2
|
import prettierConfig from 'eslint-config-prettier'
|
|
3
3
|
|
|
4
|
-
const prettierConflictRules = { ...prettierConfig.rules }
|
|
5
|
-
delete prettierConflictRules['vue/html-self-closing']
|
|
6
|
-
|
|
7
4
|
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
8
5
|
export const prettier = [
|
|
9
6
|
{
|
|
@@ -11,7 +8,7 @@ export const prettier = [
|
|
|
11
8
|
prettier: prettierPlugin,
|
|
12
9
|
},
|
|
13
10
|
rules: {
|
|
14
|
-
...
|
|
11
|
+
...prettierConfig.rules,
|
|
15
12
|
...prettierPlugin.configs.recommended.rules,
|
|
16
13
|
'prettier/prettier': 'warn',
|
|
17
14
|
},
|
package/lib/shared.js
CHANGED
|
@@ -24,7 +24,7 @@ export const GLOB_MARKDOWN = '**/*.md'
|
|
|
24
24
|
export const GLOB_YAML = '**/*.y?(a)ml'
|
|
25
25
|
export const GLOB_HTML = '**/*.htm?(l)'
|
|
26
26
|
|
|
27
|
-
export const GLOB_ALL_SRC =
|
|
27
|
+
export const GLOB_ALL_SRC = [
|
|
28
28
|
GLOB_SRC,
|
|
29
29
|
GLOB_STYLE,
|
|
30
30
|
GLOB_JSON,
|
|
@@ -33,16 +33,12 @@ export const GLOB_ALL_SRC = /** @type {const} */ ([
|
|
|
33
33
|
GLOB_VUE,
|
|
34
34
|
GLOB_YAML,
|
|
35
35
|
GLOB_HTML,
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
export const GLOB_NODE_MODULES =
|
|
39
|
-
export const GLOB_DIST =
|
|
40
|
-
export const GLOB_LOCKFILE =
|
|
41
|
-
|
|
42
|
-
'**/yarn.lock',
|
|
43
|
-
'**/pnpm-lock.yaml',
|
|
44
|
-
])
|
|
45
|
-
export const GLOB_EXCLUDE = /** @type {const} */ ([
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
export const GLOB_NODE_MODULES = '**/node_modules/**'
|
|
39
|
+
export const GLOB_DIST = '**/dist/**'
|
|
40
|
+
export const GLOB_LOCKFILE = ['**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml']
|
|
41
|
+
export const GLOB_EXCLUDE = [
|
|
46
42
|
GLOB_NODE_MODULES,
|
|
47
43
|
GLOB_DIST,
|
|
48
44
|
...GLOB_LOCKFILE,
|
|
@@ -52,10 +48,15 @@ export const GLOB_EXCLUDE = /** @type {const} */ ([
|
|
|
52
48
|
'**/output',
|
|
53
49
|
'**/coverage',
|
|
54
50
|
'**/temp',
|
|
51
|
+
'**/cache',
|
|
55
52
|
'**/fixtures',
|
|
53
|
+
'**/.vitepress/cache',
|
|
54
|
+
'**/.nuxt',
|
|
55
|
+
'**/.vercel',
|
|
56
|
+
'**/.changeset',
|
|
56
57
|
'**/__snapshots__',
|
|
57
58
|
'**/auto-import.d.ts',
|
|
58
59
|
'**/components.d.ts',
|
|
59
60
|
'**/.npmrc',
|
|
60
61
|
'**/.yarnrc',
|
|
61
|
-
]
|
|
62
|
+
]
|
package/lib/ts.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import tsParser from '@typescript-eslint/parser'
|
|
2
2
|
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_TS, GLOB_TSX } from './shared.js'
|
|
4
|
+
|
|
5
|
+
export { tsParser, tsPlugin }
|
|
4
6
|
|
|
5
7
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
8
|
export const ts = [
|
|
7
9
|
{
|
|
8
10
|
files: [GLOB_TS, GLOB_TSX],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
11
|
languageOptions: {
|
|
11
12
|
parser: tsParser,
|
|
12
13
|
parserOptions: {
|
|
@@ -53,7 +54,6 @@ export const ts = [
|
|
|
53
54
|
|
|
54
55
|
{
|
|
55
56
|
files: ['**/*.d.ts'],
|
|
56
|
-
ignores: GLOB_EXCLUDE,
|
|
57
57
|
rules: {
|
|
58
58
|
'import/no-duplicates': 'off',
|
|
59
59
|
'import/newline-after-import': 'off',
|
|
@@ -67,4 +67,11 @@ export const ts = [
|
|
|
67
67
|
'max-lines-per-function': 'off',
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
|
+
|
|
71
|
+
{
|
|
72
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
73
|
+
rules: {
|
|
74
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
70
77
|
]
|
package/lib/vue.js
CHANGED
|
@@ -1,23 +1,62 @@
|
|
|
1
|
+
import { getPackageInfoSync } from 'local-pkg'
|
|
1
2
|
import vuePlugin from 'eslint-plugin-vue'
|
|
2
3
|
import vueParser from 'vue-eslint-parser'
|
|
3
|
-
import
|
|
4
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
5
|
+
import { ts } from './ts.js'
|
|
6
|
+
import { GLOB_VUE } from './shared.js'
|
|
7
|
+
|
|
8
|
+
export { vueParser, vuePlugin }
|
|
9
|
+
|
|
10
|
+
export function getVueVersion() {
|
|
11
|
+
const pkg = getPackageInfoSync('vue', { paths: [process.cwd()] })
|
|
12
|
+
if (pkg && typeof pkg.version === 'string' && !Number.isNaN(+pkg.version[0])) {
|
|
13
|
+
return +pkg.version[0]
|
|
14
|
+
}
|
|
15
|
+
return 3
|
|
16
|
+
}
|
|
17
|
+
const isVue3 = getVueVersion() === 3
|
|
18
|
+
|
|
19
|
+
/** @type {import('eslint-define-config').Rules} */
|
|
20
|
+
const vueBaseRules = {}
|
|
21
|
+
|
|
22
|
+
/** @type {import('eslint-define-config').Rules} */
|
|
23
|
+
const vue2Rules = {
|
|
24
|
+
...vueBaseRules,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @type {import('eslint-define-config').Rules} */
|
|
28
|
+
const vue3Rules = {
|
|
29
|
+
...vueBaseRules,
|
|
30
|
+
}
|
|
4
31
|
|
|
5
32
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
33
|
export const vue = [
|
|
7
34
|
{
|
|
8
35
|
files: [GLOB_VUE],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
36
|
plugins: {
|
|
11
37
|
vue: vuePlugin,
|
|
38
|
+
'@typescript-eslint': tsPlugin,
|
|
12
39
|
},
|
|
13
40
|
languageOptions: {
|
|
14
41
|
parser: vueParser,
|
|
15
42
|
parserOptions: {
|
|
16
43
|
parser: '@typescript-eslint/parser',
|
|
44
|
+
sourceType: 'module',
|
|
45
|
+
extraFileExtensions: ['.vue'],
|
|
46
|
+
ecmaFeatures: {
|
|
47
|
+
jsx: true,
|
|
48
|
+
},
|
|
17
49
|
},
|
|
18
50
|
},
|
|
51
|
+
processor: vuePlugin.processors['.vue'],
|
|
19
52
|
rules: {
|
|
20
|
-
...
|
|
53
|
+
...ts[0].rules,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
plugins: {
|
|
58
|
+
vue: vuePlugin,
|
|
21
59
|
},
|
|
60
|
+
rules: isVue3 ? vue3Rules : vue2Rules,
|
|
22
61
|
},
|
|
23
62
|
]
|
package/lib/yml.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import ymlPlugin, { configs } from 'eslint-plugin-yml'
|
|
2
2
|
import ymlParser from 'yaml-eslint-parser'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_YAML } from './shared.js'
|
|
4
4
|
|
|
5
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
6
|
export const yml = [
|
|
7
7
|
{
|
|
8
8
|
files: [GLOB_YAML],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
9
|
languageOptions: {
|
|
11
10
|
parser: ymlParser,
|
|
12
11
|
},
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "2.0.0-beta.4",
|
|
5
|
+
"packageManager": "pnpm@8.1.1",
|
|
6
6
|
"description": "",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"license": "MIT",
|
|
@@ -29,38 +29,39 @@
|
|
|
29
29
|
"eslint": "^8.30.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint/js": "^8.
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
34
|
-
"@typescript-eslint/parser": "^5.
|
|
35
|
-
"astro-eslint-parser": "^0.
|
|
36
|
-
"eslint-config-prettier": "^8.
|
|
37
|
-
"eslint-plugin-astro": "^0.
|
|
32
|
+
"@eslint/js": "^8.37.0",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
34
|
+
"@typescript-eslint/parser": "^5.57.1",
|
|
35
|
+
"astro-eslint-parser": "^0.13.2",
|
|
36
|
+
"eslint-config-prettier": "^8.8.0",
|
|
37
|
+
"eslint-plugin-astro": "^0.26.1",
|
|
38
38
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
39
39
|
"eslint-plugin-import": "^2.27.5",
|
|
40
|
-
"eslint-plugin-jsonc": "^2.
|
|
40
|
+
"eslint-plugin-jsonc": "^2.7.0",
|
|
41
41
|
"eslint-plugin-markdown": "^3.0.0",
|
|
42
42
|
"eslint-plugin-prettier": "^4.2.1",
|
|
43
43
|
"eslint-plugin-unicorn": "^46.0.0",
|
|
44
|
-
"eslint-plugin-vue": "^9.
|
|
44
|
+
"eslint-plugin-vue": "^9.10.0",
|
|
45
45
|
"eslint-plugin-yml": "^1.5.0",
|
|
46
46
|
"globals": "^13.20.0",
|
|
47
47
|
"jsonc-eslint-parser": "^2.2.0",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"local-pkg": "^0.4.3",
|
|
49
|
+
"prettier": "^2.8.7",
|
|
50
|
+
"vue-eslint-parser": "^9.1.1",
|
|
50
51
|
"yaml-eslint-parser": "^1.2.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@ntnyq/prettier-config": "^1.
|
|
54
|
-
"@types/node": "^18.15.
|
|
55
|
-
"bumpp": "^9.
|
|
56
|
-
"eslint": "^8.
|
|
57
|
-
"eslint-define-config": "^1.
|
|
54
|
+
"@ntnyq/prettier-config": "^1.6.1",
|
|
55
|
+
"@types/node": "^18.15.11",
|
|
56
|
+
"bumpp": "^9.1.0",
|
|
57
|
+
"eslint": "^8.37.0",
|
|
58
|
+
"eslint-define-config": "^1.17.0",
|
|
58
59
|
"husky": "^8.0.3",
|
|
59
60
|
"nano-staged": "^0.8.0",
|
|
60
|
-
"typescript": "5.0.
|
|
61
|
+
"typescript": "5.0.3"
|
|
61
62
|
},
|
|
62
63
|
"engines": {
|
|
63
|
-
"node": ">=14.
|
|
64
|
+
"node": ">=16.14.0"
|
|
64
65
|
},
|
|
65
66
|
"prettier": "@ntnyq/prettier-config",
|
|
66
67
|
"scripts": {
|