@curev/eslint-config 0.2.1 → 0.3.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/.eslintignore +1 -0
- package/.github/workflows/release.yml +37 -0
- package/.vscode/settings.json +36 -0
- package/CHANGELOG.md +740 -0
- package/README.md +70 -0
- package/eslint.config.ts +3 -0
- package/fixtures/input/css.css +10 -0
- package/fixtures/input/html.html +17 -0
- package/fixtures/input/javascript.js +69 -0
- package/fixtures/input/jsx.jsx +27 -0
- package/fixtures/input/markdown.md +34 -0
- package/fixtures/input/svelte.svelte +8 -0
- package/fixtures/input/toml.toml +23 -0
- package/fixtures/input/tsx.tsx +32 -0
- package/fixtures/input/typescript.ts +84 -0
- package/fixtures/input/vue-ts.vue +35 -0
- package/fixtures/input/vue.vue +27 -0
- package/fixtures/output/all/javascript.js +72 -0
- package/fixtures/output/all/jsx.jsx +26 -0
- package/fixtures/output/all/markdown.md +33 -0
- package/fixtures/output/all/svelte.svelte +8 -0
- package/fixtures/output/all/toml.toml +23 -0
- package/fixtures/output/all/tsx.tsx +32 -0
- package/fixtures/output/all/typescript.ts +83 -0
- package/fixtures/output/all/vue-ts.vue +35 -0
- package/fixtures/output/all/vue.vue +24 -0
- package/fixtures/output/js/javascript.js +72 -0
- package/fixtures/output/js/markdown.md +33 -0
- package/fixtures/output/js/toml.toml +23 -0
- package/fixtures/output/no-markdown-with-formatters/javascript.js +72 -0
- package/fixtures/output/no-markdown-with-formatters/jsx.jsx +24 -0
- package/fixtures/output/no-markdown-with-formatters/markdown.md +33 -0
- package/fixtures/output/no-markdown-with-formatters/toml.toml +23 -0
- package/fixtures/output/no-markdown-with-formatters/tsx.tsx +23 -0
- package/fixtures/output/no-markdown-with-formatters/typescript.ts +83 -0
- package/fixtures/output/no-style/javascript.js +72 -0
- package/fixtures/output/no-style/jsx.jsx +21 -0
- package/fixtures/output/no-style/toml.toml +23 -0
- package/fixtures/output/no-style/typescript.ts +80 -0
- package/fixtures/output/no-style/vue-ts.vue +35 -0
- package/fixtures/output/no-style/vue.vue +24 -0
- package/fixtures/output/tab-double-quotes/javascript.js +72 -0
- package/fixtures/output/tab-double-quotes/jsx.jsx +26 -0
- package/fixtures/output/tab-double-quotes/markdown.md +33 -0
- package/fixtures/output/tab-double-quotes/toml.toml +23 -0
- package/fixtures/output/tab-double-quotes/tsx.tsx +32 -0
- package/fixtures/output/tab-double-quotes/typescript.ts +83 -0
- package/fixtures/output/tab-double-quotes/vue-ts.vue +35 -0
- package/fixtures/output/tab-double-quotes/vue.vue +24 -0
- package/fixtures/output/ts-override/javascript.js +72 -0
- package/fixtures/output/ts-override/jsx.jsx +26 -0
- package/fixtures/output/ts-override/markdown.md +33 -0
- package/fixtures/output/ts-override/toml.toml +23 -0
- package/fixtures/output/ts-override/tsx.tsx +32 -0
- package/fixtures/output/ts-override/typescript.ts +83 -0
- package/fixtures/output/ts-override/vue-ts.vue +35 -0
- package/fixtures/output/ts-override/vue.vue +24 -0
- package/fixtures/output/with-formatters/css.css +11 -0
- package/fixtures/output/with-formatters/html.html +28 -0
- package/fixtures/output/with-formatters/javascript.js +72 -0
- package/fixtures/output/with-formatters/jsx.jsx +26 -0
- package/fixtures/output/with-formatters/markdown.md +34 -0
- package/fixtures/output/with-formatters/toml.toml +23 -0
- package/fixtures/output/with-formatters/tsx.tsx +32 -0
- package/fixtures/output/with-formatters/typescript.ts +83 -0
- package/fixtures/output/with-formatters/vue-ts.vue +38 -0
- package/fixtures/output/with-formatters/vue.vue +24 -0
- package/package.json +130 -12
- package/src/configs/comments.ts +19 -0
- package/src/configs/formatters.ts +187 -0
- package/src/configs/ignores.ts +10 -0
- package/src/configs/imports.ts +46 -0
- package/src/configs/index.ts +21 -0
- package/src/configs/javascript.ts +277 -0
- package/src/configs/jsdoc.ts +41 -0
- package/src/configs/jsonc.ts +86 -0
- package/src/configs/markdown.ts +110 -0
- package/src/configs/node.ts +24 -0
- package/src/configs/perfectionist.ts +18 -0
- package/src/configs/react.ts +111 -0
- package/src/configs/sort.ts +223 -0
- package/src/configs/stylistic.ts +52 -0
- package/src/configs/svelte.ts +107 -0
- package/src/configs/test.ts +54 -0
- package/src/configs/toml.ts +72 -0
- package/src/configs/typescript.ts +171 -0
- package/src/configs/unicorn.ts +41 -0
- package/src/configs/unocss.ts +43 -0
- package/src/configs/vue.ts +170 -0
- package/src/configs/yaml.ts +72 -0
- package/src/factory.ts +255 -0
- package/src/globs.ts +81 -0
- package/src/index.ts +9 -0
- package/src/plugins.ts +10 -0
- package/src/stub.d.ts +3 -0
- package/src/types.ts +364 -0
- package/src/utils.ts +76 -0
- package/src/vender/prettier-types.ts +136 -0
- package/test/cli.spec.ts +90 -0
- package/test/fixtures.test.ts +127 -0
- package/tsconfig.json +17 -0
- package/tsup.config.ts +8 -0
- package/index.js +0 -5
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { interopDefault } from "../utils";
|
|
2
|
+
import type { FlatConfigItem, OptionsFiles, OptionsIsInEditor, OptionsOverrides } from "../types";
|
|
3
|
+
import { GLOB_TESTS } from "../globs";
|
|
4
|
+
|
|
5
|
+
export async function test(
|
|
6
|
+
options: OptionsFiles & OptionsIsInEditor & OptionsOverrides = {}
|
|
7
|
+
): Promise<FlatConfigItem[]> {
|
|
8
|
+
const {
|
|
9
|
+
files = GLOB_TESTS,
|
|
10
|
+
isInEditor = false,
|
|
11
|
+
overrides = {}
|
|
12
|
+
} = options;
|
|
13
|
+
|
|
14
|
+
const [
|
|
15
|
+
pluginVitest,
|
|
16
|
+
pluginNoOnlyTests
|
|
17
|
+
] = await Promise.all([
|
|
18
|
+
interopDefault(import("eslint-plugin-vitest")),
|
|
19
|
+
// @ts-expect-error missing types
|
|
20
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
21
|
+
] as const);
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
name: "curev:test:setup",
|
|
26
|
+
plugins: {
|
|
27
|
+
test: {
|
|
28
|
+
...pluginVitest,
|
|
29
|
+
rules: {
|
|
30
|
+
...pluginVitest.rules,
|
|
31
|
+
// extend `test/no-only-tests` rule
|
|
32
|
+
...pluginNoOnlyTests.rules
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
files,
|
|
39
|
+
name: "curev:test:rules",
|
|
40
|
+
rules: {
|
|
41
|
+
"node/prefer-global/process": "off",
|
|
42
|
+
|
|
43
|
+
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
44
|
+
"test/no-identical-title": "error",
|
|
45
|
+
"test/no-import-node-test": "error",
|
|
46
|
+
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
47
|
+
"test/prefer-hooks-in-order": "error",
|
|
48
|
+
"test/prefer-lowercase-title": "error",
|
|
49
|
+
|
|
50
|
+
...overrides
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { FlatConfigItem, OptionsFiles, OptionsOverrides, OptionsStylistic } from "../types";
|
|
2
|
+
import { GLOB_TOML } from "../globs";
|
|
3
|
+
import { interopDefault } from "../utils";
|
|
4
|
+
|
|
5
|
+
export async function toml(
|
|
6
|
+
options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}
|
|
7
|
+
): Promise<FlatConfigItem[]> {
|
|
8
|
+
const {
|
|
9
|
+
files = [GLOB_TOML],
|
|
10
|
+
overrides = {},
|
|
11
|
+
stylistic = true
|
|
12
|
+
} = options;
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
indent = 2
|
|
16
|
+
} = typeof stylistic === "boolean" ? {} : stylistic;
|
|
17
|
+
|
|
18
|
+
const [
|
|
19
|
+
pluginToml,
|
|
20
|
+
parserToml
|
|
21
|
+
] = await Promise.all([
|
|
22
|
+
interopDefault(import("eslint-plugin-toml")),
|
|
23
|
+
interopDefault(import("toml-eslint-parser"))
|
|
24
|
+
] as const);
|
|
25
|
+
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
name: "curev:toml:setup",
|
|
29
|
+
plugins: {
|
|
30
|
+
toml: pluginToml
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
files,
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parser: parserToml
|
|
37
|
+
},
|
|
38
|
+
name: "curev:toml:rules",
|
|
39
|
+
rules: {
|
|
40
|
+
"style/spaced-comment": "off",
|
|
41
|
+
|
|
42
|
+
"toml/comma-style": "error",
|
|
43
|
+
"toml/keys-order": "error",
|
|
44
|
+
"toml/no-space-dots": "error",
|
|
45
|
+
"toml/no-unreadable-number-separator": "error",
|
|
46
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
47
|
+
"toml/precision-of-integer": "error",
|
|
48
|
+
"toml/tables-order": "error",
|
|
49
|
+
|
|
50
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
51
|
+
|
|
52
|
+
...stylistic
|
|
53
|
+
? {
|
|
54
|
+
"toml/array-bracket-newline": "error",
|
|
55
|
+
"toml/array-bracket-spacing": "error",
|
|
56
|
+
"toml/array-element-newline": "error",
|
|
57
|
+
"toml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
58
|
+
"toml/inline-table-curly-spacing": "error",
|
|
59
|
+
"toml/key-spacing": "error",
|
|
60
|
+
"toml/padding-line-between-pairs": "error",
|
|
61
|
+
"toml/padding-line-between-tables": "error",
|
|
62
|
+
"toml/quoted-keys": "error",
|
|
63
|
+
"toml/spaced-comment": "error",
|
|
64
|
+
"toml/table-bracket-spacing": "error"
|
|
65
|
+
}
|
|
66
|
+
: {},
|
|
67
|
+
|
|
68
|
+
...overrides
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { GLOB_SRC, GLOB_TS, GLOB_TSX } from "../globs";
|
|
3
|
+
import type { FlatConfigItem, OptionsComponentExts, OptionsFiles, OptionsOverrides, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from "../types";
|
|
4
|
+
import { pluginAntfu } from "../plugins";
|
|
5
|
+
import { interopDefault, renameRules, toArray } from "../utils";
|
|
6
|
+
|
|
7
|
+
export async function typescript(
|
|
8
|
+
options: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions = {}
|
|
9
|
+
): Promise<FlatConfigItem[]> {
|
|
10
|
+
const {
|
|
11
|
+
componentExts = [],
|
|
12
|
+
overrides = {},
|
|
13
|
+
parserOptions = {}
|
|
14
|
+
} = options;
|
|
15
|
+
|
|
16
|
+
const files = options.files ?? [
|
|
17
|
+
GLOB_SRC,
|
|
18
|
+
...componentExts.map(ext => `**/*.${ext}`)
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
22
|
+
const tsconfigPath = options?.tsconfigPath
|
|
23
|
+
? toArray(options.tsconfigPath)
|
|
24
|
+
: undefined;
|
|
25
|
+
const isTypeAware = !!tsconfigPath;
|
|
26
|
+
|
|
27
|
+
const typeAwareRules: FlatConfigItem["rules"] = {
|
|
28
|
+
"dot-notation": "off",
|
|
29
|
+
"no-implied-eval": "off",
|
|
30
|
+
"no-throw-literal": "off",
|
|
31
|
+
"ts/await-thenable": "error",
|
|
32
|
+
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
33
|
+
"ts/no-floating-promises": "error",
|
|
34
|
+
"ts/no-for-in-array": "error",
|
|
35
|
+
"ts/no-implied-eval": "error",
|
|
36
|
+
"ts/no-misused-promises": "error",
|
|
37
|
+
"ts/no-throw-literal": "error",
|
|
38
|
+
"ts/no-unnecessary-type-assertion": "error",
|
|
39
|
+
"ts/no-unsafe-argument": "error",
|
|
40
|
+
"ts/no-unsafe-assignment": "error",
|
|
41
|
+
"ts/no-unsafe-call": "error",
|
|
42
|
+
"ts/no-unsafe-member-access": "error",
|
|
43
|
+
"ts/no-unsafe-return": "error",
|
|
44
|
+
"ts/restrict-plus-operands": "error",
|
|
45
|
+
"ts/restrict-template-expressions": "error",
|
|
46
|
+
"ts/unbound-method": "error"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const [
|
|
50
|
+
pluginTs,
|
|
51
|
+
parserTs
|
|
52
|
+
] = await Promise.all([
|
|
53
|
+
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
54
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
55
|
+
] as const);
|
|
56
|
+
|
|
57
|
+
function makeParser(typeAware: boolean, files: string[], ignores?: string[]): FlatConfigItem {
|
|
58
|
+
return {
|
|
59
|
+
files,
|
|
60
|
+
...ignores ? { ignores } : {},
|
|
61
|
+
languageOptions: {
|
|
62
|
+
parser: parserTs,
|
|
63
|
+
parserOptions: {
|
|
64
|
+
extraFileExtensions: componentExts.map(ext => `.${ext}`),
|
|
65
|
+
sourceType: "module",
|
|
66
|
+
...typeAware
|
|
67
|
+
? {
|
|
68
|
+
project: tsconfigPath,
|
|
69
|
+
tsconfigRootDir: process.cwd()
|
|
70
|
+
}
|
|
71
|
+
: {},
|
|
72
|
+
...parserOptions as any
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
name: `curev:typescript:${typeAware ? "type-aware-parser" : "parser"}`
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
82
|
+
name: "curev:typescript:setup",
|
|
83
|
+
plugins: {
|
|
84
|
+
curev: pluginAntfu,
|
|
85
|
+
ts: pluginTs as any
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
89
|
+
...isTypeAware
|
|
90
|
+
? [
|
|
91
|
+
makeParser(true, filesTypeAware),
|
|
92
|
+
makeParser(false, files, filesTypeAware)
|
|
93
|
+
]
|
|
94
|
+
: [makeParser(false, files)],
|
|
95
|
+
{
|
|
96
|
+
files,
|
|
97
|
+
name: "curev:typescript:rules",
|
|
98
|
+
rules: {
|
|
99
|
+
...renameRules(
|
|
100
|
+
pluginTs.configs["eslint-recommended"].overrides![0].rules!,
|
|
101
|
+
"@typescript-eslint/",
|
|
102
|
+
"ts/"
|
|
103
|
+
),
|
|
104
|
+
...renameRules(
|
|
105
|
+
pluginTs.configs.strict.rules!,
|
|
106
|
+
"@typescript-eslint/",
|
|
107
|
+
"ts/"
|
|
108
|
+
),
|
|
109
|
+
"no-dupe-class-members": "off",
|
|
110
|
+
"no-loss-of-precision": "off",
|
|
111
|
+
"no-redeclare": "off",
|
|
112
|
+
"no-use-before-define": "off",
|
|
113
|
+
"no-useless-constructor": "off",
|
|
114
|
+
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
115
|
+
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
116
|
+
"ts/consistent-type-definitions": ["error", "interface"],
|
|
117
|
+
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
|
|
118
|
+
"ts/no-dupe-class-members": "error",
|
|
119
|
+
"ts/no-dynamic-delete": "off",
|
|
120
|
+
"ts/no-explicit-any": "off",
|
|
121
|
+
"ts/no-extraneous-class": "off",
|
|
122
|
+
"ts/no-import-type-side-effects": "error",
|
|
123
|
+
"ts/no-invalid-void-type": "off",
|
|
124
|
+
"ts/no-loss-of-precision": "error",
|
|
125
|
+
"ts/no-non-null-assertion": "off",
|
|
126
|
+
"ts/no-redeclare": "error",
|
|
127
|
+
"ts/no-require-imports": "error",
|
|
128
|
+
"ts/no-unused-vars": "off",
|
|
129
|
+
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
130
|
+
"ts/no-useless-constructor": "off",
|
|
131
|
+
"ts/prefer-ts-expect-error": "error",
|
|
132
|
+
"ts/triple-slash-reference": "off",
|
|
133
|
+
"ts/unified-signatures": "off",
|
|
134
|
+
...overrides
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
files: filesTypeAware,
|
|
139
|
+
name: "curev:typescript:rules-type-aware",
|
|
140
|
+
rules: {
|
|
141
|
+
...tsconfigPath ? typeAwareRules : {},
|
|
142
|
+
...overrides
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
files: ["**/*.d.ts"],
|
|
147
|
+
name: "curev:typescript:dts-overrides",
|
|
148
|
+
rules: {
|
|
149
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
150
|
+
"import/no-duplicates": "off",
|
|
151
|
+
"no-restricted-syntax": "off",
|
|
152
|
+
"unused-imports/no-unused-vars": "off"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
files: ["**/*.{test,spec}.ts?(x)"],
|
|
157
|
+
name: "curev:typescript:tests-overrides",
|
|
158
|
+
rules: {
|
|
159
|
+
"no-unused-expressions": "off"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
164
|
+
name: "curev:typescript:javascript-overrides",
|
|
165
|
+
rules: {
|
|
166
|
+
"ts/no-require-imports": "off",
|
|
167
|
+
"ts/no-var-requires": "off"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
];
|
|
171
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FlatConfigItem } from "../types";
|
|
2
|
+
import { pluginUnicorn } from "../plugins";
|
|
3
|
+
|
|
4
|
+
export async function unicorn(): Promise<FlatConfigItem[]> {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
name: "curev:unicorn",
|
|
8
|
+
plugins: {
|
|
9
|
+
unicorn: pluginUnicorn
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
// Pass error message when throwing errors
|
|
13
|
+
"unicorn/error-message": "error",
|
|
14
|
+
// Uppercase regex escapes
|
|
15
|
+
"unicorn/escape-case": "error",
|
|
16
|
+
// Array.isArray instead of instanceof
|
|
17
|
+
"unicorn/no-instanceof-array": "error",
|
|
18
|
+
// Ban `new Array` as `Array` constructor's params are ambiguous
|
|
19
|
+
"unicorn/no-new-array": "error",
|
|
20
|
+
// Prevent deprecated `new Buffer()`
|
|
21
|
+
"unicorn/no-new-buffer": "error",
|
|
22
|
+
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
|
|
23
|
+
"unicorn/number-literal-case": "error",
|
|
24
|
+
// textContent instead of innerText
|
|
25
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
26
|
+
// includes over indexOf when checking for existence
|
|
27
|
+
"unicorn/prefer-includes": "error",
|
|
28
|
+
// Prefer using the node: protocol
|
|
29
|
+
"unicorn/prefer-node-protocol": "error",
|
|
30
|
+
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
31
|
+
"unicorn/prefer-number-properties": "error",
|
|
32
|
+
// String methods startsWith/endsWith instead of more complicated stuff
|
|
33
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
34
|
+
// Enforce throwing type error when throwing error while checking typeof
|
|
35
|
+
"unicorn/prefer-type-error": "error",
|
|
36
|
+
// Use new when throwing error
|
|
37
|
+
"unicorn/throw-new-error": "error"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ensurePackages, interopDefault } from "../utils";
|
|
2
|
+
import type { FlatConfigItem, OptionsUnoCSS } from "../types";
|
|
3
|
+
|
|
4
|
+
export async function unocss(
|
|
5
|
+
options: OptionsUnoCSS = {}
|
|
6
|
+
): Promise<FlatConfigItem[]> {
|
|
7
|
+
const {
|
|
8
|
+
attributify = true,
|
|
9
|
+
strict = false
|
|
10
|
+
} = options;
|
|
11
|
+
|
|
12
|
+
await ensurePackages([
|
|
13
|
+
"@unocss/eslint-plugin"
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const [
|
|
17
|
+
pluginUnoCSS
|
|
18
|
+
] = await Promise.all([
|
|
19
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
20
|
+
] as const);
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: "curev:unocss",
|
|
25
|
+
plugins: {
|
|
26
|
+
unocss: pluginUnoCSS
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
"unocss/order": "warn",
|
|
30
|
+
...attributify
|
|
31
|
+
? {
|
|
32
|
+
"unocss/order-attributify": "warn"
|
|
33
|
+
}
|
|
34
|
+
: {},
|
|
35
|
+
...strict
|
|
36
|
+
? {
|
|
37
|
+
"unocss/blocklist": "error"
|
|
38
|
+
}
|
|
39
|
+
: {}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { mergeProcessors } from "eslint-merge-processors";
|
|
2
|
+
import { interopDefault } from "../utils";
|
|
3
|
+
import type { FlatConfigItem, OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, OptionsVue } from "../types";
|
|
4
|
+
import { GLOB_VUE } from "../globs";
|
|
5
|
+
|
|
6
|
+
export async function vue(
|
|
7
|
+
options: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {}
|
|
8
|
+
): Promise<FlatConfigItem[]> {
|
|
9
|
+
const {
|
|
10
|
+
files = [GLOB_VUE],
|
|
11
|
+
overrides = {},
|
|
12
|
+
stylistic = true,
|
|
13
|
+
vueVersion = 3
|
|
14
|
+
} = options;
|
|
15
|
+
|
|
16
|
+
const sfcBlocks = options.sfcBlocks === true
|
|
17
|
+
? {}
|
|
18
|
+
: options.sfcBlocks ?? {};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
indent = 2
|
|
22
|
+
} = typeof stylistic === "boolean" ? {} : stylistic;
|
|
23
|
+
|
|
24
|
+
const [
|
|
25
|
+
pluginVue,
|
|
26
|
+
parserVue,
|
|
27
|
+
processorVueBlocks
|
|
28
|
+
] = await Promise.all([
|
|
29
|
+
// @ts-expect-error missing types
|
|
30
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
31
|
+
interopDefault(import("vue-eslint-parser")),
|
|
32
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
33
|
+
] as const);
|
|
34
|
+
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
name: "curev:vue:setup",
|
|
38
|
+
plugins: {
|
|
39
|
+
vue: pluginVue
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
files,
|
|
44
|
+
languageOptions: {
|
|
45
|
+
parser: parserVue,
|
|
46
|
+
parserOptions: {
|
|
47
|
+
ecmaFeatures: {
|
|
48
|
+
jsx: true
|
|
49
|
+
},
|
|
50
|
+
extraFileExtensions: [".vue"],
|
|
51
|
+
parser: options.typescript
|
|
52
|
+
? await interopDefault(import("@typescript-eslint/parser")) as any
|
|
53
|
+
: null,
|
|
54
|
+
sourceType: "module"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
name: "curev:vue:rules",
|
|
58
|
+
processor: sfcBlocks === false
|
|
59
|
+
? pluginVue.processors[".vue"]
|
|
60
|
+
: mergeProcessors([
|
|
61
|
+
pluginVue.processors[".vue"],
|
|
62
|
+
processorVueBlocks({
|
|
63
|
+
...sfcBlocks,
|
|
64
|
+
blocks: {
|
|
65
|
+
styles: true,
|
|
66
|
+
...sfcBlocks.blocks
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
]),
|
|
70
|
+
rules: {
|
|
71
|
+
...pluginVue.configs.base.rules as any,
|
|
72
|
+
|
|
73
|
+
...vueVersion === 2
|
|
74
|
+
? {
|
|
75
|
+
...pluginVue.configs.essential.rules as any,
|
|
76
|
+
...pluginVue.configs["strongly-recommended"].rules as any,
|
|
77
|
+
...pluginVue.configs.recommended.rules as any
|
|
78
|
+
}
|
|
79
|
+
: {
|
|
80
|
+
...pluginVue.configs["vue3-essential"].rules as any,
|
|
81
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules as any,
|
|
82
|
+
...pluginVue.configs["vue3-recommended"].rules as any
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
"node/prefer-global/process": "off",
|
|
86
|
+
"vue/block-order": ["error", {
|
|
87
|
+
order: ["script", "template", "style"]
|
|
88
|
+
}],
|
|
89
|
+
|
|
90
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
91
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
92
|
+
// this is deprecated
|
|
93
|
+
"vue/component-tags-order": "off",
|
|
94
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
95
|
+
"vue/define-macros-order": ["error", {
|
|
96
|
+
order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
|
|
97
|
+
}],
|
|
98
|
+
"vue/dot-location": ["error", "property"],
|
|
99
|
+
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
100
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
101
|
+
"vue/html-indent": ["error", indent],
|
|
102
|
+
"vue/html-quotes": ["error", "double"],
|
|
103
|
+
"vue/max-attributes-per-line": "off",
|
|
104
|
+
"vue/multi-word-component-names": "off",
|
|
105
|
+
"vue/no-dupe-keys": "off",
|
|
106
|
+
"vue/no-empty-pattern": "error",
|
|
107
|
+
"vue/no-irregular-whitespace": "error",
|
|
108
|
+
"vue/no-loss-of-precision": "error",
|
|
109
|
+
"vue/no-restricted-syntax": [
|
|
110
|
+
"error",
|
|
111
|
+
"DebuggerStatement",
|
|
112
|
+
"LabeledStatement",
|
|
113
|
+
"WithStatement"
|
|
114
|
+
],
|
|
115
|
+
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
116
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
117
|
+
"vue/no-sparse-arrays": "error",
|
|
118
|
+
"vue/no-unused-refs": "error",
|
|
119
|
+
"vue/no-useless-v-bind": "error",
|
|
120
|
+
"vue/no-v-html": "off",
|
|
121
|
+
"vue/object-shorthand": [
|
|
122
|
+
"error",
|
|
123
|
+
"always",
|
|
124
|
+
{
|
|
125
|
+
avoidQuotes: true,
|
|
126
|
+
ignoreConstructors: false
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"vue/prefer-separate-static-class": "error",
|
|
130
|
+
"vue/prefer-template": "error",
|
|
131
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
132
|
+
"vue/require-default-prop": "off",
|
|
133
|
+
"vue/require-prop-types": "off",
|
|
134
|
+
"vue/space-infix-ops": "error",
|
|
135
|
+
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
136
|
+
|
|
137
|
+
...stylistic
|
|
138
|
+
? {
|
|
139
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
|
140
|
+
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
141
|
+
"vue/block-spacing": ["error", "always"],
|
|
142
|
+
"vue/block-tag-newline": ["error", {
|
|
143
|
+
multiline: "always",
|
|
144
|
+
singleline: "always"
|
|
145
|
+
}],
|
|
146
|
+
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
|
|
147
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
|
148
|
+
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
149
|
+
"vue/comma-style": ["error", "last"],
|
|
150
|
+
"vue/html-comment-content-spacing": ["error", "always", {
|
|
151
|
+
exceptions: ["-"]
|
|
152
|
+
}],
|
|
153
|
+
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
154
|
+
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
155
|
+
"vue/object-curly-newline": "off",
|
|
156
|
+
"vue/object-curly-spacing": ["error", "always"],
|
|
157
|
+
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
158
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
159
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
160
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
161
|
+
"vue/space-in-parens": ["error", "never"],
|
|
162
|
+
"vue/template-curly-spacing": "error"
|
|
163
|
+
}
|
|
164
|
+
: {},
|
|
165
|
+
|
|
166
|
+
...overrides
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
];
|
|
170
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { FlatConfigItem, OptionsFiles, OptionsOverrides, OptionsStylistic } from "../types";
|
|
2
|
+
import { GLOB_YAML } from "../globs";
|
|
3
|
+
import { interopDefault } from "../utils";
|
|
4
|
+
|
|
5
|
+
export async function yaml(
|
|
6
|
+
options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}
|
|
7
|
+
): Promise<FlatConfigItem[]> {
|
|
8
|
+
const {
|
|
9
|
+
files = [GLOB_YAML],
|
|
10
|
+
overrides = {},
|
|
11
|
+
stylistic = true
|
|
12
|
+
} = options;
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
indent = 2,
|
|
16
|
+
quotes = "single"
|
|
17
|
+
} = typeof stylistic === "boolean" ? {} : stylistic;
|
|
18
|
+
|
|
19
|
+
const [
|
|
20
|
+
pluginYaml,
|
|
21
|
+
parserYaml
|
|
22
|
+
] = await Promise.all([
|
|
23
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
24
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
25
|
+
] as const);
|
|
26
|
+
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
name: "curev:yaml:setup",
|
|
30
|
+
plugins: {
|
|
31
|
+
yaml: pluginYaml
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
files,
|
|
36
|
+
languageOptions: {
|
|
37
|
+
parser: parserYaml
|
|
38
|
+
},
|
|
39
|
+
name: "curev:yaml:rules",
|
|
40
|
+
rules: {
|
|
41
|
+
"style/spaced-comment": "off",
|
|
42
|
+
|
|
43
|
+
"yaml/block-mapping": "error",
|
|
44
|
+
"yaml/block-sequence": "error",
|
|
45
|
+
"yaml/no-empty-key": "error",
|
|
46
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
47
|
+
"yaml/no-irregular-whitespace": "error",
|
|
48
|
+
"yaml/plain-scalar": "error",
|
|
49
|
+
|
|
50
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
51
|
+
|
|
52
|
+
...stylistic
|
|
53
|
+
? {
|
|
54
|
+
"yaml/block-mapping-question-indicator-newline": "error",
|
|
55
|
+
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
56
|
+
"yaml/flow-mapping-curly-newline": "error",
|
|
57
|
+
"yaml/flow-mapping-curly-spacing": "error",
|
|
58
|
+
"yaml/flow-sequence-bracket-newline": "error",
|
|
59
|
+
"yaml/flow-sequence-bracket-spacing": "error",
|
|
60
|
+
"yaml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
61
|
+
"yaml/key-spacing": "error",
|
|
62
|
+
"yaml/no-tab-indent": "error",
|
|
63
|
+
"yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
|
|
64
|
+
"yaml/spaced-comment": "error"
|
|
65
|
+
}
|
|
66
|
+
: {},
|
|
67
|
+
|
|
68
|
+
...overrides
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|