@eienjs/eslint-config 1.2.2 → 1.4.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/dist/cli/constants.js +74 -0
- package/dist/cli/constants_generated.js +13 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +3 -268
- package/dist/cli/run.js +77 -0
- package/dist/cli/stages/update_eslint_files.js +39 -0
- package/dist/cli/stages/update_package_json.js +46 -0
- package/dist/cli/stages/update_vscode_settings.js +30 -0
- package/dist/cli/utils.js +23 -0
- package/dist/configs/adonisjs.d.ts +6 -0
- package/dist/configs/adonisjs.js +115 -0
- package/dist/configs/astro.d.ts +6 -0
- package/dist/configs/astro.js +52 -0
- package/dist/configs/command.d.ts +6 -0
- package/dist/configs/command.js +12 -0
- package/dist/configs/comments.d.ts +6 -0
- package/dist/configs/comments.js +19 -0
- package/dist/configs/disables.d.ts +6 -0
- package/dist/configs/disables.js +85 -0
- package/dist/configs/formatters.d.ts +6 -0
- package/dist/configs/formatters.js +134 -0
- package/dist/configs/ignores.d.ts +6 -0
- package/dist/configs/ignores.js +12 -0
- package/dist/configs/imports.d.ts +6 -0
- package/dist/configs/imports.js +28 -0
- package/dist/configs/index.d.ts +25 -95
- package/dist/configs/index.js +25 -1
- package/dist/configs/javascript.d.ts +6 -0
- package/dist/configs/javascript.js +289 -0
- package/dist/configs/jsdoc.d.ts +6 -0
- package/dist/configs/jsdoc.js +34 -0
- package/dist/configs/jsonc.d.ts +6 -0
- package/dist/configs/jsonc.js +71 -0
- package/dist/configs/markdown.d.ts +6 -0
- package/dist/configs/markdown.js +67 -0
- package/dist/configs/node.d.ts +6 -0
- package/dist/configs/node.js +22 -0
- package/dist/configs/nuxt.d.ts +6 -0
- package/dist/configs/nuxt.js +137 -0
- package/dist/configs/perfectionist.d.ts +12 -0
- package/dist/configs/perfectionist.js +56 -0
- package/dist/configs/pnpm.d.ts +6 -0
- package/dist/configs/pnpm.js +33 -0
- package/dist/configs/regexp.d.ts +6 -0
- package/dist/configs/regexp.js +21 -0
- package/dist/configs/sort.d.ts +18 -0
- package/dist/configs/sort.js +239 -0
- package/dist/configs/stylistic.d.ts +8 -0
- package/dist/configs/stylistic.js +76 -0
- package/dist/configs/test.d.ts +6 -0
- package/dist/configs/test.js +42 -0
- package/dist/configs/toml.d.ts +6 -0
- package/dist/configs/toml.js +45 -0
- package/dist/configs/typescript.d.ts +6 -0
- package/dist/configs/typescript.js +237 -0
- package/dist/configs/unicorn.d.ts +6 -0
- package/dist/configs/unicorn.js +42 -0
- package/dist/configs/vue.d.ts +6 -0
- package/dist/configs/vue.js +206 -0
- package/dist/configs/yaml.d.ts +6 -0
- package/dist/configs/yaml.js +83 -0
- package/dist/factory.d.ts +17 -0
- package/dist/factory.js +161 -0
- package/dist/globs.d.ts +32 -0
- package/dist/globs.js +89 -0
- package/dist/index.d.ts +6 -86
- package/dist/index.js +3 -133
- package/dist/package.js +5 -0
- package/dist/plugins.js +9 -0
- package/dist/{types-ClRJcxpY.d.ts → typegen.d.ts} +446 -747
- package/dist/types.d.ts +426 -0
- package/dist/utils.d.ts +42 -0
- package/dist/utils.js +62 -0
- package/dist/vendored/prettier_types.d.ts +121 -0
- package/package.json +45 -33
- package/dist/configs-D_4UWxl6.js +0 -2192
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GLOB_TOML } from "../globs.js";
|
|
2
|
+
import { interopDefault } from "../utils.js";
|
|
3
|
+
|
|
4
|
+
//#region src/configs/toml.ts
|
|
5
|
+
async function toml(options = {}) {
|
|
6
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
7
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
8
|
+
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
9
|
+
return [{
|
|
10
|
+
name: "eienjs/toml/setup",
|
|
11
|
+
plugins: { toml: pluginToml }
|
|
12
|
+
}, {
|
|
13
|
+
files,
|
|
14
|
+
languageOptions: { parser: parserToml },
|
|
15
|
+
name: "eienjs/toml/rules",
|
|
16
|
+
rules: {
|
|
17
|
+
"@stylistic/spaced-comment": "off",
|
|
18
|
+
"toml/comma-style": "error",
|
|
19
|
+
"toml/keys-order": "error",
|
|
20
|
+
"toml/no-space-dots": "error",
|
|
21
|
+
"toml/no-unreadable-number-separator": "error",
|
|
22
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
23
|
+
"toml/precision-of-integer": "error",
|
|
24
|
+
"toml/tables-order": "error",
|
|
25
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
26
|
+
...stylistic ? {
|
|
27
|
+
"toml/array-bracket-newline": "error",
|
|
28
|
+
"toml/array-bracket-spacing": "error",
|
|
29
|
+
"toml/array-element-newline": "error",
|
|
30
|
+
"toml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
31
|
+
"toml/inline-table-curly-spacing": "error",
|
|
32
|
+
"toml/key-spacing": "error",
|
|
33
|
+
"toml/padding-line-between-pairs": "error",
|
|
34
|
+
"toml/padding-line-between-tables": "error",
|
|
35
|
+
"toml/quoted-keys": "error",
|
|
36
|
+
"toml/spaced-comment": "error",
|
|
37
|
+
"toml/table-bracket-spacing": "error"
|
|
38
|
+
} : {},
|
|
39
|
+
...overrides
|
|
40
|
+
}
|
|
41
|
+
}];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { toml };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OptionsComponentExts, OptionsFiles, OptionsOverrides, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescriptWithErasableSyntaxOnly, TypedFlatConfigItem } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/typescript.d.ts
|
|
4
|
+
declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsTypescriptWithErasableSyntaxOnly & OptionsStylistic): Promise<TypedFlatConfigItem[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { typescript };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { GLOB_ASTRO_TS, GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from "../globs.js";
|
|
2
|
+
import { ensurePackages, interopDefault } from "../utils.js";
|
|
3
|
+
import { pluginAntfu } from "../plugins.js";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
|
|
6
|
+
//#region src/configs/typescript.ts
|
|
7
|
+
async function typescript(options = {}) {
|
|
8
|
+
const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, stylistic = true, erasableSyntaxOnly = false } = options;
|
|
9
|
+
const files = options.files ?? [
|
|
10
|
+
GLOB_TS,
|
|
11
|
+
GLOB_TSX,
|
|
12
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
13
|
+
];
|
|
14
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
15
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
|
|
16
|
+
const tsconfigPath = options.tsconfigPath ?? void 0;
|
|
17
|
+
const isTypeAware = Boolean(tsconfigPath);
|
|
18
|
+
const isErasableSyntaxOnly = Boolean(erasableSyntaxOnly);
|
|
19
|
+
const typeAwareRules = {
|
|
20
|
+
"dot-notation": "off",
|
|
21
|
+
"no-implied-eval": "off",
|
|
22
|
+
"@typescript-eslint/await-thenable": "error",
|
|
23
|
+
"@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
24
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
|
|
25
|
+
"@typescript-eslint/explicit-member-accessibility": "error",
|
|
26
|
+
"@typescript-eslint/explicit-module-boundary-types": "error",
|
|
27
|
+
"@typescript-eslint/naming-convention": [
|
|
28
|
+
"error",
|
|
29
|
+
{
|
|
30
|
+
format: ["camelCase", "UPPER_CASE"],
|
|
31
|
+
leadingUnderscore: "allowSingleOrDouble",
|
|
32
|
+
modifiers: ["const"],
|
|
33
|
+
selector: "variable",
|
|
34
|
+
trailingUnderscore: "allowSingleOrDouble",
|
|
35
|
+
types: ["string", "number"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
format: null,
|
|
39
|
+
leadingUnderscore: "allowSingleOrDouble",
|
|
40
|
+
selector: "objectLiteralProperty",
|
|
41
|
+
trailingUnderscore: "allowSingleOrDouble"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
format: ["PascalCase"],
|
|
45
|
+
leadingUnderscore: "allowSingleOrDouble",
|
|
46
|
+
selector: "typeLike",
|
|
47
|
+
trailingUnderscore: "allowSingleOrDouble"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
format: null,
|
|
51
|
+
modifiers: ["destructured"],
|
|
52
|
+
selector: "variable"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
format: null,
|
|
56
|
+
selector: "typeProperty"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
format: ["PascalCase"],
|
|
60
|
+
selector: "class"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
custom: {
|
|
64
|
+
match: false,
|
|
65
|
+
regex: "^I[A-Z]"
|
|
66
|
+
},
|
|
67
|
+
format: ["PascalCase"],
|
|
68
|
+
selector: "interface"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
selector: "variable",
|
|
72
|
+
format: [
|
|
73
|
+
"camelCase",
|
|
74
|
+
"UPPER_CASE",
|
|
75
|
+
"PascalCase"
|
|
76
|
+
],
|
|
77
|
+
leadingUnderscore: "allow"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
81
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
82
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
83
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
84
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
85
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
86
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
87
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
88
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
89
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
90
|
+
"@typescript-eslint/prefer-nullish-coalescing": ["error", { ignorePrimitives: { string: true } }],
|
|
91
|
+
"@typescript-eslint/prefer-optional-chain": "error",
|
|
92
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
93
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
94
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
95
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
96
|
+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
97
|
+
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }],
|
|
98
|
+
"@typescript-eslint/no-unused-vars": ["error", {
|
|
99
|
+
"args": "all",
|
|
100
|
+
"argsIgnorePattern": "^_",
|
|
101
|
+
"caughtErrors": "all",
|
|
102
|
+
"caughtErrorsIgnorePattern": "^_",
|
|
103
|
+
"destructuredArrayIgnorePattern": "^_",
|
|
104
|
+
"varsIgnorePattern": "^_",
|
|
105
|
+
"ignoreRestSiblings": true
|
|
106
|
+
}]
|
|
107
|
+
};
|
|
108
|
+
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
109
|
+
function makeParser(typeAware, files$1, ignores) {
|
|
110
|
+
return {
|
|
111
|
+
files: files$1,
|
|
112
|
+
...ignores ? { ignores } : {},
|
|
113
|
+
languageOptions: {
|
|
114
|
+
parser: parserTs,
|
|
115
|
+
parserOptions: {
|
|
116
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
117
|
+
sourceType: "module",
|
|
118
|
+
...typeAware ? {
|
|
119
|
+
projectService: {
|
|
120
|
+
allowDefaultProject: ["./*.js"],
|
|
121
|
+
defaultProject: tsconfigPath
|
|
122
|
+
},
|
|
123
|
+
tsconfigRootDir: process.cwd()
|
|
124
|
+
} : {},
|
|
125
|
+
...parserOptions
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
name: `eienjs/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const rules = [{
|
|
132
|
+
name: "eienjs/typescript/setup",
|
|
133
|
+
plugins: {
|
|
134
|
+
"antfu": pluginAntfu,
|
|
135
|
+
"@typescript-eslint": pluginTs
|
|
136
|
+
}
|
|
137
|
+
}];
|
|
138
|
+
if (isTypeAware) rules.push(makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware));
|
|
139
|
+
else rules.push(makeParser(false, files));
|
|
140
|
+
rules.push({
|
|
141
|
+
files,
|
|
142
|
+
name: "eienjs/typescript/rules",
|
|
143
|
+
rules: {
|
|
144
|
+
...pluginTs.configs["eslint-recommended"].overrides?.[0].rules,
|
|
145
|
+
...pluginTs.configs.strict.rules,
|
|
146
|
+
...stylistic ? pluginTs.configs.stylistic.rules : {},
|
|
147
|
+
"no-dupe-class-members": "off",
|
|
148
|
+
"no-redeclare": "off",
|
|
149
|
+
"no-use-before-define": "off",
|
|
150
|
+
"no-useless-constructor": "off",
|
|
151
|
+
"@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
|
|
152
|
+
"@typescript-eslint/consistent-type-assertions": "error",
|
|
153
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
154
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
155
|
+
disallowTypeAnnotations: false,
|
|
156
|
+
fixStyle: "separate-type-imports",
|
|
157
|
+
prefer: "type-imports"
|
|
158
|
+
}],
|
|
159
|
+
"@typescript-eslint/default-param-last": "error",
|
|
160
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
161
|
+
"@typescript-eslint/no-dupe-class-members": "error",
|
|
162
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
163
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
164
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
165
|
+
"@typescript-eslint/no-invalid-void-type": "off",
|
|
166
|
+
"@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
|
|
167
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
168
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
169
|
+
allowShortCircuit: true,
|
|
170
|
+
allowTaggedTemplates: true,
|
|
171
|
+
allowTernary: true
|
|
172
|
+
}],
|
|
173
|
+
"@typescript-eslint/no-unused-vars": ["error", {
|
|
174
|
+
"args": "all",
|
|
175
|
+
"argsIgnorePattern": "^_",
|
|
176
|
+
"caughtErrors": "all",
|
|
177
|
+
"caughtErrorsIgnorePattern": "^_",
|
|
178
|
+
"destructuredArrayIgnorePattern": "^_",
|
|
179
|
+
"varsIgnorePattern": "^_",
|
|
180
|
+
"ignoreRestSiblings": true
|
|
181
|
+
}],
|
|
182
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
|
183
|
+
classes: false,
|
|
184
|
+
functions: false,
|
|
185
|
+
variables: true
|
|
186
|
+
}],
|
|
187
|
+
"@typescript-eslint/no-useless-constructor": "off",
|
|
188
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
189
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
190
|
+
"@typescript-eslint/unified-signatures": "off",
|
|
191
|
+
...overrides
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
if (isTypeAware) rules.push({
|
|
195
|
+
files: filesTypeAware,
|
|
196
|
+
ignores: ignoresTypeAware,
|
|
197
|
+
name: "eienjs/typescript/rules-type-aware",
|
|
198
|
+
rules: {
|
|
199
|
+
...pluginTs.configs["strict-type-checked"].rules,
|
|
200
|
+
...stylistic ? pluginTs.configs["stylistic-type-checked"].rules : {},
|
|
201
|
+
...typeAwareRules,
|
|
202
|
+
...overridesTypeAware
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
rules.push({
|
|
206
|
+
files: isTypeAware ? filesTypeAware : files,
|
|
207
|
+
name: "eienjs/typescript/disables",
|
|
208
|
+
rules: {
|
|
209
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
210
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
211
|
+
"@typescript-eslint/no-non-null-assertion": "off"
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
if (isErasableSyntaxOnly) {
|
|
215
|
+
await ensurePackages(["eslint-plugin-erasable-syntax-only"]);
|
|
216
|
+
const pluginErasableSyntaxOnly = await interopDefault(import("eslint-plugin-erasable-syntax-only"));
|
|
217
|
+
const { enums, parameterProperties } = typeof isErasableSyntaxOnly === "boolean" ? {
|
|
218
|
+
enums: true,
|
|
219
|
+
parameterProperties: true
|
|
220
|
+
} : isErasableSyntaxOnly;
|
|
221
|
+
rules.push({
|
|
222
|
+
files,
|
|
223
|
+
name: "eienjs/typescript/erasable-syntax-only",
|
|
224
|
+
plugins: { "erasable-syntax-only": pluginErasableSyntaxOnly },
|
|
225
|
+
rules: {
|
|
226
|
+
"erasable-syntax-only/enums": enums ? "error" : "off",
|
|
227
|
+
"erasable-syntax-only/import-aliases": "error",
|
|
228
|
+
"erasable-syntax-only/namespaces": "error",
|
|
229
|
+
"erasable-syntax-only/parameter-properties": parameterProperties ? "error" : "off"
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return rules;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
export { typescript };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { GLOB_SRC } from "../globs.js";
|
|
2
|
+
import { pluginUnicorn } from "../plugins.js";
|
|
3
|
+
|
|
4
|
+
//#region src/configs/unicorn.ts
|
|
5
|
+
function unicorn(options = {}) {
|
|
6
|
+
const { overrides = {} } = options;
|
|
7
|
+
return [{
|
|
8
|
+
name: "eienjs/unicorn/rules",
|
|
9
|
+
plugins: { unicorn: pluginUnicorn },
|
|
10
|
+
rules: {
|
|
11
|
+
...pluginUnicorn.configs.recommended.rules,
|
|
12
|
+
"unicorn/no-this-assignment": "off",
|
|
13
|
+
"unicorn/consistent-destructuring": "error",
|
|
14
|
+
"unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
|
|
15
|
+
"unicorn/no-null": "off",
|
|
16
|
+
"unicorn/no-static-only-class": "off",
|
|
17
|
+
"unicorn/numeric-separators-style": "off",
|
|
18
|
+
"unicorn/prefer-dom-node-append": "off",
|
|
19
|
+
"unicorn/prefer-dom-node-dataset": "off",
|
|
20
|
+
"unicorn/prefer-dom-node-remove": "off",
|
|
21
|
+
"unicorn/prefer-dom-node-text-content": "off",
|
|
22
|
+
"unicorn/prefer-modern-dom-apis": "off",
|
|
23
|
+
"unicorn/prefer-query-selector": "off",
|
|
24
|
+
"unicorn/prefer-switch": ["error", { emptyDefaultCase: "do-nothing-comment" }],
|
|
25
|
+
"unicorn/prevent-abbreviations": "off",
|
|
26
|
+
"unicorn/no-thenable": "off",
|
|
27
|
+
"unicorn/expiring-todo-comments": "off",
|
|
28
|
+
"unicorn/no-array-reduce": "off",
|
|
29
|
+
"unicorn/prefer-export-from": "off",
|
|
30
|
+
"unicorn/prefer-top-level-await": "off",
|
|
31
|
+
"unicorn/filename-case": "off",
|
|
32
|
+
...overrides
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
files: [GLOB_SRC],
|
|
36
|
+
name: "eienjs/unicorn/special-rules",
|
|
37
|
+
rules: { "unicorn/filename-case": ["error", { case: "snakeCase" }] }
|
|
38
|
+
}];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { unicorn };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, OptionsVue, TypedFlatConfigItem } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/vue.d.ts
|
|
4
|
+
declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { vue };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { GLOB_SRC, GLOB_VUE } from "../globs.js";
|
|
2
|
+
import { interopDefault } from "../utils.js";
|
|
3
|
+
import { mergeProcessors } from "eslint-merge-processors";
|
|
4
|
+
|
|
5
|
+
//#region src/configs/vue.ts
|
|
6
|
+
async function vue(options = {}) {
|
|
7
|
+
const { files = [GLOB_VUE], overrides = {}, stylistic = true, typescript, componentNameInTemplateCasingOnlyRegistered = false, componentNameInTemplateCasingIgnores = [], componentNameInTemplateCasingGlobals = [] } = options;
|
|
8
|
+
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
9
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
10
|
+
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
11
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
12
|
+
interopDefault(import("vue-eslint-parser")),
|
|
13
|
+
interopDefault(import("eslint-processor-vue-blocks"))
|
|
14
|
+
]);
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
languageOptions: { globals: {
|
|
18
|
+
computed: "readonly",
|
|
19
|
+
defineEmits: "readonly",
|
|
20
|
+
defineExpose: "readonly",
|
|
21
|
+
defineProps: "readonly",
|
|
22
|
+
onMounted: "readonly",
|
|
23
|
+
onUnmounted: "readonly",
|
|
24
|
+
reactive: "readonly",
|
|
25
|
+
ref: "readonly",
|
|
26
|
+
shallowReactive: "readonly",
|
|
27
|
+
shallowRef: "readonly",
|
|
28
|
+
toRef: "readonly",
|
|
29
|
+
toRefs: "readonly",
|
|
30
|
+
watch: "readonly",
|
|
31
|
+
watchEffect: "readonly"
|
|
32
|
+
} },
|
|
33
|
+
name: "eienjs/vue/setup",
|
|
34
|
+
plugins: { vue: pluginVue }
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
files,
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parser: parserVue,
|
|
40
|
+
parserOptions: {
|
|
41
|
+
ecmaFeatures: { jsx: true },
|
|
42
|
+
extraFileExtensions: [".vue"],
|
|
43
|
+
parser: typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
44
|
+
sourceType: "module"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
name: "eienjs/vue/rules",
|
|
48
|
+
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([pluginVue.processors[".vue"], processorVueBlocks({
|
|
49
|
+
...sfcBlocks,
|
|
50
|
+
blocks: {
|
|
51
|
+
styles: true,
|
|
52
|
+
...sfcBlocks.blocks
|
|
53
|
+
}
|
|
54
|
+
})]),
|
|
55
|
+
rules: {
|
|
56
|
+
...pluginVue.configs.base.rules,
|
|
57
|
+
...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
|
|
58
|
+
...acc,
|
|
59
|
+
...c
|
|
60
|
+
}), {}),
|
|
61
|
+
...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
62
|
+
...acc,
|
|
63
|
+
...c
|
|
64
|
+
}), {}),
|
|
65
|
+
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
66
|
+
...acc,
|
|
67
|
+
...c
|
|
68
|
+
}), {}),
|
|
69
|
+
"vue/block-lang": ["error", { script: { lang: "ts" } }],
|
|
70
|
+
"vue/block-order": ["error", { order: [
|
|
71
|
+
"script",
|
|
72
|
+
"template",
|
|
73
|
+
"style"
|
|
74
|
+
] }],
|
|
75
|
+
"vue/component-api-style": ["error", ["script-setup"]],
|
|
76
|
+
"vue/component-name-in-template-casing": [
|
|
77
|
+
"error",
|
|
78
|
+
"PascalCase",
|
|
79
|
+
{
|
|
80
|
+
registeredComponentsOnly: componentNameInTemplateCasingOnlyRegistered,
|
|
81
|
+
ignores: componentNameInTemplateCasingIgnores,
|
|
82
|
+
globals: componentNameInTemplateCasingGlobals
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
86
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
87
|
+
"vue/define-macros-order": ["error", { order: [
|
|
88
|
+
"defineOptions",
|
|
89
|
+
"defineProps",
|
|
90
|
+
"defineEmits",
|
|
91
|
+
"defineSlots"
|
|
92
|
+
] }],
|
|
93
|
+
"vue/define-props-declaration": ["error", "runtime"],
|
|
94
|
+
"vue/dot-location": ["error", "property"],
|
|
95
|
+
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
96
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
97
|
+
"vue/html-indent": ["error", indent],
|
|
98
|
+
"vue/html-quotes": ["error", "double"],
|
|
99
|
+
"vue/max-attributes-per-line": "off",
|
|
100
|
+
"vue/multi-word-component-names": "off",
|
|
101
|
+
"vue/no-dupe-keys": "off",
|
|
102
|
+
"vue/no-empty-component-block": "error",
|
|
103
|
+
"vue/no-empty-pattern": "error",
|
|
104
|
+
"vue/no-irregular-whitespace": "error",
|
|
105
|
+
"vue/no-loss-of-precision": "error",
|
|
106
|
+
"vue/no-multiple-objects-in-class": "error",
|
|
107
|
+
"vue/no-ref-object-reactivity-loss": "error",
|
|
108
|
+
"vue/no-required-prop-with-default": "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-root-v-if": "error",
|
|
117
|
+
"vue/no-setup-props-reactivity-loss": "off",
|
|
118
|
+
"vue/no-sparse-arrays": "error",
|
|
119
|
+
"vue/no-template-target-blank": "error",
|
|
120
|
+
"vue/no-unused-properties": "error",
|
|
121
|
+
"vue/no-unused-refs": "error",
|
|
122
|
+
"vue/no-use-v-else-with-v-for": "error",
|
|
123
|
+
"vue/no-useless-mustaches": "error",
|
|
124
|
+
"vue/no-useless-v-bind": "error",
|
|
125
|
+
"vue/no-v-html": "off",
|
|
126
|
+
"vue/object-shorthand": [
|
|
127
|
+
"error",
|
|
128
|
+
"always",
|
|
129
|
+
{
|
|
130
|
+
avoidQuotes: true,
|
|
131
|
+
ignoreConstructors: false
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"vue/prefer-separate-static-class": "error",
|
|
135
|
+
"vue/prefer-template": "error",
|
|
136
|
+
"vue/prefer-true-attribute-shorthand": "error",
|
|
137
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
138
|
+
"vue/require-typed-ref": "error",
|
|
139
|
+
"vue/space-infix-ops": "error",
|
|
140
|
+
"vue/space-unary-ops": ["error", {
|
|
141
|
+
nonwords: false,
|
|
142
|
+
words: true
|
|
143
|
+
}],
|
|
144
|
+
"vue/static-class-names-order": "off",
|
|
145
|
+
...stylistic ? {
|
|
146
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
|
147
|
+
"vue/arrow-spacing": ["error", {
|
|
148
|
+
after: true,
|
|
149
|
+
before: true
|
|
150
|
+
}],
|
|
151
|
+
"vue/block-spacing": ["error", "always"],
|
|
152
|
+
"vue/block-tag-newline": ["error", {
|
|
153
|
+
multiline: "always",
|
|
154
|
+
singleline: "always"
|
|
155
|
+
}],
|
|
156
|
+
"vue/brace-style": [
|
|
157
|
+
"error",
|
|
158
|
+
"1tbs",
|
|
159
|
+
{ allowSingleLine: true }
|
|
160
|
+
],
|
|
161
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
|
162
|
+
"vue/comma-spacing": ["error", {
|
|
163
|
+
after: true,
|
|
164
|
+
before: false
|
|
165
|
+
}],
|
|
166
|
+
"vue/comma-style": ["error", "last"],
|
|
167
|
+
"vue/html-comment-content-spacing": [
|
|
168
|
+
"error",
|
|
169
|
+
"always",
|
|
170
|
+
{ exceptions: ["-"] }
|
|
171
|
+
],
|
|
172
|
+
"vue/key-spacing": ["error", {
|
|
173
|
+
afterColon: true,
|
|
174
|
+
beforeColon: false
|
|
175
|
+
}],
|
|
176
|
+
"vue/keyword-spacing": ["error", {
|
|
177
|
+
after: true,
|
|
178
|
+
before: true
|
|
179
|
+
}],
|
|
180
|
+
"vue/object-curly-newline": "off",
|
|
181
|
+
"vue/object-curly-spacing": ["error", "always"],
|
|
182
|
+
"vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
183
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
184
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
185
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
186
|
+
"vue/space-in-parens": ["error", "never"],
|
|
187
|
+
"vue/template-curly-spacing": "error"
|
|
188
|
+
} : {},
|
|
189
|
+
"antfu/no-top-level-await": "off",
|
|
190
|
+
"n/prefer-global/process": "off",
|
|
191
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
192
|
+
"@typescript-eslint/naming-convention": "off",
|
|
193
|
+
"@stylistic/max-len": "off",
|
|
194
|
+
...overrides
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
files: [`**/composables/${GLOB_SRC}`],
|
|
199
|
+
name: "eienjs/vue/composables-disables",
|
|
200
|
+
rules: { "@typescript-eslint/explicit-module-boundary-types": "off" }
|
|
201
|
+
}
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
export { vue };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/configs/yaml.d.ts
|
|
4
|
+
declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { yaml };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { GLOB_YAML } from "../globs.js";
|
|
2
|
+
import { interopDefault } from "../utils.js";
|
|
3
|
+
|
|
4
|
+
//#region src/configs/yaml.ts
|
|
5
|
+
async function yaml(options = {}) {
|
|
6
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic = true } = options;
|
|
7
|
+
const { indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
8
|
+
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "eienjs/yaml/setup",
|
|
12
|
+
plugins: { yaml: pluginYaml }
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
files,
|
|
16
|
+
languageOptions: { parser: parserYaml },
|
|
17
|
+
name: "eienjs/yaml/rules",
|
|
18
|
+
rules: {
|
|
19
|
+
"@stylistic/spaced-comment": "off",
|
|
20
|
+
"yaml/block-mapping": "error",
|
|
21
|
+
"yaml/block-sequence": "error",
|
|
22
|
+
"yaml/no-empty-key": "error",
|
|
23
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
24
|
+
"yaml/no-irregular-whitespace": "error",
|
|
25
|
+
"yaml/plain-scalar": "error",
|
|
26
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
27
|
+
...stylistic ? {
|
|
28
|
+
"yaml/block-mapping-question-indicator-newline": "error",
|
|
29
|
+
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
30
|
+
"yaml/flow-mapping-curly-newline": "error",
|
|
31
|
+
"yaml/flow-mapping-curly-spacing": "error",
|
|
32
|
+
"yaml/flow-sequence-bracket-newline": "error",
|
|
33
|
+
"yaml/flow-sequence-bracket-spacing": "error",
|
|
34
|
+
"yaml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
35
|
+
"yaml/key-spacing": "error",
|
|
36
|
+
"yaml/no-tab-indent": "error",
|
|
37
|
+
"yaml/quotes": ["error", {
|
|
38
|
+
avoidEscape: true,
|
|
39
|
+
prefer: quotes === "backtick" ? "single" : quotes
|
|
40
|
+
}],
|
|
41
|
+
"yaml/spaced-comment": "error"
|
|
42
|
+
} : {},
|
|
43
|
+
...overrides
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
files: ["pnpm-workspace.yaml"],
|
|
48
|
+
name: "eienjs/yaml/pnpm-workspace",
|
|
49
|
+
rules: { "yaml/sort-keys": [
|
|
50
|
+
"error",
|
|
51
|
+
{
|
|
52
|
+
order: [
|
|
53
|
+
"packages",
|
|
54
|
+
"overrides",
|
|
55
|
+
"patchedDependencies",
|
|
56
|
+
"hoistPattern",
|
|
57
|
+
"catalog",
|
|
58
|
+
"catalogs",
|
|
59
|
+
"allowedDeprecatedVersions",
|
|
60
|
+
"allowNonAppliedPatches",
|
|
61
|
+
"configDependencies",
|
|
62
|
+
"ignoredBuiltDependencies",
|
|
63
|
+
"ignoredOptionalDependencies",
|
|
64
|
+
"neverBuiltDependencies",
|
|
65
|
+
"onlyBuiltDependencies",
|
|
66
|
+
"onlyBuiltDependenciesFile",
|
|
67
|
+
"packageExtensions",
|
|
68
|
+
"peerDependencyRules",
|
|
69
|
+
"supportedArchitectures"
|
|
70
|
+
],
|
|
71
|
+
pathPattern: "^$"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
order: { type: "asc" },
|
|
75
|
+
pathPattern: ".*"
|
|
76
|
+
}
|
|
77
|
+
] }
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { yaml };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ConfigNames, RuleOptions } from "./typegen.js";
|
|
2
|
+
import { OptionsConfig, TypedFlatConfigItem } from "./types.js";
|
|
3
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
4
|
+
import { Linter } from "eslint";
|
|
5
|
+
|
|
6
|
+
//#region src/factory.d.ts
|
|
7
|
+
declare const defaultPluginRenaming: {
|
|
8
|
+
'import-lite': string;
|
|
9
|
+
vitest: string;
|
|
10
|
+
yml: string;
|
|
11
|
+
};
|
|
12
|
+
declare function eienjs(options?: OptionsConfig & Omit<TypedFlatConfigItem, 'files'>): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
|
|
13
|
+
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
14
|
+
declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
|
|
15
|
+
declare function getOverrides(options: OptionsConfig, key: keyof OptionsConfig): Partial<Linter.RulesRecord & RuleOptions>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ResolvedOptions, defaultPluginRenaming, eienjs, getOverrides, resolveSubOptions };
|