@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/CHANGELOG.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/cli.ts
|
|
2
|
-
import fs from "
|
|
3
|
-
import process2 from "
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import process2 from "process";
|
|
4
4
|
|
|
5
5
|
// node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
6
6
|
import { EventEmitter } from "events";
|
|
@@ -588,7 +588,7 @@ var CAC = class extends EventEmitter {
|
|
|
588
588
|
var cac = (name = "") => new CAC(name);
|
|
589
589
|
|
|
590
590
|
// src/generated/version.ts
|
|
591
|
-
var VERSION = "0.
|
|
591
|
+
var VERSION = "0.4.0";
|
|
592
592
|
|
|
593
593
|
// src/cli.ts
|
|
594
594
|
var cli = cac("jsselint");
|
package/dist/esm/config-fns.d.ts
CHANGED
|
@@ -1,40 +1,116 @@
|
|
|
1
1
|
import { reactHooks } from "./configs/react.js";
|
|
2
|
-
export declare
|
|
3
|
-
antfu:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
export declare const CONFIGS_MAPPING: {
|
|
3
|
+
antfu: {
|
|
4
|
+
fn: import("./types.js").EslintConfigFn<{
|
|
5
|
+
topLevelFunction: "error" | "off";
|
|
6
|
+
}>;
|
|
7
|
+
typeName: string;
|
|
8
|
+
};
|
|
9
|
+
command: {
|
|
10
|
+
fn: import("./types.js").EslintConfigFn;
|
|
11
|
+
typeName: string;
|
|
12
|
+
};
|
|
13
|
+
"de-morgan": {
|
|
14
|
+
fn: import("./types.js").EslintConfigFn;
|
|
15
|
+
typeName: string;
|
|
16
|
+
};
|
|
17
|
+
"eslint-comments": {
|
|
18
|
+
fn: import("./types.js").EslintConfigFn;
|
|
19
|
+
typeName: string;
|
|
20
|
+
};
|
|
21
|
+
ignores: {
|
|
22
|
+
fn: import("./types.js").EslintConfigFn;
|
|
23
|
+
typeName: string;
|
|
24
|
+
};
|
|
25
|
+
imports: {
|
|
26
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsStylistic>;
|
|
27
|
+
typeName: string;
|
|
28
|
+
};
|
|
29
|
+
javascript: {
|
|
30
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides & {
|
|
31
|
+
reportUnusedDisableDirectives?: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
typeName: string;
|
|
34
|
+
};
|
|
35
|
+
jsdoc: {
|
|
36
|
+
fn: import("./types.js").EslintConfigFn;
|
|
37
|
+
typeName: string;
|
|
38
|
+
};
|
|
39
|
+
jsonc: {
|
|
40
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsStylistic & import("./types.js").OptionsOverrides>;
|
|
41
|
+
typeName: string;
|
|
42
|
+
};
|
|
43
|
+
markdown: {
|
|
44
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides>;
|
|
45
|
+
typeName: string;
|
|
46
|
+
};
|
|
47
|
+
n: {
|
|
48
|
+
fn: import("./types.js").EslintConfigFn;
|
|
49
|
+
typeName: string;
|
|
50
|
+
};
|
|
51
|
+
"no-only-tests": {
|
|
52
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides>;
|
|
53
|
+
typeName: string;
|
|
54
|
+
};
|
|
55
|
+
perfectionist: {
|
|
56
|
+
fn: import("./types.js").EslintConfigFn;
|
|
57
|
+
typeName: string;
|
|
58
|
+
};
|
|
59
|
+
prettier: {
|
|
60
|
+
fn: import("./types.js").EslintConfigFn;
|
|
61
|
+
typeName: string;
|
|
62
|
+
};
|
|
63
|
+
react: {
|
|
64
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides & import("./types.js").OptionsTypeScriptWithTypes & import("./types.js").OptionsTypeScriptParserOptions & import("./types.js").OptionsReact>;
|
|
65
|
+
typeName: string;
|
|
66
|
+
};
|
|
67
|
+
"react-hooks": {
|
|
68
|
+
fn: typeof reactHooks;
|
|
69
|
+
typeName: string;
|
|
70
|
+
};
|
|
71
|
+
"sort-package-json": {
|
|
72
|
+
fn: import("./types.js").EslintConfigFn;
|
|
73
|
+
typeName: string;
|
|
74
|
+
};
|
|
75
|
+
"sort-tsconfig": {
|
|
76
|
+
fn: import("./types.js").EslintConfigFn<{
|
|
77
|
+
extendTsconfigGlobs?: string[];
|
|
78
|
+
}>;
|
|
79
|
+
typeName: string;
|
|
80
|
+
};
|
|
81
|
+
stylistic: {
|
|
82
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").StylisticConfig>;
|
|
83
|
+
typeName: string;
|
|
84
|
+
};
|
|
85
|
+
toml: {
|
|
86
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsOverrides & import("./types.js").OptionsFiles & import("./types.js").OptionsStylistic>;
|
|
87
|
+
typeName: string;
|
|
88
|
+
};
|
|
89
|
+
tsdoc: {
|
|
90
|
+
fn: import("./types.js").EslintConfigFn;
|
|
91
|
+
typeName: string;
|
|
92
|
+
};
|
|
93
|
+
typescript: {
|
|
94
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides & import("./types.js").OptionsTypeScriptWithTypes & import("./types.js").OptionsTypeScriptParserOptions & import("./types.js").OptionsReact & import("./types.js").OptionsPrefix>;
|
|
95
|
+
typeName: string;
|
|
96
|
+
};
|
|
97
|
+
unicorn: {
|
|
98
|
+
fn: import("./types.js").EslintConfigFn;
|
|
99
|
+
typeName: string;
|
|
100
|
+
};
|
|
101
|
+
vitest: {
|
|
102
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides>;
|
|
103
|
+
typeName: string;
|
|
104
|
+
};
|
|
105
|
+
yml: {
|
|
106
|
+
fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsOverrides & import("./types.js").OptionsStylistic & import("./types.js").OptionsFiles>;
|
|
107
|
+
typeName: string;
|
|
108
|
+
};
|
|
34
109
|
};
|
|
35
110
|
export { antfu } from "./configs/antfu.js";
|
|
36
111
|
export { command } from "./configs/command.js";
|
|
37
|
-
export {
|
|
112
|
+
export { deMorgan } from "./configs/de-morgan.js";
|
|
113
|
+
export { eslintComments } from "./configs/eslint-comments.js";
|
|
38
114
|
export { ignores } from "./configs/ignores.js";
|
|
39
115
|
export { imports } from "./configs/imports.js";
|
|
40
116
|
export { javascript } from "./configs/javascript.js";
|
|
@@ -49,7 +125,6 @@ export { react, reactHooks } from "./configs/react.js";
|
|
|
49
125
|
export { sortPackageJson } from "./configs/sort-package-json.js";
|
|
50
126
|
export { sortTsconfig } from "./configs/sort-tsconfig.js";
|
|
51
127
|
export { stylistic } from "./configs/stylistic.js";
|
|
52
|
-
export { tailwind } from "./configs/tailwind.js";
|
|
53
128
|
export { toml } from "./configs/toml.js";
|
|
54
129
|
export { typescript } from "./configs/ts/typescript.js";
|
|
55
130
|
export { tsdoc } from "./configs/tsdoc.js";
|
package/dist/esm/config-fns.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { antfu } from "./configs/antfu.js";
|
|
2
2
|
import { command } from "./configs/command.js";
|
|
3
|
-
import {
|
|
3
|
+
import { deMorgan } from "./configs/de-morgan.js";
|
|
4
|
+
import { eslintComments } from "./configs/eslint-comments.js";
|
|
4
5
|
import { ignores } from "./configs/ignores.js";
|
|
5
6
|
import { imports } from "./configs/imports.js";
|
|
6
7
|
import { javascript } from "./configs/javascript.js";
|
|
@@ -15,47 +16,123 @@ import { react, reactHooks } from "./configs/react.js";
|
|
|
15
16
|
import { sortPackageJson } from "./configs/sort-package-json.js";
|
|
16
17
|
import { sortTsconfig } from "./configs/sort-tsconfig.js";
|
|
17
18
|
import { stylistic } from "./configs/stylistic.js";
|
|
18
|
-
import { tailwind } from "./configs/tailwind.js";
|
|
19
19
|
import { toml } from "./configs/toml.js";
|
|
20
20
|
import { typescript } from "./configs/ts/typescript.js";
|
|
21
21
|
import { tsdoc } from "./configs/tsdoc.js";
|
|
22
22
|
import { unicorn } from "./configs/unicorn.js";
|
|
23
23
|
import { vitest } from "./configs/vitest.js";
|
|
24
24
|
import { yml } from "./configs/yml.js";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
25
|
+
export const CONFIGS_MAPPING = {
|
|
26
|
+
antfu: {
|
|
27
|
+
fn: antfu,
|
|
28
|
+
typeName: "AntfuRuleOptions",
|
|
29
|
+
},
|
|
30
|
+
command: {
|
|
31
|
+
fn: command,
|
|
32
|
+
typeName: "CommandRuleOptions",
|
|
33
|
+
},
|
|
34
|
+
"de-morgan": {
|
|
35
|
+
fn: deMorgan,
|
|
36
|
+
typeName: "DeMorganRuleOptions",
|
|
37
|
+
},
|
|
38
|
+
"eslint-comments": {
|
|
39
|
+
fn: eslintComments,
|
|
40
|
+
typeName: "EslintCommentsRuleOptions",
|
|
41
|
+
},
|
|
42
|
+
ignores: {
|
|
43
|
+
fn: ignores,
|
|
44
|
+
typeName: "IgnoresRuleOptions",
|
|
45
|
+
},
|
|
46
|
+
imports: {
|
|
47
|
+
fn: imports,
|
|
48
|
+
typeName: "ImportsRuleOptions",
|
|
49
|
+
},
|
|
50
|
+
javascript: {
|
|
51
|
+
fn: javascript,
|
|
52
|
+
typeName: "JavascriptRuleOptions",
|
|
53
|
+
},
|
|
54
|
+
jsdoc: {
|
|
55
|
+
fn: jsdoc,
|
|
56
|
+
typeName: "JsdocRuleOptions",
|
|
57
|
+
},
|
|
58
|
+
jsonc: {
|
|
59
|
+
fn: jsonc,
|
|
60
|
+
typeName: "JsoncRuleOptions",
|
|
61
|
+
},
|
|
62
|
+
markdown: {
|
|
63
|
+
fn: markdown,
|
|
64
|
+
typeName: "MarkdownRuleOptions",
|
|
65
|
+
},
|
|
66
|
+
n: {
|
|
67
|
+
fn: n,
|
|
68
|
+
typeName: "NRuleOptions",
|
|
69
|
+
},
|
|
70
|
+
"no-only-tests": {
|
|
71
|
+
fn: noOnlyTests,
|
|
72
|
+
typeName: "NoOnlyTestsRuleOptions",
|
|
73
|
+
},
|
|
74
|
+
perfectionist: {
|
|
75
|
+
fn: perfectionist,
|
|
76
|
+
typeName: "PerfectionistRuleOptions",
|
|
77
|
+
},
|
|
78
|
+
prettier: {
|
|
79
|
+
fn: prettier,
|
|
80
|
+
typeName: "PrettierRuleOptions",
|
|
81
|
+
},
|
|
82
|
+
react: {
|
|
83
|
+
fn: react,
|
|
84
|
+
typeName: "ReactRuleOptions",
|
|
85
|
+
},
|
|
86
|
+
"react-hooks": {
|
|
87
|
+
fn: reactHooks,
|
|
88
|
+
typeName: "ReactHooksRuleOptions",
|
|
89
|
+
},
|
|
90
|
+
"sort-package-json": {
|
|
91
|
+
fn: sortPackageJson,
|
|
92
|
+
typeName: "SortPackageJsonRuleOptions",
|
|
93
|
+
},
|
|
94
|
+
"sort-tsconfig": {
|
|
95
|
+
fn: sortTsconfig,
|
|
96
|
+
typeName: "SortTsconfigRuleOptions",
|
|
97
|
+
},
|
|
98
|
+
stylistic: {
|
|
99
|
+
fn: stylistic,
|
|
100
|
+
typeName: "StylisticRuleOptions",
|
|
101
|
+
},
|
|
102
|
+
toml: {
|
|
103
|
+
fn: toml,
|
|
104
|
+
typeName: "TomlRuleOptions",
|
|
105
|
+
},
|
|
106
|
+
tsdoc: {
|
|
107
|
+
fn: tsdoc,
|
|
108
|
+
typeName: "TsdocRuleOptions",
|
|
109
|
+
},
|
|
110
|
+
// deprecated
|
|
111
|
+
// tailwind: {
|
|
112
|
+
// typeName: "TailwindRuleOptions",
|
|
113
|
+
// fn: tailwind,
|
|
114
|
+
// },
|
|
115
|
+
typescript: {
|
|
116
|
+
fn: typescript,
|
|
117
|
+
typeName: "TypescriptRuleOptions",
|
|
118
|
+
},
|
|
119
|
+
unicorn: {
|
|
120
|
+
fn: unicorn,
|
|
121
|
+
typeName: "UnicornRuleOptions",
|
|
122
|
+
},
|
|
123
|
+
vitest: {
|
|
124
|
+
fn: vitest,
|
|
125
|
+
typeName: "VitestRuleOptions",
|
|
126
|
+
},
|
|
127
|
+
yml: {
|
|
128
|
+
fn: yml,
|
|
129
|
+
typeName: "YmlRuleOptions",
|
|
130
|
+
},
|
|
131
|
+
};
|
|
56
132
|
export { antfu } from "./configs/antfu.js";
|
|
57
133
|
export { command } from "./configs/command.js";
|
|
58
|
-
export {
|
|
134
|
+
export { deMorgan } from "./configs/de-morgan.js";
|
|
135
|
+
export { eslintComments } from "./configs/eslint-comments.js";
|
|
59
136
|
export { ignores } from "./configs/ignores.js";
|
|
60
137
|
export { imports } from "./configs/imports.js";
|
|
61
138
|
export { javascript } from "./configs/javascript.js";
|
|
@@ -70,7 +147,6 @@ export { react, reactHooks } from "./configs/react.js";
|
|
|
70
147
|
export { sortPackageJson } from "./configs/sort-package-json.js";
|
|
71
148
|
export { sortTsconfig } from "./configs/sort-tsconfig.js";
|
|
72
149
|
export { stylistic } from "./configs/stylistic.js";
|
|
73
|
-
export { tailwind } from "./configs/tailwind.js";
|
|
74
150
|
export { toml } from "./configs/toml.js";
|
|
75
151
|
export { typescript } from "./configs/ts/typescript.js";
|
|
76
152
|
export { tsdoc } from "./configs/tsdoc.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { EslintConfigFn } from "../types.js";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const deMorgan: EslintConfigFn;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function gql():
|
|
1
|
+
import type { Config } from "src/types.js";
|
|
2
|
+
export declare function gql(): Config[];
|
|
@@ -18,7 +18,7 @@ export const markdown = async (options) => {
|
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
19
|
pluginMarkdown.processors.markdown,
|
|
20
20
|
processorPassThrough,
|
|
21
|
-
]
|
|
21
|
+
]);
|
|
22
22
|
return [
|
|
23
23
|
{
|
|
24
24
|
name: "jsse/markdown/setup",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config, EslintConfigFn } from "../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Copied from https://raw.githubusercontent.com/prettier/eslint-config-prettier/main/index.js
|
|
4
4
|
* Main difference is we exclude rules we don't care about.... (flow/babel/etc)
|
|
5
5
|
*/
|
|
6
|
-
export declare function eslintConfigPrettierRules():
|
|
6
|
+
export declare function eslintConfigPrettierRules(): Config["rules"];
|
|
7
7
|
export declare const prettier: EslintConfigFn;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EslintConfigFn, OptionsComponentExts, OptionsOverrides, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes
|
|
2
|
-
export declare function reactRules():
|
|
3
|
-
export declare function reactHooks(): Promise<
|
|
1
|
+
import type { Config, EslintConfigFn, OptionsComponentExts, OptionsOverrides, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from "../types.js";
|
|
2
|
+
export declare function reactRules(): Config["rules"];
|
|
3
|
+
export declare function reactHooks(): Promise<Config[]>;
|
|
4
4
|
type ReactOptions = OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsReact;
|
|
5
5
|
export declare const react: EslintConfigFn<ReactOptions>;
|
|
6
6
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { OptionsComponentExts, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes
|
|
1
|
+
import type { Config, OptionsComponentExts, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from "../../types.js";
|
|
2
2
|
export type TsParserOptions = OptionsComponentExts & OptionsTypeScriptParserOptions & OptionsTypeScriptWithTypes & OptionsReact & {
|
|
3
3
|
name?: string;
|
|
4
4
|
};
|
|
5
|
-
export declare function typescriptParser(options: TsParserOptions):
|
|
5
|
+
export declare function typescriptParser(options: TsParserOptions): Config & {
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import {
|
|
2
|
+
import { dbg } from "src/lager.js";
|
|
3
3
|
import { GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from "../../globs.js";
|
|
4
4
|
import { parserTs } from "../../plugins.js";
|
|
5
5
|
function autoUseParserService(options) {
|
|
@@ -17,12 +17,13 @@ export function typescriptParser(options) {
|
|
|
17
17
|
const { componentExts = [], filesTypeAware: files = [GLOB_TS, GLOB_TSX], ignoresTypeAware: ignores = [GLOB_MARKDOWN], name, parserOptions: parserOptionsOverride = {}, react, tsconfig, useProjectService = autoUseParserService(options), } = options;
|
|
18
18
|
const typeAware = !!tsconfig;
|
|
19
19
|
if (useProjectService) {
|
|
20
|
-
|
|
20
|
+
dbg("ts parser-options using `projectService`project service");
|
|
21
21
|
return {
|
|
22
22
|
files,
|
|
23
|
-
...(ignores ? { ignores } : {}),
|
|
23
|
+
...(ignores.length > 0 ? { ignores } : {}),
|
|
24
24
|
languageOptions: {
|
|
25
25
|
parser: parserTs,
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
26
27
|
parserOptions: {
|
|
27
28
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
28
29
|
jsxPragma: react ? "React" : undefined,
|
|
@@ -44,12 +45,13 @@ export function typescriptParser(options) {
|
|
|
44
45
|
name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`,
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
dbg("ts parser-options NOT using `projectService`project service - using `project`");
|
|
48
49
|
return {
|
|
49
50
|
files,
|
|
50
|
-
...(ignores ? { ignores } : {}),
|
|
51
|
+
...(ignores.length > 0 ? { ignores } : {}),
|
|
51
52
|
languageOptions: {
|
|
52
53
|
parser: parserTs,
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
53
55
|
parserOptions: {
|
|
54
56
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
55
57
|
jsxPragma: react ? "React" : undefined,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function typescriptRulesTypeAware(
|
|
3
|
-
|
|
1
|
+
import type { Config } from "../../types.js";
|
|
2
|
+
export declare function typescriptRulesTypeAware(props?: {
|
|
3
|
+
strict?: boolean;
|
|
4
|
+
}): Config["rules"];
|
|
5
|
+
export declare function typescriptRulesTypeOblivious(props?: {
|
|
6
|
+
strict?: boolean;
|
|
7
|
+
}): Config["rules"];
|
|
4
8
|
export declare function typescriptRules(props?: {
|
|
5
9
|
typeAware: boolean;
|
|
6
|
-
|
|
10
|
+
strict: boolean;
|
|
11
|
+
}): Config["rules"];
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
2
|
+
import tseslint, {} from "typescript-eslint";
|
|
3
|
+
import { dbg } from "../../lager.js";
|
|
4
|
+
const extractRules = (configs) => {
|
|
5
|
+
const rules = configs
|
|
6
|
+
.filter((config) => config.rules !== undefined)
|
|
7
|
+
.map((config) => config.rules ?? {});
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
9
|
+
return Object.assign({}, ...rules);
|
|
10
|
+
};
|
|
11
|
+
export function typescriptRulesTypeAware(props) {
|
|
12
|
+
const tsRecomendedRulesTypeChecked = props?.strict
|
|
13
|
+
? extractRules(tseslint.configs.strictTypeChecked)
|
|
14
|
+
: extractRules(tseslint.configs.recommendedTypeChecked);
|
|
2
15
|
return {
|
|
16
|
+
...tsRecomendedRulesTypeChecked,
|
|
3
17
|
"@typescript-eslint/await-thenable": "error",
|
|
4
18
|
"@typescript-eslint/no-for-in-array": "error",
|
|
5
19
|
"no-implied-eval": "off",
|
|
@@ -116,8 +130,12 @@ export function typescriptRulesTypeAware() {
|
|
|
116
130
|
],
|
|
117
131
|
};
|
|
118
132
|
}
|
|
119
|
-
export function typescriptRulesTypeOblivious() {
|
|
133
|
+
export function typescriptRulesTypeOblivious(props) {
|
|
134
|
+
const tseslintBaseRules = props?.strict
|
|
135
|
+
? extractRules(tseslint.configs.strict)
|
|
136
|
+
: extractRules(tseslint.configs.recommended);
|
|
120
137
|
return {
|
|
138
|
+
...tseslintBaseRules,
|
|
121
139
|
eqeqeq: "error",
|
|
122
140
|
camelcase: "off",
|
|
123
141
|
yoda: "error",
|
|
@@ -140,61 +158,6 @@ export function typescriptRulesTypeOblivious() {
|
|
|
140
158
|
},
|
|
141
159
|
],
|
|
142
160
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
143
|
-
// "@typescript-eslint/ban-types": [
|
|
144
|
-
// "warn",
|
|
145
|
-
// {
|
|
146
|
-
// extendDefaults: false,
|
|
147
|
-
// types: {
|
|
148
|
-
// String: {
|
|
149
|
-
// message: 'Use "string" instead',
|
|
150
|
-
// fixWith: "string",
|
|
151
|
-
// },
|
|
152
|
-
// Boolean: {
|
|
153
|
-
// message: 'Use "boolean" instead',
|
|
154
|
-
// fixWith: "boolean",
|
|
155
|
-
// },
|
|
156
|
-
// Number: {
|
|
157
|
-
// message: 'Use "number" instead',
|
|
158
|
-
// fixWith: "number",
|
|
159
|
-
// },
|
|
160
|
-
// BigInt: {
|
|
161
|
-
// message: "Use `bigint` instead.",
|
|
162
|
-
// fixWith: "bigint",
|
|
163
|
-
// },
|
|
164
|
-
// Object: {
|
|
165
|
-
// message:
|
|
166
|
-
// "The `Object` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
|
|
167
|
-
// fixWith: "Record<string, unknown>",
|
|
168
|
-
// },
|
|
169
|
-
// object: {
|
|
170
|
-
// message:
|
|
171
|
-
// "The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
|
|
172
|
-
// fixWith: "Record<string, unknown>",
|
|
173
|
-
// },
|
|
174
|
-
// Symbol: {
|
|
175
|
-
// message: 'Use "symbol" instead',
|
|
176
|
-
// fixWith: "symbol",
|
|
177
|
-
// },
|
|
178
|
-
// Function: {
|
|
179
|
-
// message:
|
|
180
|
-
// 'The "Function" type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with "new".\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.',
|
|
181
|
-
// },
|
|
182
|
-
// // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
183
|
-
// "{}": {
|
|
184
|
-
// message:
|
|
185
|
-
// "The `{}` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead.",
|
|
186
|
-
// fixWith: "Record<string, unknown>",
|
|
187
|
-
// },
|
|
188
|
-
// // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
189
|
-
// "[]": "Don't use the empty array type `[]`. It only allows empty arrays. Use `SomeType[]` instead.",
|
|
190
|
-
// // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
191
|
-
// "[[]]":
|
|
192
|
-
// "Don't use `[[]]`. It only allows an array with a single element which is an empty array. Use `SomeType[][]` instead.",
|
|
193
|
-
// // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
194
|
-
// "[[[]]]": "Don't use `[[[]]]`. Use `SomeType[][][]` instead.",
|
|
195
|
-
// },
|
|
196
|
-
// },
|
|
197
|
-
// ],
|
|
198
161
|
"@typescript-eslint/consistent-type-assertions": "error",
|
|
199
162
|
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
200
163
|
"@typescript-eslint/member-ordering": [
|
|
@@ -404,12 +367,13 @@ export function typescriptRulesTypeOblivious() {
|
|
|
404
367
|
};
|
|
405
368
|
}
|
|
406
369
|
export function typescriptRules(props) {
|
|
407
|
-
const { typeAware
|
|
408
|
-
|
|
370
|
+
const normalized = { typeAware: false, strict: false, ...props };
|
|
371
|
+
dbg("building typescript rules: %O", normalized);
|
|
372
|
+
if (normalized.typeAware) {
|
|
409
373
|
return {
|
|
410
|
-
...typescriptRulesTypeOblivious(),
|
|
411
|
-
...typescriptRulesTypeAware(),
|
|
374
|
+
...typescriptRulesTypeOblivious({ strict: normalized.strict }),
|
|
375
|
+
...typescriptRulesTypeAware({ strict: normalized.strict }),
|
|
412
376
|
};
|
|
413
377
|
}
|
|
414
|
-
return typescriptRulesTypeOblivious();
|
|
378
|
+
return typescriptRulesTypeOblivious({ strict: normalized.strict });
|
|
415
379
|
}
|