@jsse/eslint-config 0.3.7 → 0.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/CHANGELOG.md +10 -0
- package/dist/cli.js +3 -3
- package/dist/esm/config-fns.d.ts +109 -34
- package/dist/esm/config-fns.js +111 -35
- package/dist/esm/configs/{comments.d.ts → de-morgan.d.ts} +1 -1
- package/dist/esm/configs/de-morgan.js +9 -0
- package/dist/esm/configs/eslint-comments.d.ts +2 -0
- package/dist/esm/configs/{comments.js → eslint-comments.js} +1 -1
- package/dist/esm/configs/gql.d.ts +2 -2
- package/dist/esm/configs/markdown.js +1 -1
- package/dist/esm/configs/prettier.d.ts +2 -2
- package/dist/esm/configs/react.d.ts +3 -3
- package/dist/esm/configs/stylistic.js +1 -1
- package/dist/esm/configs/ts/parser.d.ts +2 -2
- package/dist/esm/configs/ts/parser.js +7 -5
- package/dist/esm/configs/ts/typescript-rules.d.ts +9 -4
- package/dist/esm/configs/ts/typescript-rules.js +26 -62
- package/dist/esm/configs/ts/typescript.js +56 -43
- package/dist/esm/define-config.d.ts +3 -3
- package/dist/esm/define-config.js +38 -28
- package/dist/esm/fixable.d.ts +2 -1
- package/dist/esm/fixable.js +3 -395
- package/dist/esm/generated/fixable-rules-map.d.ts +2 -0
- package/dist/esm/generated/fixable-rules-map.js +436 -0
- package/dist/esm/generated/version.d.ts +1 -1
- package/dist/esm/generated/version.js +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/lager.d.ts +1 -1
- package/dist/esm/lager.js +1 -1
- package/dist/esm/plugins-all.d.ts +11 -8
- package/dist/esm/plugins-all.js +99 -10
- package/dist/esm/plugins.d.ts +1 -0
- package/dist/esm/plugins.js +4 -1
- package/dist/esm/presets.d.ts +16 -0
- package/dist/esm/presets.js +96 -1
- package/dist/esm/types.d.ts +34 -22
- package/dist/esm/utils.d.ts +5 -5
- package/dist/esm/utils.js +1 -1
- package/dist/index.d.ts +7404 -6303
- package/dist/index.js +289 -227
- package/package.json +20 -27
- package/dist/esm/plugindex.d.ts +0 -7
- package/dist/esm/plugindex.js +0 -60
package/dist/esm/presets.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
+
import type { Config } from "./types.js";
|
|
1
2
|
import { type DefineConfig } from "./define-config.js";
|
|
2
3
|
export declare const jsseReact: DefineConfig;
|
|
4
|
+
/** Ignore common files and include javascript support */
|
|
5
|
+
export declare const presetJavascript: () => Promise<Config[]>;
|
|
6
|
+
/** Includes markdown, yaml + `presetJsonc` support */
|
|
7
|
+
export declare const presetLangsExtensions: () => Promise<Config[]>;
|
|
8
|
+
/** Includes `presetJavaScript` and typescript support */
|
|
9
|
+
export declare const presetBasic: () => Promise<Config[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Includes
|
|
12
|
+
* - `presetBasic` (JS+TS) support
|
|
13
|
+
* - `presetLangsExtensions` (markdown, yaml, jsonc) support
|
|
14
|
+
* - Vue support
|
|
15
|
+
* - UnoCSS support (`uno.config.ts` is required)
|
|
16
|
+
* - Prettier support
|
|
17
|
+
*/
|
|
18
|
+
export declare const presetAll: () => Promise<Config[]>;
|
package/dist/esm/presets.js
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
+
import { command, eslintComments, ignores, imports, javascript, jsdoc, jsonc, markdown, n, sortPackageJson, sortTsconfig, typescript, unicorn, yml, } from "./config-fns.js";
|
|
2
|
+
import { deMorgan } from "./configs/de-morgan.js";
|
|
1
3
|
import { jsse } from "./define-config.js";
|
|
4
|
+
const makePresetFn = (cfgFunctions) => {
|
|
5
|
+
return async () => {
|
|
6
|
+
const results = await Promise.allSettled(cfgFunctions.map((fn) => fn()));
|
|
7
|
+
const ok = [];
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
const err = [];
|
|
10
|
+
for (const result of results) {
|
|
11
|
+
if (result.status === "fulfilled") {
|
|
12
|
+
ok.push(...result.value);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
err.push(result.reason);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (err.length > 0) {
|
|
19
|
+
const errorMessage = `Some preset functions failed: ${err
|
|
20
|
+
.map((e) => {
|
|
21
|
+
return e instanceof Error ? e.message : JSON.stringify(e);
|
|
22
|
+
})
|
|
23
|
+
.join(", ")}`;
|
|
24
|
+
throw new Error(errorMessage);
|
|
25
|
+
}
|
|
26
|
+
return ok;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
2
29
|
export const jsseReact = (options, ...configs) => {
|
|
3
30
|
return jsse({
|
|
4
31
|
react: true,
|
|
@@ -8,5 +35,73 @@ export const jsseReact = (options, ...configs) => {
|
|
|
8
35
|
tsconfig: ["./tsconfig.json", "./tsconfig.eslint.json"],
|
|
9
36
|
},
|
|
10
37
|
...options,
|
|
11
|
-
},
|
|
38
|
+
},
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
40
|
+
...configs);
|
|
12
41
|
};
|
|
42
|
+
/** Ignore common files and include javascript support */
|
|
43
|
+
export const presetJavascript = makePresetFn([
|
|
44
|
+
ignores,
|
|
45
|
+
javascript,
|
|
46
|
+
eslintComments,
|
|
47
|
+
imports,
|
|
48
|
+
unicorn,
|
|
49
|
+
n,
|
|
50
|
+
jsdoc,
|
|
51
|
+
deMorgan,
|
|
52
|
+
]);
|
|
53
|
+
// export const presetJavaScript = async (): Promise<Config[]> => {
|
|
54
|
+
// const promises = [
|
|
55
|
+
// ignores(),
|
|
56
|
+
// javascript(),
|
|
57
|
+
// comments(),
|
|
58
|
+
// imports(),
|
|
59
|
+
// unicorn(),
|
|
60
|
+
// n(),
|
|
61
|
+
// jsdoc(),
|
|
62
|
+
// deMorgan(),
|
|
63
|
+
// ];
|
|
64
|
+
//
|
|
65
|
+
// const r = await Promise.allSettled(promises);
|
|
66
|
+
//
|
|
67
|
+
// const ok = [];
|
|
68
|
+
// const err = [];
|
|
69
|
+
// for (const p of r) {
|
|
70
|
+
// if (p.status === "fulfilled") {
|
|
71
|
+
// ok.push(...p.value);
|
|
72
|
+
// } else {
|
|
73
|
+
// err.push(p.reason);
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
//
|
|
77
|
+
// return ok;
|
|
78
|
+
// };
|
|
79
|
+
/** Includes basic json(c) file support and sorting json keys */
|
|
80
|
+
const presetJsonc = makePresetFn([
|
|
81
|
+
jsonc,
|
|
82
|
+
sortPackageJson,
|
|
83
|
+
sortTsconfig,
|
|
84
|
+
// ...sortPnpmWorkspace(),
|
|
85
|
+
]);
|
|
86
|
+
/** Includes markdown, yaml + `presetJsonc` support */
|
|
87
|
+
export const presetLangsExtensions = makePresetFn([markdown, yml, presetJsonc]);
|
|
88
|
+
/** Includes `presetJavaScript` and typescript support */
|
|
89
|
+
export const presetBasic = makePresetFn([presetJavascript, typescript]);
|
|
90
|
+
// Config[] => [
|
|
91
|
+
// presetJavaScript(),
|
|
92
|
+
// typescript(),
|
|
93
|
+
// // ...sortImports(),
|
|
94
|
+
// ];
|
|
95
|
+
/**
|
|
96
|
+
* Includes
|
|
97
|
+
* - `presetBasic` (JS+TS) support
|
|
98
|
+
* - `presetLangsExtensions` (markdown, yaml, jsonc) support
|
|
99
|
+
* - Vue support
|
|
100
|
+
* - UnoCSS support (`uno.config.ts` is required)
|
|
101
|
+
* - Prettier support
|
|
102
|
+
*/
|
|
103
|
+
export const presetAll = makePresetFn([
|
|
104
|
+
presetBasic,
|
|
105
|
+
presetLangsExtensions,
|
|
106
|
+
command,
|
|
107
|
+
]);
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { ParserOptions } from "@typescript-eslint/parser";
|
|
2
2
|
import type { Linter } from "eslint";
|
|
3
3
|
import type { FlatGitignoreOptions } from "eslint-config-flat-gitignore";
|
|
4
|
-
import type { RuleOptionsUnion as
|
|
5
|
-
export type
|
|
6
|
-
export type UnPromise<T> = T extends Promise<infer U> ? U : T;
|
|
7
|
-
export type Rules = RuleOptions;
|
|
8
|
-
export type LanguageOptions = Linter.Config["languageOptions"];
|
|
9
|
-
export type TypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & Rules>, "plugins"> & {
|
|
10
|
-
/**
|
|
11
|
-
* Custom name of each config item
|
|
12
|
-
*/
|
|
13
|
-
name?: string;
|
|
4
|
+
import type { RuleOptionsUnion as Rules } from "./generated/rule-options.js";
|
|
5
|
+
export type Config = Omit<Linter.Config<Linter.RulesRecord & Rules>, "plugins"> & {
|
|
14
6
|
/**
|
|
15
7
|
* An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
|
|
16
8
|
*
|
|
@@ -18,8 +10,11 @@ export type TypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & Rules>
|
|
|
18
10
|
*/
|
|
19
11
|
plugins?: Record<string, any>;
|
|
20
12
|
};
|
|
13
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
14
|
+
export type UnPromise<T> = T extends Promise<infer U> ? U : T;
|
|
15
|
+
export type LanguageOptions = Linter.Config["languageOptions"];
|
|
21
16
|
export type RuleName = keyof Rules;
|
|
22
|
-
export type TypedFlatConfigItemWithId =
|
|
17
|
+
export type TypedFlatConfigItemWithId = Config & {
|
|
23
18
|
name: string;
|
|
24
19
|
};
|
|
25
20
|
export type OptionsCommon = {
|
|
@@ -46,8 +41,7 @@ export type OptionsComponentExts = {
|
|
|
46
41
|
*/
|
|
47
42
|
componentExts?: string[];
|
|
48
43
|
};
|
|
49
|
-
export type
|
|
50
|
-
export type EslintConfigFn<T = undefined> = (options?: T) => PromiseFlatConfigItem;
|
|
44
|
+
export type EslintConfigFn<T = undefined> = (options?: T) => Promise<Config[]>;
|
|
51
45
|
export type OptionsFiles = {
|
|
52
46
|
/**
|
|
53
47
|
* Override the `files` option to provide custom globs.
|
|
@@ -83,6 +77,18 @@ export type OptionsTypeScriptWithTypes = {
|
|
|
83
77
|
* @see https://typescript-eslint.io/linting/typed-linting/
|
|
84
78
|
*/
|
|
85
79
|
tsconfig?: string | string[];
|
|
80
|
+
/**
|
|
81
|
+
* Override type aware rules.
|
|
82
|
+
*/
|
|
83
|
+
overridesTypeAware?: Config["rules"];
|
|
84
|
+
/**
|
|
85
|
+
* strict vs recommended configs
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
88
|
+
strict?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* typeAware
|
|
91
|
+
*/
|
|
86
92
|
typeAware?: boolean;
|
|
87
93
|
};
|
|
88
94
|
export type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
|
|
@@ -104,7 +110,7 @@ export type OptionsPrefix = {
|
|
|
104
110
|
};
|
|
105
111
|
};
|
|
106
112
|
export type OptionsOverrides = {
|
|
107
|
-
overrides?:
|
|
113
|
+
overrides?: Config["rules"];
|
|
108
114
|
};
|
|
109
115
|
export type OptionsIsInEditor = {
|
|
110
116
|
isInEditor?: boolean;
|
|
@@ -176,7 +182,7 @@ export type OptionsConfig = {
|
|
|
176
182
|
/**
|
|
177
183
|
* Optional function to run before the final config is returned.
|
|
178
184
|
*/
|
|
179
|
-
preReturn?: (configs:
|
|
185
|
+
preReturn?: (configs: Config[]) => Config[] | Awaitable<Config[]>;
|
|
180
186
|
/**
|
|
181
187
|
* Enable gitignore support.
|
|
182
188
|
*
|
|
@@ -189,9 +195,11 @@ export type OptionsConfig = {
|
|
|
189
195
|
tsPrefix?: string;
|
|
190
196
|
/**
|
|
191
197
|
* Glob patterns for ADDITIONAL tsconfig files to lint (aka sort)
|
|
198
|
+
*
|
|
199
|
+
* Has nothing to do with `@typescript-eslint/parser` or `typescript-eslint/eslint-plugin`
|
|
200
|
+
* @default ['tsconfig.json', 'tsconfig.*.json']
|
|
192
201
|
*/
|
|
193
202
|
extendTsconfigLintGlobs?: string[];
|
|
194
|
-
typeAware?: boolean;
|
|
195
203
|
/**
|
|
196
204
|
* Enable TypeScript support.
|
|
197
205
|
*
|
|
@@ -200,6 +208,10 @@ export type OptionsConfig = {
|
|
|
200
208
|
* @default auto-detect based on the dependencies
|
|
201
209
|
*/
|
|
202
210
|
typescript?: boolean | OptionsTypeScriptWithTypes;
|
|
211
|
+
/**
|
|
212
|
+
* Forcibly disable type aware rules
|
|
213
|
+
*/
|
|
214
|
+
typeAware?: boolean;
|
|
203
215
|
react?: boolean;
|
|
204
216
|
reactRefresh?: boolean;
|
|
205
217
|
/**
|
|
@@ -249,12 +261,12 @@ export type OptionsConfig = {
|
|
|
249
261
|
* Provide overrides for rules for each integration.
|
|
250
262
|
*/
|
|
251
263
|
overrides?: {
|
|
252
|
-
javascript?:
|
|
253
|
-
typescript?:
|
|
254
|
-
test?:
|
|
255
|
-
jsonc?:
|
|
256
|
-
markdown?:
|
|
257
|
-
yaml?:
|
|
264
|
+
javascript?: Config["rules"];
|
|
265
|
+
typescript?: Config["rules"];
|
|
266
|
+
test?: Config["rules"];
|
|
267
|
+
jsonc?: Config["rules"];
|
|
268
|
+
markdown?: Config["rules"];
|
|
269
|
+
yaml?: Config["rules"];
|
|
258
270
|
};
|
|
259
271
|
} & OptionsComponentExts & OptionsTypeScriptParserOptions;
|
|
260
272
|
export type RenamePefix<T extends Record<string, unknown>, FromPref extends string, ToPref extends string> = {
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import type { Awaitable,
|
|
2
|
+
import type { Awaitable, Config } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Combine array and non-array configs into a single array.
|
|
5
5
|
*/
|
|
6
|
-
export declare function combine(...configs: Awaitable<
|
|
6
|
+
export declare function combine(...configs: Awaitable<Config | Config[]>[]): Promise<Config[]>;
|
|
7
7
|
/**
|
|
8
8
|
* Combine array and non-array configs into a single array.
|
|
9
9
|
*/
|
|
@@ -45,7 +45,7 @@ export declare const parserPlain: {
|
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
|
-
export declare function turnOffRules(configs:
|
|
48
|
+
export declare function turnOffRules(configs: Config[], off: string[]): Config[];
|
|
49
49
|
export declare function changeRuleEntrySeverity(ruleConfig: Linter.RuleEntry<any>, level: Linter.RuleSeverity): Linter.RuleEntry<any>;
|
|
50
|
-
export declare function error2warn<T extends
|
|
51
|
-
export declare function warn2error<T extends
|
|
50
|
+
export declare function error2warn<T extends Config>(configs: T[]): T[];
|
|
51
|
+
export declare function warn2error<T extends Config>(configs: T[]): T[];
|
package/dist/esm/utils.js
CHANGED