@so1ve/eslint-config 3.8.1 → 3.9.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/index.d.ts +450 -285
- package/dist/index.js +294 -253
- package/package.json +30 -29
package/dist/index.js
CHANGED
|
@@ -16,22 +16,6 @@ import fs from "node:fs";
|
|
|
16
16
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
17
17
|
import { isPackageExists } from "local-pkg";
|
|
18
18
|
|
|
19
|
-
//#region src/configs/comments.ts
|
|
20
|
-
const comments = () => [{
|
|
21
|
-
name: "so1ve/comments/setup",
|
|
22
|
-
plugins: { "eslint-comments": pluginComments }
|
|
23
|
-
}, {
|
|
24
|
-
name: "so1ve/comments/rules",
|
|
25
|
-
rules: {
|
|
26
|
-
"eslint-comments/no-aggregating-enable": "error",
|
|
27
|
-
"eslint-comments/no-duplicate-disable": "error",
|
|
28
|
-
"eslint-comments/no-unused-enable": "error",
|
|
29
|
-
"eslint-comments/disable-enable-pair": "off",
|
|
30
|
-
"eslint-comments/no-unlimited-disable": "off"
|
|
31
|
-
}
|
|
32
|
-
}];
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
19
|
//#region src/globs.ts
|
|
36
20
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
37
21
|
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
@@ -49,6 +33,8 @@ const GLOB_JSON5 = "**/*.json5";
|
|
|
49
33
|
const GLOB_JSONC = "**/*.jsonc";
|
|
50
34
|
const GLOB_ESLINTRC = "**/.eslintrc";
|
|
51
35
|
const GLOB_MARKDOWN = "**/*.md?(x)";
|
|
36
|
+
const GLOB_ASTRO = "**/*.astro";
|
|
37
|
+
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
52
38
|
const GLOB_VUE = "**/*.vue";
|
|
53
39
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
54
40
|
const GLOB_TOML = "**/*.toml";
|
|
@@ -139,14 +125,70 @@ async function interopDefault(m) {
|
|
|
139
125
|
return resolved.default ?? resolved;
|
|
140
126
|
}
|
|
141
127
|
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/configs/astro.ts
|
|
130
|
+
async function astro({ overrides = {} } = {}) {
|
|
131
|
+
const [pluginAstro, parserAstro, parserTs] = await Promise.all([
|
|
132
|
+
interopDefault(import("eslint-plugin-astro")),
|
|
133
|
+
interopDefault(import("astro-eslint-parser")),
|
|
134
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
135
|
+
]);
|
|
136
|
+
return [{
|
|
137
|
+
name: "antfu/astro/setup",
|
|
138
|
+
plugins: { astro: pluginAstro }
|
|
139
|
+
}, {
|
|
140
|
+
files: [GLOB_ASTRO],
|
|
141
|
+
languageOptions: {
|
|
142
|
+
globals: pluginAstro.environments.astro.globals,
|
|
143
|
+
parser: parserAstro,
|
|
144
|
+
parserOptions: {
|
|
145
|
+
extraFileExtensions: [".astro"],
|
|
146
|
+
parser: parserTs
|
|
147
|
+
},
|
|
148
|
+
sourceType: "module"
|
|
149
|
+
},
|
|
150
|
+
name: "antfu/astro/rules",
|
|
151
|
+
processor: "astro/client-side-ts",
|
|
152
|
+
rules: {
|
|
153
|
+
"antfu/no-top-level-await": "off",
|
|
154
|
+
"astro/missing-client-only-directive-value": "error",
|
|
155
|
+
"astro/no-conflict-set-directives": "error",
|
|
156
|
+
"astro/no-deprecated-astro-canonicalurl": "error",
|
|
157
|
+
"astro/no-deprecated-astro-fetchcontent": "error",
|
|
158
|
+
"astro/no-deprecated-astro-resolve": "error",
|
|
159
|
+
"astro/no-deprecated-getentrybyslug": "error",
|
|
160
|
+
"astro/no-set-html-directive": "off",
|
|
161
|
+
"astro/no-unused-define-vars-in-style": "error",
|
|
162
|
+
"astro/semi": "off",
|
|
163
|
+
"astro/valid-compile": "error",
|
|
164
|
+
...overrides
|
|
165
|
+
}
|
|
166
|
+
}];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/configs/comments.ts
|
|
171
|
+
const comments = () => [{
|
|
172
|
+
name: "so1ve/comments/setup",
|
|
173
|
+
plugins: { "eslint-comments": pluginComments }
|
|
174
|
+
}, {
|
|
175
|
+
name: "so1ve/comments/rules",
|
|
176
|
+
rules: {
|
|
177
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
178
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
179
|
+
"eslint-comments/no-unused-enable": "error",
|
|
180
|
+
"eslint-comments/disable-enable-pair": "off",
|
|
181
|
+
"eslint-comments/no-unlimited-disable": "off"
|
|
182
|
+
}
|
|
183
|
+
}];
|
|
184
|
+
|
|
142
185
|
//#endregion
|
|
143
186
|
//#region src/configs/formatting.ts
|
|
144
187
|
async function formatting(options) {
|
|
145
|
-
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
146
188
|
return [
|
|
147
189
|
{
|
|
148
190
|
name: "so1ve/formatting/setup",
|
|
149
|
-
plugins: { style:
|
|
191
|
+
plugins: { style: await interopDefault(import("@stylistic/eslint-plugin")) }
|
|
150
192
|
},
|
|
151
193
|
{
|
|
152
194
|
name: "so1ve/formatting/rules",
|
|
@@ -979,242 +1021,239 @@ async function toml({ overrides } = {}) {
|
|
|
979
1021
|
|
|
980
1022
|
//#endregion
|
|
981
1023
|
//#region src/configs/typescript.ts
|
|
982
|
-
async
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
"ts/consistent-generic-constructors": "error",
|
|
1004
|
-
"ts/consistent-type-exports": "error",
|
|
1005
|
-
"ts/consistent-type-assertions": ["error", {
|
|
1006
|
-
assertionStyle: "as",
|
|
1007
|
-
objectLiteralTypeAssertions: "allow"
|
|
1008
|
-
}],
|
|
1009
|
-
"ts/prefer-nullish-coalescing": "error",
|
|
1010
|
-
"ts/prefer-optional-chain": "error",
|
|
1011
|
-
"ts/prefer-return-this-type": "error",
|
|
1012
|
-
"ts/no-unnecessary-type-arguments": "error",
|
|
1013
|
-
"ts/non-nullable-type-assertion-style": "error"
|
|
1014
|
-
};
|
|
1015
|
-
return [
|
|
1016
|
-
{
|
|
1017
|
-
name: "so1ve/typescript/setup",
|
|
1018
|
-
plugins: {
|
|
1019
|
-
import: pluginImport,
|
|
1020
|
-
ts: tseslint.plugin
|
|
1021
|
-
}
|
|
1022
|
-
},
|
|
1023
|
-
{
|
|
1024
|
-
name: "so1ve/typescript/rules",
|
|
1025
|
-
files: [
|
|
1026
|
-
GLOB_TS,
|
|
1027
|
-
GLOB_TSX,
|
|
1028
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1029
|
-
],
|
|
1030
|
-
languageOptions: {
|
|
1031
|
-
parser: tseslint.parser,
|
|
1032
|
-
parserOptions: {
|
|
1033
|
-
sourceType: "module",
|
|
1034
|
-
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1035
|
-
...parserOptions
|
|
1036
|
-
}
|
|
1037
|
-
},
|
|
1038
|
-
settings: { "import/resolver": {
|
|
1039
|
-
node: { extensions: [
|
|
1040
|
-
".js",
|
|
1041
|
-
".jsx",
|
|
1042
|
-
".mjs",
|
|
1043
|
-
".ts",
|
|
1044
|
-
".tsx",
|
|
1045
|
-
".d.ts"
|
|
1046
|
-
] },
|
|
1047
|
-
typescript: { extensions: [
|
|
1048
|
-
".js",
|
|
1049
|
-
".jsx",
|
|
1050
|
-
".mjs",
|
|
1051
|
-
".ts",
|
|
1052
|
-
".tsx",
|
|
1053
|
-
".d.ts"
|
|
1054
|
-
] }
|
|
1055
|
-
} },
|
|
1056
|
-
rules: {
|
|
1057
|
-
...renameRules(tseslint.configs.eslintRecommended.rules, { "@typescript-eslint": "ts" }),
|
|
1058
|
-
...renameRules(tseslint.configs.recommended.map((config) => config.rules).filter(Boolean).reduce((a, b) => ({
|
|
1059
|
-
...a,
|
|
1060
|
-
...b
|
|
1061
|
-
}), {}), { "@typescript-eslint": "ts" }),
|
|
1062
|
-
"import/named": "off",
|
|
1063
|
-
"ts/comma-dangle": "off",
|
|
1064
|
-
"ts/brace-style": "off",
|
|
1065
|
-
"ts/comma-spacing": "off",
|
|
1066
|
-
"ts/func-call-spacing": "off",
|
|
1067
|
-
"ts/indent": "off",
|
|
1068
|
-
"ts/keyword-spacing": "off",
|
|
1069
|
-
"ts/member-delimiter-style": "off",
|
|
1070
|
-
"ts/no-extra-parens": "off",
|
|
1071
|
-
"ts/no-extra-semi": "off",
|
|
1072
|
-
"ts/quotes": "off",
|
|
1073
|
-
"ts/semi": "off",
|
|
1074
|
-
"ts/space-before-function-paren": "off",
|
|
1075
|
-
"ts/type-annotation-spacing": "off",
|
|
1076
|
-
"ts/ban-ts-comment": ["error", { minimumDescriptionLength: 0 }],
|
|
1077
|
-
"ts/no-restricted-types": ["error", { types: {
|
|
1078
|
-
String: {
|
|
1079
|
-
message: "Use `string` instead.",
|
|
1080
|
-
fixWith: "string"
|
|
1081
|
-
},
|
|
1082
|
-
Number: {
|
|
1083
|
-
message: "Use `number` instead.",
|
|
1084
|
-
fixWith: "number"
|
|
1085
|
-
},
|
|
1086
|
-
Boolean: {
|
|
1087
|
-
message: "Use `boolean` instead.",
|
|
1088
|
-
fixWith: "boolean"
|
|
1089
|
-
},
|
|
1090
|
-
Symbol: {
|
|
1091
|
-
message: "Use `symbol` instead.",
|
|
1092
|
-
fixWith: "symbol"
|
|
1093
|
-
},
|
|
1094
|
-
BigInt: {
|
|
1095
|
-
message: "Use `bigint` instead.",
|
|
1096
|
-
fixWith: "bigint"
|
|
1097
|
-
},
|
|
1098
|
-
Object: {
|
|
1099
|
-
message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
|
|
1100
|
-
fixWith: "Record<PropertyKey, unknown>"
|
|
1101
|
-
},
|
|
1102
|
-
object: {
|
|
1103
|
-
message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
|
|
1104
|
-
fixWith: "Record<PropertyKey, unknown>"
|
|
1105
|
-
},
|
|
1106
|
-
Function: {
|
|
1107
|
-
message: "Use `(...args: any[]) => any` instead.",
|
|
1108
|
-
fixWith: "(...args: any[]) => any"
|
|
1109
|
-
}
|
|
1110
|
-
} }],
|
|
1111
|
-
"ts/no-unsafe-function-type": "error",
|
|
1112
|
-
"ts/no-wrapper-object-types": "error",
|
|
1113
|
-
"ts/consistent-type-imports": ["error", {
|
|
1114
|
-
prefer: "type-imports",
|
|
1115
|
-
disallowTypeAnnotations: false
|
|
1116
|
-
}],
|
|
1117
|
-
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1118
|
-
"ts/consistent-indexed-object-style": ["error", "record"],
|
|
1119
|
-
"ts/prefer-ts-expect-error": "error",
|
|
1120
|
-
"ts/prefer-for-of": "error",
|
|
1121
|
-
"ts/no-duplicate-enum-values": "error",
|
|
1122
|
-
"ts/no-non-null-asserted-nullish-coalescing": "error",
|
|
1123
|
-
"ts/no-require-imports": "error",
|
|
1124
|
-
"ts/method-signature-style": ["error", "property"],
|
|
1125
|
-
"ts/explicit-member-accessibility": ["error", {
|
|
1126
|
-
accessibility: "explicit",
|
|
1127
|
-
overrides: { constructors: "no-public" }
|
|
1128
|
-
}],
|
|
1129
|
-
"no-useless-constructor": "off",
|
|
1130
|
-
"no-invalid-this": "off",
|
|
1131
|
-
"ts/no-invalid-this": "error",
|
|
1132
|
-
"no-redeclare": "off",
|
|
1133
|
-
"ts/no-redeclare": "error",
|
|
1134
|
-
"no-use-before-define": "off",
|
|
1135
|
-
"ts/no-use-before-define": ["error", {
|
|
1136
|
-
functions: false,
|
|
1137
|
-
classes: false,
|
|
1138
|
-
variables: true
|
|
1139
|
-
}],
|
|
1140
|
-
"object-curly-spacing": "off",
|
|
1141
|
-
"space-before-blocks": "off",
|
|
1142
|
-
"ts/space-before-blocks": "off",
|
|
1143
|
-
"space-before-function-paren": "off",
|
|
1144
|
-
"no-dupe-class-members": "off",
|
|
1145
|
-
"ts/no-dupe-class-members": "error",
|
|
1146
|
-
"no-loss-of-precision": "off",
|
|
1147
|
-
"ts/no-loss-of-precision": "error",
|
|
1148
|
-
"so1ve/no-inline-type-import": "error",
|
|
1149
|
-
"ts/camelcase": "off",
|
|
1150
|
-
"ts/explicit-function-return-type": "off",
|
|
1151
|
-
"ts/no-explicit-any": "off",
|
|
1152
|
-
"ts/no-parameter-properties": "off",
|
|
1153
|
-
"ts/no-empty-interface": "off",
|
|
1154
|
-
"ts/ban-ts-ignore": "off",
|
|
1155
|
-
"ts/no-empty-function": "off",
|
|
1156
|
-
"ts/no-non-null-assertion": "off",
|
|
1157
|
-
"ts/explicit-module-boundary-types": "off",
|
|
1158
|
-
"ts/triple-slash-reference": "off",
|
|
1159
|
-
"ts/no-unused-vars": "off",
|
|
1160
|
-
...overrides
|
|
1024
|
+
const typescript = async ({ componentExts = [], parserOptions, overrides } = {}) => [
|
|
1025
|
+
{
|
|
1026
|
+
name: "so1ve/typescript/setup",
|
|
1027
|
+
plugins: {
|
|
1028
|
+
import: pluginImport,
|
|
1029
|
+
ts: tseslint.plugin
|
|
1030
|
+
}
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
name: "so1ve/typescript/rules",
|
|
1034
|
+
files: [
|
|
1035
|
+
GLOB_TS,
|
|
1036
|
+
GLOB_TSX,
|
|
1037
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1038
|
+
],
|
|
1039
|
+
languageOptions: {
|
|
1040
|
+
parser: tseslint.parser,
|
|
1041
|
+
parserOptions: {
|
|
1042
|
+
sourceType: "module",
|
|
1043
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1044
|
+
...parserOptions
|
|
1161
1045
|
}
|
|
1162
1046
|
},
|
|
1163
|
-
{
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1047
|
+
settings: { "import/resolver": {
|
|
1048
|
+
node: { extensions: [
|
|
1049
|
+
".js",
|
|
1050
|
+
".jsx",
|
|
1051
|
+
".mjs",
|
|
1052
|
+
".ts",
|
|
1053
|
+
".tsx",
|
|
1054
|
+
".d.ts"
|
|
1055
|
+
] },
|
|
1056
|
+
typescript: { extensions: [
|
|
1057
|
+
".js",
|
|
1058
|
+
".jsx",
|
|
1059
|
+
".mjs",
|
|
1060
|
+
".ts",
|
|
1061
|
+
".tsx",
|
|
1062
|
+
".d.ts"
|
|
1063
|
+
] }
|
|
1064
|
+
} },
|
|
1065
|
+
rules: {
|
|
1066
|
+
...renameRules(tseslint.configs.eslintRecommended.rules, { "@typescript-eslint": "ts" }),
|
|
1067
|
+
...renameRules(tseslint.configs.recommended.map((config) => config.rules).filter(Boolean).reduce((a, b) => ({
|
|
1068
|
+
...a,
|
|
1069
|
+
...b
|
|
1070
|
+
}), {}), { "@typescript-eslint": "ts" }),
|
|
1071
|
+
"import/named": "off",
|
|
1072
|
+
"ts/comma-dangle": "off",
|
|
1073
|
+
"ts/brace-style": "off",
|
|
1074
|
+
"ts/comma-spacing": "off",
|
|
1075
|
+
"ts/func-call-spacing": "off",
|
|
1076
|
+
"ts/indent": "off",
|
|
1077
|
+
"ts/keyword-spacing": "off",
|
|
1078
|
+
"ts/member-delimiter-style": "off",
|
|
1079
|
+
"ts/no-extra-parens": "off",
|
|
1080
|
+
"ts/no-extra-semi": "off",
|
|
1081
|
+
"ts/quotes": "off",
|
|
1082
|
+
"ts/semi": "off",
|
|
1083
|
+
"ts/space-before-function-paren": "off",
|
|
1084
|
+
"ts/type-annotation-spacing": "off",
|
|
1085
|
+
"ts/ban-ts-comment": ["error", { minimumDescriptionLength: 0 }],
|
|
1086
|
+
"ts/no-restricted-types": ["error", { types: {
|
|
1087
|
+
String: {
|
|
1088
|
+
message: "Use `string` instead.",
|
|
1089
|
+
fixWith: "string"
|
|
1090
|
+
},
|
|
1091
|
+
Number: {
|
|
1092
|
+
message: "Use `number` instead.",
|
|
1093
|
+
fixWith: "number"
|
|
1094
|
+
},
|
|
1095
|
+
Boolean: {
|
|
1096
|
+
message: "Use `boolean` instead.",
|
|
1097
|
+
fixWith: "boolean"
|
|
1098
|
+
},
|
|
1099
|
+
Symbol: {
|
|
1100
|
+
message: "Use `symbol` instead.",
|
|
1101
|
+
fixWith: "symbol"
|
|
1102
|
+
},
|
|
1103
|
+
BigInt: {
|
|
1104
|
+
message: "Use `bigint` instead.",
|
|
1105
|
+
fixWith: "bigint"
|
|
1106
|
+
},
|
|
1107
|
+
Object: {
|
|
1108
|
+
message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
|
|
1109
|
+
fixWith: "Record<PropertyKey, unknown>"
|
|
1110
|
+
},
|
|
1111
|
+
object: {
|
|
1112
|
+
message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
|
|
1113
|
+
fixWith: "Record<PropertyKey, unknown>"
|
|
1114
|
+
},
|
|
1115
|
+
Function: {
|
|
1116
|
+
message: "Use `(...args: any[]) => any` instead.",
|
|
1117
|
+
fixWith: "(...args: any[]) => any"
|
|
1177
1118
|
}
|
|
1178
|
-
},
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1119
|
+
} }],
|
|
1120
|
+
"ts/no-unsafe-function-type": "error",
|
|
1121
|
+
"ts/no-wrapper-object-types": "error",
|
|
1122
|
+
"ts/consistent-type-imports": ["error", {
|
|
1123
|
+
prefer: "type-imports",
|
|
1124
|
+
disallowTypeAnnotations: false
|
|
1125
|
+
}],
|
|
1126
|
+
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1127
|
+
"ts/consistent-indexed-object-style": ["error", "record"],
|
|
1128
|
+
"ts/prefer-ts-expect-error": "error",
|
|
1129
|
+
"ts/prefer-for-of": "error",
|
|
1130
|
+
"ts/no-duplicate-enum-values": "error",
|
|
1131
|
+
"ts/no-non-null-asserted-nullish-coalescing": "error",
|
|
1132
|
+
"ts/no-require-imports": "error",
|
|
1133
|
+
"ts/method-signature-style": ["error", "property"],
|
|
1134
|
+
"ts/explicit-member-accessibility": ["error", {
|
|
1135
|
+
accessibility: "explicit",
|
|
1136
|
+
overrides: { constructors: "no-public" }
|
|
1137
|
+
}],
|
|
1138
|
+
"no-useless-constructor": "off",
|
|
1139
|
+
"no-invalid-this": "off",
|
|
1140
|
+
"ts/no-invalid-this": "error",
|
|
1141
|
+
"no-redeclare": "off",
|
|
1142
|
+
"ts/no-redeclare": "error",
|
|
1143
|
+
"no-use-before-define": "off",
|
|
1144
|
+
"ts/no-use-before-define": ["error", {
|
|
1145
|
+
functions: false,
|
|
1146
|
+
classes: false,
|
|
1147
|
+
variables: true
|
|
1148
|
+
}],
|
|
1149
|
+
"object-curly-spacing": "off",
|
|
1150
|
+
"space-before-blocks": "off",
|
|
1151
|
+
"ts/space-before-blocks": "off",
|
|
1152
|
+
"space-before-function-paren": "off",
|
|
1153
|
+
"no-dupe-class-members": "off",
|
|
1154
|
+
"ts/no-dupe-class-members": "error",
|
|
1155
|
+
"no-loss-of-precision": "off",
|
|
1156
|
+
"ts/no-loss-of-precision": "error",
|
|
1157
|
+
"so1ve/no-inline-type-import": "error",
|
|
1158
|
+
"ts/camelcase": "off",
|
|
1159
|
+
"ts/explicit-function-return-type": "off",
|
|
1160
|
+
"ts/no-explicit-any": "off",
|
|
1161
|
+
"ts/no-parameter-properties": "off",
|
|
1162
|
+
"ts/no-empty-interface": "off",
|
|
1163
|
+
"ts/ban-ts-ignore": "off",
|
|
1164
|
+
"ts/no-empty-function": "off",
|
|
1165
|
+
"ts/no-non-null-assertion": "off",
|
|
1166
|
+
"ts/explicit-module-boundary-types": "off",
|
|
1167
|
+
"ts/triple-slash-reference": "off",
|
|
1168
|
+
"ts/no-unused-vars": "off",
|
|
1169
|
+
...overrides
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
name: "so1ve/typescript/rules/type-aware",
|
|
1174
|
+
files: [
|
|
1175
|
+
GLOB_TS,
|
|
1176
|
+
GLOB_TSX,
|
|
1177
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1178
|
+
],
|
|
1179
|
+
ignores: [GLOB_MARKDOWN_CODE, GLOB_ASTRO_TS],
|
|
1180
|
+
languageOptions: {
|
|
1181
|
+
parser: tseslint.parser,
|
|
1182
|
+
parserOptions: {
|
|
1183
|
+
sourceType: "module",
|
|
1184
|
+
projectService: true,
|
|
1185
|
+
tsconfigRootDir: process.cwd()
|
|
1206
1186
|
}
|
|
1207
1187
|
},
|
|
1208
|
-
{
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
"
|
|
1213
|
-
"ts
|
|
1214
|
-
|
|
1188
|
+
settings: { "import/resolver": {
|
|
1189
|
+
node: { extensions: [
|
|
1190
|
+
".js",
|
|
1191
|
+
".jsx",
|
|
1192
|
+
".mjs",
|
|
1193
|
+
".ts",
|
|
1194
|
+
".tsx",
|
|
1195
|
+
".d.ts"
|
|
1196
|
+
] },
|
|
1197
|
+
typescript: { extensions: [
|
|
1198
|
+
".js",
|
|
1199
|
+
".jsx",
|
|
1200
|
+
".mjs",
|
|
1201
|
+
".ts",
|
|
1202
|
+
".tsx",
|
|
1203
|
+
".d.ts"
|
|
1204
|
+
] }
|
|
1205
|
+
} },
|
|
1206
|
+
rules: {
|
|
1207
|
+
"no-throw-literal": "off",
|
|
1208
|
+
"ts/only-throw-error": "error",
|
|
1209
|
+
"no-implied-eval": "off",
|
|
1210
|
+
"ts/no-implied-eval": "error",
|
|
1211
|
+
"dot-notation": "off",
|
|
1212
|
+
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1213
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
1214
|
+
"ts/await-thenable": "error",
|
|
1215
|
+
"ts/no-for-in-array": "error",
|
|
1216
|
+
"ts/no-unnecessary-type-assertion": "error",
|
|
1217
|
+
"ts/restrict-template-expressions": ["error", {
|
|
1218
|
+
allowAny: true,
|
|
1219
|
+
allowNumber: true,
|
|
1220
|
+
allowBoolean: true
|
|
1221
|
+
}],
|
|
1222
|
+
"ts/array-type": ["error", {
|
|
1223
|
+
default: "array",
|
|
1224
|
+
readonly: "array"
|
|
1225
|
+
}],
|
|
1226
|
+
"ts/consistent-generic-constructors": "error",
|
|
1227
|
+
"ts/consistent-type-exports": "error",
|
|
1228
|
+
"ts/consistent-type-assertions": ["error", {
|
|
1229
|
+
assertionStyle: "as",
|
|
1230
|
+
objectLiteralTypeAssertions: "allow"
|
|
1231
|
+
}],
|
|
1232
|
+
"ts/prefer-nullish-coalescing": "error",
|
|
1233
|
+
"ts/prefer-optional-chain": "error",
|
|
1234
|
+
"ts/prefer-return-this-type": "error",
|
|
1235
|
+
"ts/no-unnecessary-type-arguments": "error",
|
|
1236
|
+
"ts/non-nullable-type-assertion-style": "error"
|
|
1215
1237
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
name: "so1ve/typescript/rules/dts",
|
|
1241
|
+
files: ["**/*.d.ts"],
|
|
1242
|
+
rules: {
|
|
1243
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
1244
|
+
"import/no-duplicates": "off",
|
|
1245
|
+
"unused-imports/no-unused-vars": "off"
|
|
1246
|
+
}
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
name: "so1ve/typescript/rules/js",
|
|
1250
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
1251
|
+
rules: {
|
|
1252
|
+
"ts/no-require-imports": "off",
|
|
1253
|
+
"ts/no-var-requires": "off"
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
];
|
|
1218
1257
|
|
|
1219
1258
|
//#endregion
|
|
1220
1259
|
//#region src/configs/unicorn.ts
|
|
@@ -1246,6 +1285,7 @@ const unicorn = () => [{
|
|
|
1246
1285
|
"unicorn/no-lonely-if": "error",
|
|
1247
1286
|
"unicorn/no-negated-condition": "error",
|
|
1248
1287
|
"unicorn/no-useless-spread": "error",
|
|
1288
|
+
"unicorn/require-module-specifiers": "error",
|
|
1249
1289
|
"unicorn/prefer-ternary": "error",
|
|
1250
1290
|
"unicorn/prefer-query-selector": "error",
|
|
1251
1291
|
"unicorn/prefer-modern-dom-apis": "error",
|
|
@@ -1267,7 +1307,8 @@ const unicorn = () => [{
|
|
|
1267
1307
|
"unicorn/prefer-regexp-test": "error",
|
|
1268
1308
|
"unicorn/prefer-optional-catch-binding": "error",
|
|
1269
1309
|
"unicorn/prefer-object-from-entries": "error",
|
|
1270
|
-
"unicorn/prefer-prototype-methods": "error"
|
|
1310
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
1311
|
+
"unicorn/prefer-class-fields": "error"
|
|
1271
1312
|
}
|
|
1272
1313
|
}];
|
|
1273
1314
|
|
|
@@ -1507,7 +1548,7 @@ const defaultPluginRenaming = {
|
|
|
1507
1548
|
* Construct an array of ESLint flat config items.
|
|
1508
1549
|
*/
|
|
1509
1550
|
function so1ve(options = {}, ...userConfigs) {
|
|
1510
|
-
const { vue: enableVue = VuePackages.some((i) => isPackageExists(i)), solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), gitignore: enableGitignore = true, pnpm: enableCatalogs = false, componentExts = [] } = options;
|
|
1551
|
+
const { astro: enableAstro = isPackageExists("astro"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)), solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), gitignore: enableGitignore = true, pnpm: enableCatalogs = false, componentExts = [] } = options;
|
|
1511
1552
|
const configs = [];
|
|
1512
1553
|
if (enableGitignore) if (typeof enableGitignore === "boolean") {
|
|
1513
1554
|
if (fs.existsSync(".gitignore")) configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
@@ -1521,6 +1562,7 @@ function so1ve(options = {}, ...userConfigs) {
|
|
|
1521
1562
|
overrides: getOverrides(options, "typescript")
|
|
1522
1563
|
}));
|
|
1523
1564
|
if (options.test ?? true) configs.push(test({ overrides: getOverrides(options, "test") }));
|
|
1565
|
+
if (enableAstro) configs.push(astro({ overrides: getOverrides(options, "astro") }));
|
|
1524
1566
|
if (enableVue) configs.push(vue({
|
|
1525
1567
|
overrides: getOverrides(options, "vue"),
|
|
1526
1568
|
typescript: !!enableTypeScript
|
|
@@ -1542,8 +1584,7 @@ function so1ve(options = {}, ...userConfigs) {
|
|
|
1542
1584
|
return acc;
|
|
1543
1585
|
}, {});
|
|
1544
1586
|
if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
|
|
1545
|
-
|
|
1546
|
-
return composer;
|
|
1587
|
+
return new FlatConfigComposer().append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
1547
1588
|
}
|
|
1548
1589
|
const resolveSubOptions = (options, key) => typeof options[key] === "boolean" ? {} : options[key] ?? {};
|
|
1549
1590
|
function getOverrides(options, key) {
|
|
@@ -1555,4 +1596,4 @@ function getOverrides(options, key) {
|
|
|
1555
1596
|
}
|
|
1556
1597
|
|
|
1557
1598
|
//#endregion
|
|
1558
|
-
export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, comments, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, pnpm, promise, renameRules, resolveSubOptions, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, yaml };
|
|
1599
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, astro, comments, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, pnpm, promise, renameRules, resolveSubOptions, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, yaml };
|