@ivanmaxlogiudice/eslint-config 0.1.10 → 1.0.0-beta.0
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/LICENSE +2 -2
- package/README.md +30 -16
- package/index.js +9 -414
- package/package.json +40 -22
- package/src/eslint-comments.js +17 -0
- package/src/js.js +350 -0
- package/src/jsonc.js +108 -0
- package/src/markdown.js +43 -0
- package/src/presets.js +63 -0
- package/src/shared.js +67 -0
- package/src/typescript.js +155 -0
- package/src/vue.js +197 -0
- package/src/yml.js +26 -0
package/src/js.js
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import globals from 'globals'
|
|
2
|
+
import jsConfig from '@eslint/js'
|
|
3
|
+
import standardConfig from 'eslint-config-standard'
|
|
4
|
+
import nPlugin from 'eslint-plugin-n'
|
|
5
|
+
import importPlugin from 'eslint-plugin-import'
|
|
6
|
+
import unusedImportsPlugin from 'eslint-plugin-unused-imports'
|
|
7
|
+
import unicornPlugin from 'eslint-plugin-unicorn'
|
|
8
|
+
import antfuPlugin from 'eslint-plugin-antfu'
|
|
9
|
+
import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests'
|
|
10
|
+
import { GLOB_MARKDOWN, GLOB_SRC, GLOB_SRC_EXT } from './shared.js'
|
|
11
|
+
|
|
12
|
+
export { importPlugin, unicornPlugin, antfuPlugin }
|
|
13
|
+
|
|
14
|
+
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
15
|
+
export const js = [
|
|
16
|
+
jsConfig.configs.recommended,
|
|
17
|
+
{
|
|
18
|
+
languageOptions: {
|
|
19
|
+
globals: {
|
|
20
|
+
...globals.browser,
|
|
21
|
+
...globals.es2021,
|
|
22
|
+
...globals.node,
|
|
23
|
+
},
|
|
24
|
+
sourceType: 'module',
|
|
25
|
+
},
|
|
26
|
+
plugins: {
|
|
27
|
+
standard: standardConfig,
|
|
28
|
+
n: nPlugin,
|
|
29
|
+
},
|
|
30
|
+
rules: {
|
|
31
|
+
// ...standardConfig,
|
|
32
|
+
|
|
33
|
+
'array-bracket-spacing': ['error', 'never'],
|
|
34
|
+
'array-callback-return': 'error',
|
|
35
|
+
'arrow-parens': ['error', 'as-needed', {
|
|
36
|
+
requireForBlockBody: true,
|
|
37
|
+
}],
|
|
38
|
+
'block-scoped-var': 'error',
|
|
39
|
+
'block-spacing': ['error', 'always'],
|
|
40
|
+
'brace-style': ['error', 'stroustrup', {
|
|
41
|
+
allowSingleLine: true,
|
|
42
|
+
}],
|
|
43
|
+
'consistent-return': 'error',
|
|
44
|
+
'comma-dangle': ['error', 'always-multiline'],
|
|
45
|
+
'comma-spacing': ['error', {
|
|
46
|
+
after: true,
|
|
47
|
+
before: false,
|
|
48
|
+
}],
|
|
49
|
+
'comma-style': ['error', 'last'],
|
|
50
|
+
'curly': ['error', 'multi-or-nest', 'consistent'],
|
|
51
|
+
'eqeqeq': ['error', 'smart'],
|
|
52
|
+
'func-call-spacing': ['error', 'never'],
|
|
53
|
+
'indent': ['error', 4, {
|
|
54
|
+
SwitchCase: 1,
|
|
55
|
+
outerIIFEBody: 1,
|
|
56
|
+
VariableDeclarator: 1,
|
|
57
|
+
}],
|
|
58
|
+
'key-spacing': ['error', {
|
|
59
|
+
afterColon: true,
|
|
60
|
+
beforeColon: false,
|
|
61
|
+
}],
|
|
62
|
+
'max-statements-per-line': ['error', {
|
|
63
|
+
max: 1,
|
|
64
|
+
}],
|
|
65
|
+
'object-curly-spacing': ['error', 'always'],
|
|
66
|
+
'object-shorthand': ['error', 'always', {
|
|
67
|
+
avoidQuotes: true,
|
|
68
|
+
ignoreConstructors: false,
|
|
69
|
+
}],
|
|
70
|
+
'operator-linebreak': ['error', 'before'],
|
|
71
|
+
'prefer-arrow-callback': ['error', {
|
|
72
|
+
allowNamedFunctions: false,
|
|
73
|
+
allowUnboundThis: true,
|
|
74
|
+
}],
|
|
75
|
+
'prefer-const': ['error', {
|
|
76
|
+
destructuring: 'all',
|
|
77
|
+
ignoreReadBeforeAssign: true,
|
|
78
|
+
}],
|
|
79
|
+
'prefer-exponentiation-operator': 'error',
|
|
80
|
+
'prefer-rest-params': 'error',
|
|
81
|
+
'prefer-spread': 'error',
|
|
82
|
+
'prefer-template': 'error',
|
|
83
|
+
'quote-props': ['error', 'consistent-as-needed'],
|
|
84
|
+
'quotes': ['error', 'single', {
|
|
85
|
+
avoidEscape: true,
|
|
86
|
+
}],
|
|
87
|
+
'semi': ['error', 'never'],
|
|
88
|
+
'sort-imports': ['error', {
|
|
89
|
+
allowSeparatedGroups: false,
|
|
90
|
+
ignoreCase: false,
|
|
91
|
+
ignoreDeclarationSort: true,
|
|
92
|
+
ignoreMemberSort: false,
|
|
93
|
+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
|
94
|
+
}],
|
|
95
|
+
'space-before-blocks': ['error', 'always'],
|
|
96
|
+
'space-before-function-paren': ['error', {
|
|
97
|
+
anonymous: 'always',
|
|
98
|
+
asyncArrow: 'always',
|
|
99
|
+
named: 'never',
|
|
100
|
+
}],
|
|
101
|
+
'spaced-comment': ['error', 'always', {
|
|
102
|
+
block: {
|
|
103
|
+
balanced: true,
|
|
104
|
+
exceptions: ['*'],
|
|
105
|
+
markers: ['!'],
|
|
106
|
+
},
|
|
107
|
+
line: {
|
|
108
|
+
exceptions: ['/', '#'],
|
|
109
|
+
markers: ['/'],
|
|
110
|
+
},
|
|
111
|
+
}],
|
|
112
|
+
'require-await': 'error',
|
|
113
|
+
'template-curly-spacing': 'error',
|
|
114
|
+
'vars-on-top': 'error',
|
|
115
|
+
|
|
116
|
+
// no-
|
|
117
|
+
'no-alert': 'warn',
|
|
118
|
+
'no-cond-assign': ['error', 'always'],
|
|
119
|
+
'no-console': ['error', {
|
|
120
|
+
allow: ['warn', 'error'],
|
|
121
|
+
}],
|
|
122
|
+
'no-constant-condition': 'warn',
|
|
123
|
+
'no-debugger': 'warn',
|
|
124
|
+
'no-duplicate-imports': 'error',
|
|
125
|
+
'no-empty': ['error', {
|
|
126
|
+
allowEmptyCatch: true,
|
|
127
|
+
}],
|
|
128
|
+
'no-invalid-this': 'error',
|
|
129
|
+
'no-lonely-if': 'error',
|
|
130
|
+
'no-multi-spaces': 'error',
|
|
131
|
+
'no-multi-str': 'error',
|
|
132
|
+
'no-return-assign': ['error', 'always'],
|
|
133
|
+
'no-return-await': 'warn',
|
|
134
|
+
'no-restricted-globals': ['error',
|
|
135
|
+
{ name: 'global', message: 'Use `globalThis` instead.' },
|
|
136
|
+
{ name: 'self', message: 'Use `globalThis` instead.' },
|
|
137
|
+
],
|
|
138
|
+
'no-restricted-properties': ['error',
|
|
139
|
+
{ property: '__proto__', message: 'Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.' },
|
|
140
|
+
{ property: '__defineGetter__', message: 'Use `Object.defineProperty` instead.' },
|
|
141
|
+
{ property: '__defineSetter__', message: 'Use `Object.defineProperty` instead.' },
|
|
142
|
+
{ property: '__lookupGetter__', message: 'Use `Object.getOwnPropertyDescriptor` instead.' },
|
|
143
|
+
{ property: '__lookupSetter__', message: 'Use `Object.getOwnPropertyDescriptor` instead.' },
|
|
144
|
+
],
|
|
145
|
+
'no-restricted-syntax': ['error',
|
|
146
|
+
'DebuggerStatement',
|
|
147
|
+
'LabeledStatement',
|
|
148
|
+
'WithStatement',
|
|
149
|
+
],
|
|
150
|
+
'no-param-reassign': 'error',
|
|
151
|
+
'no-unused-expressions': ['error', {
|
|
152
|
+
allowShortCircuit: true,
|
|
153
|
+
allowTernary: true,
|
|
154
|
+
allowTaggedTemplates: true,
|
|
155
|
+
}],
|
|
156
|
+
'no-useless-escape': 'error',
|
|
157
|
+
'no-use-before-define': ['error', {
|
|
158
|
+
classes: false,
|
|
159
|
+
functions: false,
|
|
160
|
+
variables: true,
|
|
161
|
+
}],
|
|
162
|
+
'no-var': 'error',
|
|
163
|
+
'no-void': 'error',
|
|
164
|
+
|
|
165
|
+
// node
|
|
166
|
+
'n/prefer-global/buffer': ['error', 'never'],
|
|
167
|
+
'n/no-callback-literal': 'off',
|
|
168
|
+
|
|
169
|
+
// off
|
|
170
|
+
'camelcase': 'off',
|
|
171
|
+
'complexity': 'off',
|
|
172
|
+
'generator-star-spacing': 'off',
|
|
173
|
+
'no-unused-vars': 'off', // handled by unused-imports/no-unused-vars
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
files: ['**/scripts/*', '**/cli.*'],
|
|
178
|
+
rules: {
|
|
179
|
+
'no-console': 'off',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
plugins: {
|
|
184
|
+
noOnlyTest: noOnlyTestsPlugin,
|
|
185
|
+
},
|
|
186
|
+
files: ['**/*.{test,spec}.{js?(x),ts}'],
|
|
187
|
+
rules: {
|
|
188
|
+
'no-unused-expressions': 'off',
|
|
189
|
+
'no-only-tests/no-only-tests': 'error',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
195
|
+
export const jsx = [
|
|
196
|
+
{
|
|
197
|
+
files: ['**/*.jsx'],
|
|
198
|
+
languageOptions: {
|
|
199
|
+
parserOptions: {
|
|
200
|
+
ecmaFeatures: {
|
|
201
|
+
jsx: true,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
209
|
+
export const imports = [
|
|
210
|
+
{
|
|
211
|
+
plugins: {
|
|
212
|
+
'import': importPlugin,
|
|
213
|
+
'unused-imports': unusedImportsPlugin,
|
|
214
|
+
'antfu': antfuPlugin,
|
|
215
|
+
},
|
|
216
|
+
settings: {
|
|
217
|
+
'import/resolver': {
|
|
218
|
+
node: { extensions: ['.js', '.mjs', '.ts', '.mts', '.d.ts'] },
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
rules: {
|
|
222
|
+
'import/first': 'error',
|
|
223
|
+
'import/newline-after-import': ['error', {
|
|
224
|
+
considerComments: true,
|
|
225
|
+
count: 1,
|
|
226
|
+
}],
|
|
227
|
+
'import/no-default-export': 'error',
|
|
228
|
+
'import/no-duplicates': 'error',
|
|
229
|
+
'import/no-mutable-exports': 'error',
|
|
230
|
+
'import/order': ['error', {
|
|
231
|
+
groups: [
|
|
232
|
+
'builtin',
|
|
233
|
+
'external',
|
|
234
|
+
'internal',
|
|
235
|
+
'parent',
|
|
236
|
+
'sibling',
|
|
237
|
+
'index',
|
|
238
|
+
'object',
|
|
239
|
+
'type',
|
|
240
|
+
],
|
|
241
|
+
pathGroups: [{
|
|
242
|
+
group: 'internal',
|
|
243
|
+
pattern: '@/**',
|
|
244
|
+
}],
|
|
245
|
+
pathGroupsExcludedImportTypes: ['type'],
|
|
246
|
+
}],
|
|
247
|
+
|
|
248
|
+
// off
|
|
249
|
+
'import/namespace': 'off',
|
|
250
|
+
'import/no-absolute-path': 'off',
|
|
251
|
+
'import/no-named-as-default': 'off',
|
|
252
|
+
'import/no-named-as-default-member': 'off',
|
|
253
|
+
'import/no-unresolved': 'off',
|
|
254
|
+
|
|
255
|
+
// unused-imports
|
|
256
|
+
'unused-imports/no-unused-imports': 'error',
|
|
257
|
+
'unused-imports/no-unused-vars': ['warn', {
|
|
258
|
+
vars: 'all',
|
|
259
|
+
varsIgnorePattern: '^_',
|
|
260
|
+
args: 'after-used',
|
|
261
|
+
argsIgnorePattern: '^_',
|
|
262
|
+
}],
|
|
263
|
+
|
|
264
|
+
'antfu/if-newline': 'error',
|
|
265
|
+
'antfu/import-dedupe': 'error',
|
|
266
|
+
'antfu/prefer-inline-type-import': 'error',
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
files: [
|
|
271
|
+
`**/*config*.${GLOB_SRC_EXT}`,
|
|
272
|
+
`**/views/${GLOB_SRC}`,
|
|
273
|
+
`**/pages/${GLOB_SRC}`,
|
|
274
|
+
'**/{index,vite,esbuild,rollup,webpack,rspack}.ts',
|
|
275
|
+
'**/*.d.ts',
|
|
276
|
+
`${GLOB_MARKDOWN}/**`,
|
|
277
|
+
],
|
|
278
|
+
plugins: {
|
|
279
|
+
import: importPlugin,
|
|
280
|
+
},
|
|
281
|
+
rules: {
|
|
282
|
+
'import/no-default-export': 'off',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
]
|
|
286
|
+
|
|
287
|
+
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
288
|
+
export const unicorn = [
|
|
289
|
+
{
|
|
290
|
+
plugins: {
|
|
291
|
+
unicorn: unicornPlugin,
|
|
292
|
+
},
|
|
293
|
+
rules: {
|
|
294
|
+
'unicorn/better-regex': 'error',
|
|
295
|
+
'unicorn/custom-error-definition': 'error',
|
|
296
|
+
'unicorn/error-message': 'error',
|
|
297
|
+
'unicorn/escape-case': 'error',
|
|
298
|
+
'unicorn/explicit-length-check': 'error',
|
|
299
|
+
'unicorn/import-index': 'error',
|
|
300
|
+
'unicorn/new-for-builtins': 'error',
|
|
301
|
+
'unicorn/no-array-callback-reference': 'error',
|
|
302
|
+
'unicorn/no-array-method-this-argument': 'error',
|
|
303
|
+
'unicorn/no-array-push-push': 'error',
|
|
304
|
+
'unicorn/no-console-spaces': 'error',
|
|
305
|
+
'unicorn/no-for-loop': 'error',
|
|
306
|
+
'unicorn/no-hex-escape': 'error',
|
|
307
|
+
'unicorn/no-instanceof-array': 'error',
|
|
308
|
+
'unicorn/no-invalid-remove-event-listener': 'error',
|
|
309
|
+
'unicorn/no-lonely-if': 'error',
|
|
310
|
+
'unicorn/no-new-array': 'error',
|
|
311
|
+
'unicorn/no-new-buffer': 'error',
|
|
312
|
+
'unicorn/no-unnecessary-await': 'error',
|
|
313
|
+
'unicorn/no-unsafe-regex': 'off',
|
|
314
|
+
'unicorn/number-literal-case': 'error',
|
|
315
|
+
'unicorn/prefer-add-event-listener': 'error',
|
|
316
|
+
'unicorn/prefer-array-find': 'error',
|
|
317
|
+
'unicorn/prefer-array-flat-map': 'error',
|
|
318
|
+
'unicorn/prefer-array-index-of': 'error',
|
|
319
|
+
'unicorn/prefer-array-some': 'error',
|
|
320
|
+
'unicorn/prefer-at': 'error',
|
|
321
|
+
'unicorn/prefer-blob-reading-methods': 'error',
|
|
322
|
+
'unicorn/prefer-date-now': 'error',
|
|
323
|
+
'unicorn/prefer-dom-node-append': 'error',
|
|
324
|
+
'unicorn/prefer-dom-node-dataset': 'error',
|
|
325
|
+
'unicorn/prefer-dom-node-remove': 'error',
|
|
326
|
+
'unicorn/prefer-dom-node-text-content': 'error',
|
|
327
|
+
'unicorn/prefer-includes': 'error',
|
|
328
|
+
'unicorn/prefer-keyboard-event-key': 'error',
|
|
329
|
+
'unicorn/prefer-logical-operator-over-ternary': 'error',
|
|
330
|
+
'unicorn/prefer-math-trunc': 'error',
|
|
331
|
+
'unicorn/prefer-modern-dom-apis': 'error',
|
|
332
|
+
'unicorn/prefer-negative-index': 'error',
|
|
333
|
+
'unicorn/prefer-node-protocol': 'error',
|
|
334
|
+
'unicorn/prefer-number-properties': 'error',
|
|
335
|
+
'unicorn/prefer-optional-catch-binding': 'error',
|
|
336
|
+
'unicorn/prefer-prototype-methods': 'error',
|
|
337
|
+
'unicorn/prefer-query-selector': 'error',
|
|
338
|
+
'unicorn/prefer-reflect-apply': 'error',
|
|
339
|
+
'unicorn/prefer-string-replace-all': 'error',
|
|
340
|
+
'unicorn/prefer-string-slice': 'error',
|
|
341
|
+
'unicorn/prefer-string-starts-ends-with': 'error',
|
|
342
|
+
'unicorn/prefer-string-trim-start-end': 'error',
|
|
343
|
+
'unicorn/prefer-text-content': 'error',
|
|
344
|
+
'unicorn/prefer-type-error': 'error',
|
|
345
|
+
'unicorn/switch-case-braces': 'error',
|
|
346
|
+
'unicorn/throw-new-error': 'error',
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
]
|
|
350
|
+
|
package/src/jsonc.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import jsoncPlugin, { configs } from 'eslint-plugin-jsonc'
|
|
2
|
+
import jsoncParser from 'jsonc-eslint-parser'
|
|
3
|
+
import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from './shared.js'
|
|
4
|
+
|
|
5
|
+
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
6
|
+
export const jsonc = [
|
|
7
|
+
{
|
|
8
|
+
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
9
|
+
plugins: {
|
|
10
|
+
jsonc: jsoncPlugin,
|
|
11
|
+
},
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parser: jsoncParser,
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
...configs['recommended-with-jsonc'].rules,
|
|
17
|
+
|
|
18
|
+
'jsonc/array-bracket-spacing': ['error', 'never'],
|
|
19
|
+
'jsonc/comma-dangle': 'error',
|
|
20
|
+
'jsonc/comma-style': ['error', 'last'],
|
|
21
|
+
'jsonc/indent': ['error', 4],
|
|
22
|
+
'jsonc/key-spacing': ['error', {
|
|
23
|
+
beforeColon: false,
|
|
24
|
+
afterColon: true,
|
|
25
|
+
}],
|
|
26
|
+
'jsonc/no-octal-escape': 'error',
|
|
27
|
+
'jsonc/object-curly-newline': ['error', {
|
|
28
|
+
multiline: true,
|
|
29
|
+
consistent: true,
|
|
30
|
+
}],
|
|
31
|
+
'jsonc/object-curly-spacing': ['error', 'always'],
|
|
32
|
+
'jsonc/object-property-newline': ['error', {
|
|
33
|
+
allowMultiplePropertiesPerLine: true,
|
|
34
|
+
}],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
40
|
+
export const pkgOrder = [
|
|
41
|
+
{
|
|
42
|
+
files: ['**/package.json'],
|
|
43
|
+
rules: {
|
|
44
|
+
'jsonc/sort-keys': [
|
|
45
|
+
'error',
|
|
46
|
+
{
|
|
47
|
+
pathPattern: '^$',
|
|
48
|
+
order: [
|
|
49
|
+
'name',
|
|
50
|
+
'version',
|
|
51
|
+
'private',
|
|
52
|
+
'packageManager',
|
|
53
|
+
'description',
|
|
54
|
+
'type',
|
|
55
|
+
'keywords',
|
|
56
|
+
'license',
|
|
57
|
+
'homepage',
|
|
58
|
+
'bugs',
|
|
59
|
+
'repository',
|
|
60
|
+
'author',
|
|
61
|
+
'contributors',
|
|
62
|
+
'funding',
|
|
63
|
+
'sideEffects',
|
|
64
|
+
'files',
|
|
65
|
+
'main',
|
|
66
|
+
'module',
|
|
67
|
+
'types',
|
|
68
|
+
'exports',
|
|
69
|
+
'typesVersions',
|
|
70
|
+
'unpkg',
|
|
71
|
+
'jsdelivr',
|
|
72
|
+
'browser',
|
|
73
|
+
'bin',
|
|
74
|
+
'man',
|
|
75
|
+
'directories',
|
|
76
|
+
'publishConfig',
|
|
77
|
+
'scripts',
|
|
78
|
+
'peerDependencies',
|
|
79
|
+
'peerDependenciesMeta',
|
|
80
|
+
'optionalDependencies',
|
|
81
|
+
'dependencies',
|
|
82
|
+
'devDependencies',
|
|
83
|
+
'engines',
|
|
84
|
+
'config',
|
|
85
|
+
'overrides',
|
|
86
|
+
'pnpm',
|
|
87
|
+
'husky',
|
|
88
|
+
'simple-git-hooks',
|
|
89
|
+
'lint-staged',
|
|
90
|
+
'eslintConfig',
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies$',
|
|
95
|
+
order: { type: 'asc' },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
pathPattern: '^exports.*$',
|
|
99
|
+
order: [
|
|
100
|
+
'types',
|
|
101
|
+
'require',
|
|
102
|
+
'import',
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
]
|
package/src/markdown.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import markdownPlugin from 'eslint-plugin-markdown'
|
|
2
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
3
|
+
|
|
4
|
+
import { GLOB_MARKDOWN, GLOB_SRC, GLOB_VUE } from './shared.js'
|
|
5
|
+
|
|
6
|
+
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
7
|
+
export const markdown = [
|
|
8
|
+
{
|
|
9
|
+
files: [GLOB_MARKDOWN],
|
|
10
|
+
plugins: {
|
|
11
|
+
markdown: markdownPlugin,
|
|
12
|
+
},
|
|
13
|
+
processor: 'markdown/markdown',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
|
|
17
|
+
languageOptions: {
|
|
18
|
+
parserOptions: {
|
|
19
|
+
ecmaFeatures: {
|
|
20
|
+
impliedStrict: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
plugins: {
|
|
25
|
+
'@typescript-eslint': tsPlugin,
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
...markdownPlugin.configs.recommended.overrides[1].rules,
|
|
29
|
+
|
|
30
|
+
'@typescript-eslint/no-redeclare': 'off',
|
|
31
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
32
|
+
'@typescript-eslint/no-use-before-define': 'off',
|
|
33
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
34
|
+
|
|
35
|
+
'no-alert': 'off',
|
|
36
|
+
'no-console': 'off',
|
|
37
|
+
'no-restricted-imports': 'off',
|
|
38
|
+
'no-undef': 'off',
|
|
39
|
+
'no-unused-expressions': 'off',
|
|
40
|
+
'no-unused-vars': 'off',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
]
|
package/src/presets.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { eslintComments } from './eslint-comments.js'
|
|
4
|
+
import { imports, js, jsx, unicorn } from './js.js'
|
|
5
|
+
import { jsonc, pkgOrder } from './jsonc.js'
|
|
6
|
+
import { typescript } from './typescript.js'
|
|
7
|
+
import { markdown } from './markdown.js'
|
|
8
|
+
import { yml } from './yml.js'
|
|
9
|
+
import { vue } from './vue.js'
|
|
10
|
+
|
|
11
|
+
import { GLOB_EXCLUDE } from './shared.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef { import('eslint-define-config').FlatESLintConfigItem } FlatESLintConfigItem
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @type {FlatESLintConfigItem[]} */
|
|
18
|
+
export const basic = [
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
{ ignores: GLOB_EXCLUDE },
|
|
21
|
+
|
|
22
|
+
...js,
|
|
23
|
+
...jsx,
|
|
24
|
+
...typescript,
|
|
25
|
+
...imports,
|
|
26
|
+
...unicorn,
|
|
27
|
+
...jsonc,
|
|
28
|
+
...pkgOrder,
|
|
29
|
+
...yml,
|
|
30
|
+
...eslintComments,
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
/** @type {FlatESLintConfigItem[]} */
|
|
34
|
+
export const all = [
|
|
35
|
+
...vue,
|
|
36
|
+
...basic,
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
/** @type {(config?: FlatESLintConfigItem | FlatESLintConfigItem[], enables?: Partial<{
|
|
40
|
+
* vue: boolean
|
|
41
|
+
* markdown: boolean
|
|
42
|
+
* }>) => FlatESLintConfigItem[]} */
|
|
43
|
+
export function config(
|
|
44
|
+
config = [],
|
|
45
|
+
{
|
|
46
|
+
vue: enableVue = true,
|
|
47
|
+
markdown: enableMarkdown = true,
|
|
48
|
+
} = {},
|
|
49
|
+
) {
|
|
50
|
+
const configs = [...basic]
|
|
51
|
+
|
|
52
|
+
if (enableVue !== false)
|
|
53
|
+
configs.push(...vue)
|
|
54
|
+
|
|
55
|
+
if (enableMarkdown !== false)
|
|
56
|
+
configs.push(...markdown)
|
|
57
|
+
|
|
58
|
+
if (Object.keys(config).length > 0)
|
|
59
|
+
configs.push(...(Array.isArray(config) ? config : [config]))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return configs
|
|
63
|
+
}
|
package/src/shared.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)'
|
|
4
|
+
export const GLOB_SRC = '**/*.?([cm])[jt]s?(x)'
|
|
5
|
+
|
|
6
|
+
export const GLOB_JS = '**/*.?([cm])js'
|
|
7
|
+
export const GLOB_JSX = '**/*.?([cm])jsx'
|
|
8
|
+
|
|
9
|
+
export const GLOB_TS = '**/*.?([cm])ts'
|
|
10
|
+
export const GLOB_TSX = '**/*.?([cm])tsx'
|
|
11
|
+
|
|
12
|
+
export const GLOB_STYLE = '**/*.{c,le,sc}ss'
|
|
13
|
+
export const GLOB_CSS = '**/*.css'
|
|
14
|
+
export const GLOB_LESS = '**/*.less'
|
|
15
|
+
export const GLOB_SCSS = '**/*.scss'
|
|
16
|
+
|
|
17
|
+
export const GLOB_JSON = '**/*.json'
|
|
18
|
+
export const GLOB_JSON5 = '**/*.json5'
|
|
19
|
+
export const GLOB_JSONC = '**/*.jsonc'
|
|
20
|
+
|
|
21
|
+
export const GLOB_MARKDOWN = '**/*.md'
|
|
22
|
+
export const GLOB_VUE = '**/*.vue'
|
|
23
|
+
export const GLOB_YAML = '**/*.y?(a)ml'
|
|
24
|
+
export const GLOB_HTML = '**/*.htm?(l)'
|
|
25
|
+
|
|
26
|
+
export const GLOB_ALL_SRC = /** @type {const} */ ([
|
|
27
|
+
GLOB_SRC,
|
|
28
|
+
GLOB_STYLE,
|
|
29
|
+
GLOB_JSON,
|
|
30
|
+
GLOB_JSON5,
|
|
31
|
+
GLOB_MARKDOWN,
|
|
32
|
+
GLOB_VUE,
|
|
33
|
+
GLOB_YAML,
|
|
34
|
+
GLOB_HTML,
|
|
35
|
+
])
|
|
36
|
+
|
|
37
|
+
export const GLOB_NODE_MODULES = /** @type {const} */ ('**/node_modules')
|
|
38
|
+
export const GLOB_DIST = /** @type {const} */ ('**/dist')
|
|
39
|
+
export const GLOB_LOCKFILE = /** @type {const} */ ([
|
|
40
|
+
'**/package-lock.json',
|
|
41
|
+
'**/yarn.lock',
|
|
42
|
+
'**/pnpm-lock.yaml',
|
|
43
|
+
])
|
|
44
|
+
export const GLOB_EXCLUDE = /** @type {const} */ ([
|
|
45
|
+
GLOB_NODE_MODULES,
|
|
46
|
+
GLOB_DIST,
|
|
47
|
+
...GLOB_LOCKFILE,
|
|
48
|
+
|
|
49
|
+
'**/output',
|
|
50
|
+
'**/coverage',
|
|
51
|
+
'**/temp',
|
|
52
|
+
'**/fixtures',
|
|
53
|
+
'**/.vitepress/cache',
|
|
54
|
+
'**/.nuxt',
|
|
55
|
+
'**/.vercel',
|
|
56
|
+
'**/.changeset',
|
|
57
|
+
'**/.idea',
|
|
58
|
+
'**/.output',
|
|
59
|
+
'**/.vite-inspect',
|
|
60
|
+
|
|
61
|
+
'**/CHANGELOG*.md',
|
|
62
|
+
'**/*.min.*',
|
|
63
|
+
'**/LICENSE*',
|
|
64
|
+
'**/__snapshots__',
|
|
65
|
+
'**/auto-import.d.ts',
|
|
66
|
+
'**/components.d.ts',
|
|
67
|
+
])
|