@sxzz/eslint-config 3.0.0-beta.1 → 3.0.0-beta.3
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/package.json +1 -1
- package/src/js.js +2 -0
- package/src/jsonc.js +1 -1
- package/src/markdown.js +6 -2
- package/src/presets.js +20 -15
- package/src/shared.js +2 -0
- package/src/typescript.js +2 -0
- package/src/vue.js +18 -3
package/package.json
CHANGED
package/src/js.js
CHANGED
|
@@ -3,6 +3,8 @@ import jsConfig from '@eslint/js'
|
|
|
3
3
|
import importPlugin from 'eslint-plugin-import'
|
|
4
4
|
import unicornPlugin from 'eslint-plugin-unicorn'
|
|
5
5
|
|
|
6
|
+
export { importPlugin, unicornPlugin }
|
|
7
|
+
|
|
6
8
|
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
7
9
|
export const js = [
|
|
8
10
|
jsConfig.configs.recommended,
|
package/src/jsonc.js
CHANGED
|
@@ -5,7 +5,7 @@ import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from './shared.js'
|
|
|
5
5
|
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
6
6
|
export const jsonc = [
|
|
7
7
|
{
|
|
8
|
-
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC
|
|
8
|
+
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
9
9
|
plugins: {
|
|
10
10
|
jsonc: jsoncPlugin,
|
|
11
11
|
},
|
package/src/markdown.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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').FlatESLintConfigItem[]} */
|
|
5
6
|
export const markdown = [
|
|
@@ -11,7 +12,7 @@ export const markdown = [
|
|
|
11
12
|
processor: 'markdown/markdown',
|
|
12
13
|
},
|
|
13
14
|
{
|
|
14
|
-
files: [
|
|
15
|
+
files: [`**/*.md/${GLOB_SRC}`, `**/*.md/${GLOB_VUE}`],
|
|
15
16
|
languageOptions: {
|
|
16
17
|
parserOptions: {
|
|
17
18
|
ecmaFeatures: {
|
|
@@ -19,6 +20,9 @@ export const markdown = [
|
|
|
19
20
|
},
|
|
20
21
|
},
|
|
21
22
|
},
|
|
23
|
+
plugins: {
|
|
24
|
+
'@typescript-eslint': tsPlugin,
|
|
25
|
+
},
|
|
22
26
|
rules: {
|
|
23
27
|
...markdownPlugin.configs.recommended.overrides[1].rules,
|
|
24
28
|
|
package/src/presets.js
CHANGED
|
@@ -16,10 +16,8 @@ import { yml } from './yml.js'
|
|
|
16
16
|
|
|
17
17
|
/** @type {FlatESLintConfigItem[]} */
|
|
18
18
|
export const basic = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
ignores: GLOB_EXCLUDE,
|
|
22
|
-
},
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
{ ignores: GLOB_EXCLUDE },
|
|
23
21
|
...js,
|
|
24
22
|
...jsx,
|
|
25
23
|
...typescript,
|
|
@@ -28,31 +26,38 @@ export const basic = [
|
|
|
28
26
|
...jsonc,
|
|
29
27
|
...pkgOrder,
|
|
30
28
|
...yml,
|
|
31
|
-
...markdown,
|
|
32
29
|
...eslintComments,
|
|
33
30
|
]
|
|
34
31
|
|
|
35
32
|
/** @type { FlatESLintConfigItem[] } */
|
|
36
|
-
export const all = [...
|
|
33
|
+
export const all = [...vue, ...basic, ...prettier]
|
|
37
34
|
|
|
38
|
-
/** @type {(
|
|
35
|
+
/** @type {(config?: FlatESLintConfigItem | FlatESLintConfigItem[], enables?: Partial<{
|
|
39
36
|
* vue: boolean
|
|
40
37
|
* prettier: boolean
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
* markdown: boolean
|
|
39
|
+
* }>) => FlatESLintConfigItem[]} */
|
|
40
|
+
export function sxzz(
|
|
41
|
+
config = [],
|
|
42
|
+
{
|
|
43
|
+
vue: enableVue = true,
|
|
44
|
+
prettier: enablePrettier = true,
|
|
45
|
+
markdown: enableMarkdown = true,
|
|
46
|
+
} = {}
|
|
47
|
+
) {
|
|
48
|
+
const configs = []
|
|
49
|
+
configs.push(...basic)
|
|
48
50
|
if (enableVue !== false) {
|
|
49
51
|
configs.push(...vue)
|
|
50
52
|
}
|
|
53
|
+
if (enableMarkdown !== false) {
|
|
54
|
+
configs.push(...markdown)
|
|
55
|
+
}
|
|
51
56
|
if (enablePrettier !== false) {
|
|
52
57
|
configs.push(...prettier)
|
|
53
58
|
}
|
|
54
59
|
if (Object.keys(config).length > 0) {
|
|
55
|
-
configs.push(config)
|
|
60
|
+
configs.push(...(Array.isArray(config) ? config : [config]))
|
|
56
61
|
}
|
|
57
62
|
return configs
|
|
58
63
|
}
|
package/src/shared.js
CHANGED
package/src/typescript.js
CHANGED
|
@@ -2,6 +2,8 @@ import tsParser from '@typescript-eslint/parser'
|
|
|
2
2
|
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
3
3
|
import { GLOB_TS, GLOB_TSX } from './shared.js'
|
|
4
4
|
|
|
5
|
+
export { tsParser, tsPlugin }
|
|
6
|
+
|
|
5
7
|
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
6
8
|
export const typescript = [
|
|
7
9
|
{
|
package/src/vue.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { getPackageInfoSync } from 'local-pkg'
|
|
2
2
|
import vueParser from 'vue-eslint-parser'
|
|
3
3
|
import vuePlugin from 'eslint-plugin-vue'
|
|
4
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
4
5
|
import { typescript } from './typescript.js'
|
|
6
|
+
import { GLOB_VUE } from './shared.js'
|
|
7
|
+
|
|
8
|
+
export { vueParser, vuePlugin }
|
|
5
9
|
|
|
6
10
|
export function getVueVersion() {
|
|
7
11
|
const pkg = getPackageInfoSync('vue', { paths: [process.cwd()] })
|
|
@@ -14,6 +18,7 @@ export function getVueVersion() {
|
|
|
14
18
|
}
|
|
15
19
|
return 3
|
|
16
20
|
}
|
|
21
|
+
const isVue3 = getVueVersion() === 3
|
|
17
22
|
|
|
18
23
|
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
19
24
|
export const reactivityTransform = [
|
|
@@ -29,6 +34,9 @@ export const reactivityTransform = [
|
|
|
29
34
|
$customRef: 'readonly',
|
|
30
35
|
},
|
|
31
36
|
},
|
|
37
|
+
plugins: {
|
|
38
|
+
vue: vuePlugin,
|
|
39
|
+
},
|
|
32
40
|
rules: {
|
|
33
41
|
'vue/no-setup-props-destructure': 'off',
|
|
34
42
|
},
|
|
@@ -75,10 +83,10 @@ const vue2Rules = {
|
|
|
75
83
|
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
76
84
|
export const vue = [
|
|
77
85
|
{
|
|
78
|
-
files: [
|
|
86
|
+
files: [GLOB_VUE],
|
|
79
87
|
plugins: {
|
|
80
88
|
vue: vuePlugin,
|
|
81
|
-
|
|
89
|
+
'@typescript-eslint': tsPlugin,
|
|
82
90
|
},
|
|
83
91
|
languageOptions: {
|
|
84
92
|
parser: vueParser,
|
|
@@ -93,9 +101,16 @@ export const vue = [
|
|
|
93
101
|
},
|
|
94
102
|
processor: vuePlugin.processors['.vue'],
|
|
95
103
|
rules: {
|
|
96
|
-
...(getVueVersion() === 3 ? vue3Rules : vue2Rules),
|
|
97
104
|
...typescript[0].rules,
|
|
98
105
|
},
|
|
99
106
|
},
|
|
107
|
+
{
|
|
108
|
+
plugins: {
|
|
109
|
+
vue: vuePlugin,
|
|
110
|
+
},
|
|
111
|
+
rules: {
|
|
112
|
+
...(isVue3 ? vue3Rules : vue2Rules),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
100
115
|
...reactivityTransform,
|
|
101
116
|
]
|