@curev/eslint-config 0.3.0 → 0.3.1
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/chunk-TMQW6NVO.js +69 -0
- package/dist/dist-QAUNCL3U.js +226708 -0
- package/dist/index.cjs +228976 -0
- package/dist/index.d.cts +516 -0
- package/dist/index.d.ts +516 -0
- package/dist/index.js +2153 -0
- package/package.json +5 -2
- package/.eslintignore +0 -1
- package/.github/workflows/release.yml +0 -37
- package/.vscode/settings.json +0 -36
- package/CHANGELOG.md +0 -740
- package/eslint.config.ts +0 -3
- package/fixtures/input/css.css +0 -10
- package/fixtures/input/html.html +0 -17
- package/fixtures/input/javascript.js +0 -69
- package/fixtures/input/jsx.jsx +0 -27
- package/fixtures/input/markdown.md +0 -34
- package/fixtures/input/svelte.svelte +0 -8
- package/fixtures/input/toml.toml +0 -23
- package/fixtures/input/tsx.tsx +0 -32
- package/fixtures/input/typescript.ts +0 -84
- package/fixtures/input/vue-ts.vue +0 -35
- package/fixtures/input/vue.vue +0 -27
- package/fixtures/output/all/javascript.js +0 -72
- package/fixtures/output/all/jsx.jsx +0 -26
- package/fixtures/output/all/markdown.md +0 -33
- package/fixtures/output/all/svelte.svelte +0 -8
- package/fixtures/output/all/toml.toml +0 -23
- package/fixtures/output/all/tsx.tsx +0 -32
- package/fixtures/output/all/typescript.ts +0 -83
- package/fixtures/output/all/vue-ts.vue +0 -35
- package/fixtures/output/all/vue.vue +0 -24
- package/fixtures/output/js/javascript.js +0 -72
- package/fixtures/output/js/markdown.md +0 -33
- package/fixtures/output/js/toml.toml +0 -23
- package/fixtures/output/no-markdown-with-formatters/javascript.js +0 -72
- package/fixtures/output/no-markdown-with-formatters/jsx.jsx +0 -24
- package/fixtures/output/no-markdown-with-formatters/markdown.md +0 -33
- package/fixtures/output/no-markdown-with-formatters/toml.toml +0 -23
- package/fixtures/output/no-markdown-with-formatters/tsx.tsx +0 -23
- package/fixtures/output/no-markdown-with-formatters/typescript.ts +0 -83
- package/fixtures/output/no-style/javascript.js +0 -72
- package/fixtures/output/no-style/jsx.jsx +0 -21
- package/fixtures/output/no-style/toml.toml +0 -23
- package/fixtures/output/no-style/typescript.ts +0 -80
- package/fixtures/output/no-style/vue-ts.vue +0 -35
- package/fixtures/output/no-style/vue.vue +0 -24
- package/fixtures/output/tab-double-quotes/javascript.js +0 -72
- package/fixtures/output/tab-double-quotes/jsx.jsx +0 -26
- package/fixtures/output/tab-double-quotes/markdown.md +0 -33
- package/fixtures/output/tab-double-quotes/toml.toml +0 -23
- package/fixtures/output/tab-double-quotes/tsx.tsx +0 -32
- package/fixtures/output/tab-double-quotes/typescript.ts +0 -83
- package/fixtures/output/tab-double-quotes/vue-ts.vue +0 -35
- package/fixtures/output/tab-double-quotes/vue.vue +0 -24
- package/fixtures/output/ts-override/javascript.js +0 -72
- package/fixtures/output/ts-override/jsx.jsx +0 -26
- package/fixtures/output/ts-override/markdown.md +0 -33
- package/fixtures/output/ts-override/toml.toml +0 -23
- package/fixtures/output/ts-override/tsx.tsx +0 -32
- package/fixtures/output/ts-override/typescript.ts +0 -83
- package/fixtures/output/ts-override/vue-ts.vue +0 -35
- package/fixtures/output/ts-override/vue.vue +0 -24
- package/fixtures/output/with-formatters/css.css +0 -11
- package/fixtures/output/with-formatters/html.html +0 -28
- package/fixtures/output/with-formatters/javascript.js +0 -72
- package/fixtures/output/with-formatters/jsx.jsx +0 -26
- package/fixtures/output/with-formatters/markdown.md +0 -34
- package/fixtures/output/with-formatters/toml.toml +0 -23
- package/fixtures/output/with-formatters/tsx.tsx +0 -32
- package/fixtures/output/with-formatters/typescript.ts +0 -83
- package/fixtures/output/with-formatters/vue-ts.vue +0 -38
- package/fixtures/output/with-formatters/vue.vue +0 -24
- package/src/configs/comments.ts +0 -19
- package/src/configs/formatters.ts +0 -187
- package/src/configs/ignores.ts +0 -10
- package/src/configs/imports.ts +0 -46
- package/src/configs/index.ts +0 -21
- package/src/configs/javascript.ts +0 -277
- package/src/configs/jsdoc.ts +0 -41
- package/src/configs/jsonc.ts +0 -86
- package/src/configs/markdown.ts +0 -110
- package/src/configs/node.ts +0 -24
- package/src/configs/perfectionist.ts +0 -18
- package/src/configs/react.ts +0 -111
- package/src/configs/sort.ts +0 -223
- package/src/configs/stylistic.ts +0 -52
- package/src/configs/svelte.ts +0 -107
- package/src/configs/test.ts +0 -54
- package/src/configs/toml.ts +0 -72
- package/src/configs/typescript.ts +0 -171
- package/src/configs/unicorn.ts +0 -41
- package/src/configs/unocss.ts +0 -43
- package/src/configs/vue.ts +0 -170
- package/src/configs/yaml.ts +0 -72
- package/src/factory.ts +0 -255
- package/src/globs.ts +0 -81
- package/src/index.ts +0 -9
- package/src/plugins.ts +0 -10
- package/src/stub.d.ts +0 -3
- package/src/types.ts +0 -364
- package/src/utils.ts +0 -76
- package/src/vender/prettier-types.ts +0 -136
- package/test/cli.spec.ts +0 -90
- package/test/fixtures.test.ts +0 -127
- package/tsconfig.json +0 -17
- package/tsup.config.ts +0 -8
package/src/configs/sort.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import type { FlatConfigItem } from "../types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Sort package.json
|
|
5
|
-
*
|
|
6
|
-
* Requires `jsonc` config
|
|
7
|
-
*/
|
|
8
|
-
export async function sortPackageJson(): Promise<FlatConfigItem[]> {
|
|
9
|
-
return [
|
|
10
|
-
{
|
|
11
|
-
files: ["**/package.json"],
|
|
12
|
-
name: "curev:sort-package-json",
|
|
13
|
-
rules: {
|
|
14
|
-
"jsonc/sort-array-values": [
|
|
15
|
-
"error",
|
|
16
|
-
{
|
|
17
|
-
order: { type: "asc" },
|
|
18
|
-
pathPattern: "^files$"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"jsonc/sort-keys": [
|
|
22
|
-
"error",
|
|
23
|
-
{
|
|
24
|
-
order: [
|
|
25
|
-
"publisher",
|
|
26
|
-
"name",
|
|
27
|
-
"displayName",
|
|
28
|
-
"type",
|
|
29
|
-
"version",
|
|
30
|
-
"private",
|
|
31
|
-
"packageManager",
|
|
32
|
-
"description",
|
|
33
|
-
"author",
|
|
34
|
-
"license",
|
|
35
|
-
"funding",
|
|
36
|
-
"homepage",
|
|
37
|
-
"repository",
|
|
38
|
-
"bugs",
|
|
39
|
-
"keywords",
|
|
40
|
-
"categories",
|
|
41
|
-
"sideEffects",
|
|
42
|
-
"exports",
|
|
43
|
-
"main",
|
|
44
|
-
"module",
|
|
45
|
-
"unpkg",
|
|
46
|
-
"jsdelivr",
|
|
47
|
-
"types",
|
|
48
|
-
"typesVersions",
|
|
49
|
-
"bin",
|
|
50
|
-
"icon",
|
|
51
|
-
"files",
|
|
52
|
-
"engines",
|
|
53
|
-
"activationEvents",
|
|
54
|
-
"contributes",
|
|
55
|
-
"scripts",
|
|
56
|
-
"peerDependencies",
|
|
57
|
-
"peerDependenciesMeta",
|
|
58
|
-
"dependencies",
|
|
59
|
-
"optionalDependencies",
|
|
60
|
-
"devDependencies",
|
|
61
|
-
"pnpm",
|
|
62
|
-
"overrides",
|
|
63
|
-
"resolutions",
|
|
64
|
-
"husky",
|
|
65
|
-
"simple-git-hooks",
|
|
66
|
-
"lint-staged",
|
|
67
|
-
"eslintConfig"
|
|
68
|
-
],
|
|
69
|
-
pathPattern: "^$"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
order: { type: "asc" },
|
|
73
|
-
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
order: { type: "asc" },
|
|
77
|
-
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
order: [
|
|
81
|
-
"types",
|
|
82
|
-
"import",
|
|
83
|
-
"require",
|
|
84
|
-
"default"
|
|
85
|
-
],
|
|
86
|
-
pathPattern: "^exports.*$"
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Sort tsconfig.json
|
|
95
|
-
*
|
|
96
|
-
* Requires `jsonc` config
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
export function sortTsconfig(): FlatConfigItem[] {
|
|
100
|
-
return [
|
|
101
|
-
{
|
|
102
|
-
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
103
|
-
name: "curev:sort-tsconfig",
|
|
104
|
-
rules: {
|
|
105
|
-
"jsonc/sort-keys": [
|
|
106
|
-
"error",
|
|
107
|
-
{
|
|
108
|
-
order: [
|
|
109
|
-
"extends",
|
|
110
|
-
"compilerOptions",
|
|
111
|
-
"references",
|
|
112
|
-
"files",
|
|
113
|
-
"include",
|
|
114
|
-
"exclude"
|
|
115
|
-
],
|
|
116
|
-
pathPattern: "^$"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
order: [
|
|
120
|
-
/* Projects */
|
|
121
|
-
"incremental",
|
|
122
|
-
"composite",
|
|
123
|
-
"tsBuildInfoFile",
|
|
124
|
-
"disableSourceOfProjectReferenceRedirect",
|
|
125
|
-
"disableSolutionSearching",
|
|
126
|
-
"disableReferencedProjectLoad",
|
|
127
|
-
/* Language and Environment */
|
|
128
|
-
"target",
|
|
129
|
-
"jsx",
|
|
130
|
-
"jsxFactory",
|
|
131
|
-
"jsxFragmentFactory",
|
|
132
|
-
"jsxImportSource",
|
|
133
|
-
"lib",
|
|
134
|
-
"moduleDetection",
|
|
135
|
-
"noLib",
|
|
136
|
-
"reactNamespace",
|
|
137
|
-
"useDefineForClassFields",
|
|
138
|
-
"emitDecoratorMetadata",
|
|
139
|
-
"experimentalDecorators",
|
|
140
|
-
/* Modules */
|
|
141
|
-
"baseUrl",
|
|
142
|
-
"rootDir",
|
|
143
|
-
"rootDirs",
|
|
144
|
-
"customConditions",
|
|
145
|
-
"module",
|
|
146
|
-
"moduleResolution",
|
|
147
|
-
"moduleSuffixes",
|
|
148
|
-
"noResolve",
|
|
149
|
-
"paths",
|
|
150
|
-
"resolveJsonModule",
|
|
151
|
-
"resolvePackageJsonExports",
|
|
152
|
-
"resolvePackageJsonImports",
|
|
153
|
-
"typeRoots",
|
|
154
|
-
"types",
|
|
155
|
-
"allowArbitraryExtensions",
|
|
156
|
-
"allowImportingTsExtensions",
|
|
157
|
-
"allowUmdGlobalAccess",
|
|
158
|
-
/* JavaScript Support */
|
|
159
|
-
"allowJs",
|
|
160
|
-
"checkJs",
|
|
161
|
-
"maxNodeModuleJsDepth",
|
|
162
|
-
/* Type Checking */
|
|
163
|
-
"strict",
|
|
164
|
-
"strictBindCallApply",
|
|
165
|
-
"strictFunctionTypes",
|
|
166
|
-
"strictNullChecks",
|
|
167
|
-
"strictPropertyInitialization",
|
|
168
|
-
"allowUnreachableCode",
|
|
169
|
-
"allowUnusedLabels",
|
|
170
|
-
"alwaysStrict",
|
|
171
|
-
"exactOptionalPropertyTypes",
|
|
172
|
-
"noFallthroughCasesInSwitch",
|
|
173
|
-
"noImplicitAny",
|
|
174
|
-
"noImplicitOverride",
|
|
175
|
-
"noImplicitReturns",
|
|
176
|
-
"noImplicitThis",
|
|
177
|
-
"noPropertyAccessFromIndexSignature",
|
|
178
|
-
"noUncheckedIndexedAccess",
|
|
179
|
-
"noUnusedLocals",
|
|
180
|
-
"noUnusedParameters",
|
|
181
|
-
"useUnknownInCatchVariables",
|
|
182
|
-
/* Emit */
|
|
183
|
-
"declaration",
|
|
184
|
-
"declarationDir",
|
|
185
|
-
"declarationMap",
|
|
186
|
-
"downlevelIteration",
|
|
187
|
-
"emitBOM",
|
|
188
|
-
"emitDeclarationOnly",
|
|
189
|
-
"importHelpers",
|
|
190
|
-
"importsNotUsedAsValues",
|
|
191
|
-
"inlineSourceMap",
|
|
192
|
-
"inlineSources",
|
|
193
|
-
"mapRoot",
|
|
194
|
-
"newLine",
|
|
195
|
-
"noEmit",
|
|
196
|
-
"noEmitHelpers",
|
|
197
|
-
"noEmitOnError",
|
|
198
|
-
"outDir",
|
|
199
|
-
"outFile",
|
|
200
|
-
"preserveConstEnums",
|
|
201
|
-
"preserveValueImports",
|
|
202
|
-
"removeComments",
|
|
203
|
-
"sourceMap",
|
|
204
|
-
"sourceRoot",
|
|
205
|
-
"stripInternal",
|
|
206
|
-
/* Interop Constraints */
|
|
207
|
-
"allowSyntheticDefaultImports",
|
|
208
|
-
"esModuleInterop",
|
|
209
|
-
"forceConsistentCasingInFileNames",
|
|
210
|
-
"isolatedModules",
|
|
211
|
-
"preserveSymlinks",
|
|
212
|
-
"verbatimModuleSyntax",
|
|
213
|
-
/* Completeness */
|
|
214
|
-
"skipDefaultLibCheck",
|
|
215
|
-
"skipLibCheck"
|
|
216
|
-
],
|
|
217
|
-
pathPattern: "^compilerOptions$"
|
|
218
|
-
}
|
|
219
|
-
]
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
];
|
|
223
|
-
}
|
package/src/configs/stylistic.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { interopDefault } from "../utils";
|
|
2
|
-
import type { FlatConfigItem, OptionsOverrides, StylisticConfig } from "../types";
|
|
3
|
-
import { pluginAntfu } from "../plugins";
|
|
4
|
-
|
|
5
|
-
export const StylisticConfigDefaults: StylisticConfig = {
|
|
6
|
-
indent: 2,
|
|
7
|
-
jsx: true,
|
|
8
|
-
quotes: "double",
|
|
9
|
-
semi: true,
|
|
10
|
-
braceStyle: "1tbs",
|
|
11
|
-
commaDangle: "never"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export async function stylistic(
|
|
15
|
-
options: StylisticConfig & OptionsOverrides = {}
|
|
16
|
-
): Promise<FlatConfigItem[]> {
|
|
17
|
-
const mergeOptions = {
|
|
18
|
-
...StylisticConfigDefaults,
|
|
19
|
-
...options
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const { overrides = {} } = mergeOptions;
|
|
23
|
-
|
|
24
|
-
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
25
|
-
|
|
26
|
-
const config = pluginStylistic.configs.customize({
|
|
27
|
-
flat: true,
|
|
28
|
-
pluginName: "style",
|
|
29
|
-
...mergeOptions
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return [
|
|
33
|
-
{
|
|
34
|
-
name: "curev:stylistic",
|
|
35
|
-
plugins: {
|
|
36
|
-
curev: pluginAntfu,
|
|
37
|
-
style: pluginStylistic
|
|
38
|
-
},
|
|
39
|
-
rules: {
|
|
40
|
-
...config.rules,
|
|
41
|
-
|
|
42
|
-
"antfu/consistent-list-newline": "error",
|
|
43
|
-
"antfu/if-newline": "error",
|
|
44
|
-
"antfu/top-level-function": "error",
|
|
45
|
-
"semi-spacing": ["error", { before: false, after: true }],
|
|
46
|
-
"style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
47
|
-
"curly": ["error", "all"],
|
|
48
|
-
...overrides
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
|
-
}
|
package/src/configs/svelte.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { ensurePackages, interopDefault } from "../utils";
|
|
2
|
-
import type { FlatConfigItem, OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic } from "../types";
|
|
3
|
-
import { GLOB_SVELTE } from "../globs";
|
|
4
|
-
|
|
5
|
-
export async function svelte(
|
|
6
|
-
options: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {}
|
|
7
|
-
): Promise<FlatConfigItem[]> {
|
|
8
|
-
const {
|
|
9
|
-
files = [GLOB_SVELTE],
|
|
10
|
-
overrides = {},
|
|
11
|
-
stylistic = true
|
|
12
|
-
} = options;
|
|
13
|
-
|
|
14
|
-
const {
|
|
15
|
-
indent = 2,
|
|
16
|
-
quotes = "single"
|
|
17
|
-
} = typeof stylistic === "boolean" ? {} : stylistic;
|
|
18
|
-
|
|
19
|
-
await ensurePackages([
|
|
20
|
-
"eslint-plugin-svelte"
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
const [
|
|
24
|
-
pluginSvelte,
|
|
25
|
-
parserSvelte
|
|
26
|
-
] = await Promise.all([
|
|
27
|
-
interopDefault(import("eslint-plugin-svelte")),
|
|
28
|
-
interopDefault(import("svelte-eslint-parser"))
|
|
29
|
-
] as const);
|
|
30
|
-
|
|
31
|
-
return [
|
|
32
|
-
{
|
|
33
|
-
name: "curev:svelte:setup",
|
|
34
|
-
plugins: {
|
|
35
|
-
svelte: pluginSvelte
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
files,
|
|
40
|
-
languageOptions: {
|
|
41
|
-
parser: parserSvelte,
|
|
42
|
-
parserOptions: {
|
|
43
|
-
extraFileExtensions: [".svelte"],
|
|
44
|
-
parser: options.typescript
|
|
45
|
-
? await interopDefault(import("@typescript-eslint/parser")) as any
|
|
46
|
-
: null
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
name: "curev:svelte:rules",
|
|
50
|
-
processor: pluginSvelte.processors[".svelte"],
|
|
51
|
-
rules: {
|
|
52
|
-
"import/no-mutable-exports": "off",
|
|
53
|
-
"no-undef": "off", // incompatible with most recent (attribute-form) generic types RFC
|
|
54
|
-
"no-unused-vars": ["error", {
|
|
55
|
-
args: "none",
|
|
56
|
-
caughtErrors: "none",
|
|
57
|
-
ignoreRestSiblings: true,
|
|
58
|
-
vars: "all",
|
|
59
|
-
varsIgnorePattern: "^\\$\\$Props$"
|
|
60
|
-
}],
|
|
61
|
-
|
|
62
|
-
"svelte/comment-directive": "error",
|
|
63
|
-
"svelte/no-at-debug-tags": "warn",
|
|
64
|
-
"svelte/no-at-html-tags": "error",
|
|
65
|
-
"svelte/no-dupe-else-if-blocks": "error",
|
|
66
|
-
"svelte/no-dupe-style-properties": "error",
|
|
67
|
-
"svelte/no-dupe-use-directives": "error",
|
|
68
|
-
"svelte/no-dynamic-slot-name": "error",
|
|
69
|
-
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
70
|
-
"svelte/no-inner-declarations": "error",
|
|
71
|
-
"svelte/no-not-function-handler": "error",
|
|
72
|
-
"svelte/no-object-in-text-mustaches": "error",
|
|
73
|
-
"svelte/no-reactive-functions": "error",
|
|
74
|
-
"svelte/no-reactive-literals": "error",
|
|
75
|
-
"svelte/no-shorthand-style-property-overrides": "error",
|
|
76
|
-
"svelte/no-unknown-style-directive-property": "error",
|
|
77
|
-
"svelte/no-unused-svelte-ignore": "error",
|
|
78
|
-
"svelte/no-useless-mustaches": "error",
|
|
79
|
-
"svelte/require-store-callbacks-use-set-param": "error",
|
|
80
|
-
"svelte/system": "error",
|
|
81
|
-
"svelte/valid-compile": "error",
|
|
82
|
-
"svelte/valid-each-key": "error",
|
|
83
|
-
|
|
84
|
-
"unused-imports/no-unused-vars": [
|
|
85
|
-
"error",
|
|
86
|
-
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
|
|
87
|
-
],
|
|
88
|
-
|
|
89
|
-
...stylistic
|
|
90
|
-
? {
|
|
91
|
-
"style/no-trailing-spaces": "off", // superseded by svelte/no-trailing-spaces
|
|
92
|
-
"svelte/derived-has-same-inputs-outputs": "error",
|
|
93
|
-
"svelte/html-closing-bracket-spacing": "error",
|
|
94
|
-
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
95
|
-
"svelte/indent": ["error", { alignAttributesVertically: true, indent }],
|
|
96
|
-
"svelte/mustache-spacing": "error",
|
|
97
|
-
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
98
|
-
"svelte/no-trailing-spaces": "error",
|
|
99
|
-
"svelte/spaced-html-comment": "error"
|
|
100
|
-
}
|
|
101
|
-
: {},
|
|
102
|
-
|
|
103
|
-
...overrides
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
];
|
|
107
|
-
}
|
package/src/configs/test.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
}
|
package/src/configs/toml.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
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
|
-
}
|