@storm-software/eslint 0.122.8 → 0.123.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/README.md +1 -1
- package/dist/chunk-7NZUDX62.js +99 -0
- package/dist/{chunk-Y67QTC5U.js → chunk-K6KBWFPU.js} +1 -1
- package/dist/{chunk-LSG5T3ZK.js → chunk-W6QEP5VE.js} +7 -6
- package/dist/chunk-X3L37QNE.js +161 -0
- package/dist/preset.d.ts +23 -7048
- package/dist/preset.js +3590 -933
- package/dist/types-Drnq7vws.d.ts +14859 -0
- package/dist/utils/banner-plugin.js +3 -3
- package/dist/utils/combine.d.ts +14 -0
- package/dist/utils/combine.js +13 -0
- package/dist/utils/constants.d.ts +33 -22
- package/dist/utils/constants.js +65 -19
- package/dist/utils/get-file-banner.js +2 -2
- package/dist/utils/helpers.d.ts +55 -0
- package/dist/utils/helpers.js +19 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +67 -21
- package/package.json +76 -50
- package/dist/chunk-723HQUNP.js +0 -14
- package/dist/chunk-ESFBJFNU.cjs +0 -149
- package/dist/chunk-GMT3V67N.cjs +0 -24
- package/dist/chunk-HMBBDY5L.cjs +0 -49
- package/dist/chunk-JS7W7LMD.cjs +0 -14
- package/dist/chunk-KISSHBCD.cjs +0 -1333
- package/dist/chunk-LFHG33FO.cjs +0 -313
- package/dist/chunk-QSFZU7HX.cjs +0 -47
- package/dist/chunk-RTM5LCEB.js +0 -149
- package/dist/chunk-USNT2KNT.cjs +0 -6
- package/dist/chunk-VIASOXKK.js +0 -1333
- package/dist/preset.cjs +0 -988
- package/dist/preset.d.cts +0 -7057
- package/dist/rules/import.cjs +0 -291
- package/dist/rules/import.d.cts +0 -5
- package/dist/rules/import.d.ts +0 -5
- package/dist/rules/import.js +0 -291
- package/dist/rules/jsx-a11y.cjs +0 -341
- package/dist/rules/jsx-a11y.d.cts +0 -5
- package/dist/rules/jsx-a11y.d.ts +0 -5
- package/dist/rules/jsx-a11y.js +0 -341
- package/dist/rules/react-hooks.cjs +0 -15
- package/dist/rules/react-hooks.d.cts +0 -5
- package/dist/rules/react-hooks.d.ts +0 -5
- package/dist/rules/react-hooks.js +0 -15
- package/dist/rules/react.cjs +0 -689
- package/dist/rules/react.d.cts +0 -5
- package/dist/rules/react.d.ts +0 -5
- package/dist/rules/react.js +0 -689
- package/dist/rules/storm.cjs +0 -7
- package/dist/rules/storm.d.cts +0 -11
- package/dist/rules/storm.d.ts +0 -11
- package/dist/rules/storm.js +0 -7
- package/dist/rules/ts-docs.cjs +0 -7
- package/dist/rules/ts-docs.d.cts +0 -5
- package/dist/rules/ts-docs.d.ts +0 -5
- package/dist/rules/ts-docs.js +0 -7
- package/dist/rules.d.ts +0 -7005
- package/dist/utils/banner-plugin.cjs +0 -9
- package/dist/utils/banner-plugin.d.cts +0 -6
- package/dist/utils/constants.cjs +0 -25
- package/dist/utils/constants.d.cts +0 -24
- package/dist/utils/create-flat-import-plugin.cjs +0 -20
- package/dist/utils/create-flat-import-plugin.d.cts +0 -11
- package/dist/utils/create-flat-import-plugin.d.ts +0 -11
- package/dist/utils/create-flat-import-plugin.js +0 -20
- package/dist/utils/format-config.cjs +0 -7
- package/dist/utils/format-config.d.cts +0 -5
- package/dist/utils/get-file-banner.cjs +0 -8
- package/dist/utils/get-file-banner.d.cts +0 -9
- package/dist/utils/ignores.cjs +0 -7
- package/dist/utils/ignores.d.cts +0 -3
- package/dist/utils/index.cjs +0 -33
- package/dist/utils/index.d.cts +0 -4
package/dist/preset.js
CHANGED
|
@@ -1,988 +1,3645 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatConfig
|
|
3
|
-
} from "./chunk-FTXILLLE.js";
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_IGNORES
|
|
6
|
-
} from "./chunk-UAGSKXUP.js";
|
|
7
|
-
import {
|
|
8
|
-
getStormRulesConfig
|
|
9
|
-
} from "./chunk-VIASOXKK.js";
|
|
10
|
-
import {
|
|
11
|
-
ts_docs_default
|
|
12
|
-
} from "./chunk-723HQUNP.js";
|
|
13
1
|
import {
|
|
14
2
|
banner_plugin_default
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-W6QEP5VE.js";
|
|
4
|
+
import "./chunk-K6KBWFPU.js";
|
|
17
5
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
GLOB_ASTRO,
|
|
7
|
+
GLOB_ASTRO_TS,
|
|
8
|
+
GLOB_CSS,
|
|
9
|
+
GLOB_EXCLUDE,
|
|
10
|
+
GLOB_GRAPHQL,
|
|
11
|
+
GLOB_HTML,
|
|
12
|
+
GLOB_JSON,
|
|
13
|
+
GLOB_JSON5,
|
|
14
|
+
GLOB_JSONC,
|
|
15
|
+
GLOB_JSX,
|
|
16
|
+
GLOB_LESS,
|
|
17
|
+
GLOB_MARKDOWN,
|
|
18
|
+
GLOB_MARKDOWN_CODE,
|
|
19
|
+
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
20
|
+
GLOB_POSTCSS,
|
|
21
|
+
GLOB_SCSS,
|
|
22
|
+
GLOB_SRC,
|
|
23
|
+
GLOB_SRC_EXT,
|
|
24
|
+
GLOB_SVG,
|
|
25
|
+
GLOB_TESTS,
|
|
26
|
+
GLOB_TOML,
|
|
27
|
+
GLOB_TS,
|
|
28
|
+
GLOB_TSX,
|
|
29
|
+
GLOB_XML,
|
|
30
|
+
GLOB_YAML
|
|
31
|
+
} from "./chunk-X3L37QNE.js";
|
|
32
|
+
import {
|
|
33
|
+
ensurePackages,
|
|
34
|
+
interopDefault,
|
|
35
|
+
isInEditorEnv,
|
|
36
|
+
isPackageInScope,
|
|
37
|
+
parserPlain,
|
|
38
|
+
renameRules
|
|
39
|
+
} from "./chunk-7NZUDX62.js";
|
|
22
40
|
import {
|
|
23
41
|
__name
|
|
24
42
|
} from "./chunk-SHUYVCID.js";
|
|
25
43
|
|
|
26
44
|
// src/preset.ts
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import next from "@next/eslint-plugin-next";
|
|
30
|
-
import nxPlugin from "@nx/eslint-plugin/nx.js";
|
|
31
|
-
|
|
32
|
-
// ../config-tools/src/types.ts
|
|
33
|
-
var LogLevel = {
|
|
34
|
-
SILENT: 0,
|
|
35
|
-
FATAL: 10,
|
|
36
|
-
ERROR: 20,
|
|
37
|
-
WARN: 30,
|
|
38
|
-
SUCCESS: 35,
|
|
39
|
-
INFO: 40,
|
|
40
|
-
DEBUG: 60,
|
|
41
|
-
TRACE: 70,
|
|
42
|
-
ALL: 100
|
|
43
|
-
};
|
|
44
|
-
var LogLevelLabel = {
|
|
45
|
-
SILENT: "silent",
|
|
46
|
-
FATAL: "fatal",
|
|
47
|
-
ERROR: "error",
|
|
48
|
-
WARN: "warn",
|
|
49
|
-
SUCCESS: "success",
|
|
50
|
-
INFO: "info",
|
|
51
|
-
DEBUG: "debug",
|
|
52
|
-
TRACE: "trace",
|
|
53
|
-
ALL: "all"
|
|
54
|
-
};
|
|
45
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
46
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
55
47
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
import
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var InfoColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0070E0").describe("The informational color of the workspace");
|
|
72
|
-
var WarningColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace");
|
|
73
|
-
var DangerColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#D8314A").describe("The danger color of the workspace");
|
|
74
|
-
var FatalColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The fatal color of the workspace");
|
|
75
|
-
var PositiveColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#4ade80").describe("The positive number color of the workspace");
|
|
76
|
-
var NegativeColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#ef4444").describe("The negative number color of the workspace");
|
|
77
|
-
var DarkThemeColorConfigSchema = z.object({
|
|
78
|
-
foreground: LightColorSchema,
|
|
79
|
-
background: DarkColorSchema,
|
|
80
|
-
brand: BrandColorSchema,
|
|
81
|
-
alternate: AlternateColorSchema,
|
|
82
|
-
accent: AccentColorSchema,
|
|
83
|
-
link: LinkColorSchema,
|
|
84
|
-
help: HelpColorSchema,
|
|
85
|
-
success: SuccessColorSchema,
|
|
86
|
-
info: InfoColorSchema,
|
|
87
|
-
warning: WarningColorSchema,
|
|
88
|
-
danger: DangerColorSchema,
|
|
89
|
-
fatal: FatalColorSchema,
|
|
90
|
-
positive: PositiveColorSchema,
|
|
91
|
-
negative: NegativeColorSchema
|
|
92
|
-
});
|
|
93
|
-
var LightThemeColorConfigSchema = z.object({
|
|
94
|
-
foreground: DarkColorSchema,
|
|
95
|
-
background: LightColorSchema,
|
|
96
|
-
brand: BrandColorSchema,
|
|
97
|
-
alternate: AlternateColorSchema,
|
|
98
|
-
accent: AccentColorSchema,
|
|
99
|
-
link: LinkColorSchema,
|
|
100
|
-
help: HelpColorSchema,
|
|
101
|
-
success: SuccessColorSchema,
|
|
102
|
-
info: InfoColorSchema,
|
|
103
|
-
warning: WarningColorSchema,
|
|
104
|
-
danger: DangerColorSchema,
|
|
105
|
-
fatal: FatalColorSchema,
|
|
106
|
-
positive: PositiveColorSchema,
|
|
107
|
-
negative: NegativeColorSchema
|
|
108
|
-
});
|
|
109
|
-
var MultiThemeColorConfigSchema = z.object({
|
|
110
|
-
dark: DarkThemeColorConfigSchema,
|
|
111
|
-
light: LightThemeColorConfigSchema
|
|
112
|
-
});
|
|
113
|
-
var SingleThemeColorConfigSchema = z.object({
|
|
114
|
-
dark: DarkColorSchema,
|
|
115
|
-
light: LightColorSchema,
|
|
116
|
-
brand: BrandColorSchema,
|
|
117
|
-
alternate: AlternateColorSchema,
|
|
118
|
-
accent: AccentColorSchema,
|
|
119
|
-
link: LinkColorSchema,
|
|
120
|
-
help: HelpColorSchema,
|
|
121
|
-
success: SuccessColorSchema,
|
|
122
|
-
info: InfoColorSchema,
|
|
123
|
-
warning: WarningColorSchema,
|
|
124
|
-
danger: DangerColorSchema,
|
|
125
|
-
fatal: FatalColorSchema,
|
|
126
|
-
positive: PositiveColorSchema,
|
|
127
|
-
negative: NegativeColorSchema
|
|
128
|
-
});
|
|
129
|
-
var RegistryUrlConfigSchema = z.string().trim().toLowerCase().url().optional().describe("A remote registry URL used to publish distributable packages");
|
|
130
|
-
var RegistryConfigSchema = z.object({
|
|
131
|
-
github: RegistryUrlConfigSchema,
|
|
132
|
-
npm: RegistryUrlConfigSchema,
|
|
133
|
-
cargo: RegistryUrlConfigSchema,
|
|
134
|
-
cyclone: RegistryUrlConfigSchema,
|
|
135
|
-
container: RegistryUrlConfigSchema
|
|
136
|
-
}).default({}).describe("A list of remote registry URLs used by Storm Software");
|
|
137
|
-
var ColorConfigSchema = SingleThemeColorConfigSchema.or(MultiThemeColorConfigSchema).describe("Colors used for various workspace elements");
|
|
138
|
-
var ColorConfigMapSchema = z.union([
|
|
139
|
-
z.object({
|
|
140
|
-
base: ColorConfigSchema
|
|
141
|
-
}),
|
|
142
|
-
z.record(z.string(), ColorConfigSchema)
|
|
143
|
-
]);
|
|
144
|
-
var ExtendsItemSchema = z.string().trim().describe("The path to a base config file to use as a configuration preset file. Documentation can be found at https://github.com/unjs/c12#extending-configuration.");
|
|
145
|
-
var ExtendsSchema = ExtendsItemSchema.or(z.array(ExtendsItemSchema)).describe("The path to a base config file to use as a configuration preset file. Documentation can be found at https://github.com/unjs/c12#extending-configuration.");
|
|
146
|
-
var WorkspaceBotConfigSchema = z.object({
|
|
147
|
-
name: z.string().trim().default("Stormie-Bot").describe("The workspace bot user's name (this is the bot that will be used to perform various tasks)"),
|
|
148
|
-
email: z.string().trim().email().default("bot@stormsoftware.com").describe("The email of the workspace bot")
|
|
149
|
-
}).describe("The workspace's bot user's config used to automated various operations tasks");
|
|
150
|
-
var WorkspaceDirectoryConfigSchema = z.object({
|
|
151
|
-
cache: z.string().trim().optional().describe("The directory used to store the environment's cached file data"),
|
|
152
|
-
data: z.string().trim().optional().describe("The directory used to store the environment's data files"),
|
|
153
|
-
config: z.string().trim().optional().describe("The directory used to store the environment's configuration files"),
|
|
154
|
-
temp: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
|
|
155
|
-
log: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
|
|
156
|
-
build: z.string().trim().default("dist").describe("The directory used to store the workspace's distributable files after a build (relative to the workspace root)")
|
|
157
|
-
}).describe("Various directories used by the workspace to store data, cache, and configuration files");
|
|
158
|
-
var StormConfigSchema = z.object({
|
|
159
|
-
$schema: z.string().trim().default("https://cdn.jsdelivr.net/npm/@storm-software/config/schemas/storm-workspace.schema.json").optional().nullish().describe("The URL to the JSON schema file that describes the Storm configuration file"),
|
|
160
|
-
extends: ExtendsSchema.optional(),
|
|
161
|
-
name: z.string().trim().toLowerCase().optional().describe("The name of the service/package/scope using this configuration"),
|
|
162
|
-
namespace: z.string().trim().toLowerCase().optional().describe("The namespace of the package"),
|
|
163
|
-
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
|
|
164
|
-
repository: z.string().trim().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
165
|
-
license: z.string().trim().default("Apache-2.0").describe("The license type of the package"),
|
|
166
|
-
homepage: z.string().trim().url().default(STORM_DEFAULT_HOMEPAGE).describe("The homepage of the workspace"),
|
|
167
|
-
docs: z.string().trim().url().default(STORM_DEFAULT_DOCS).describe("The base documentation site for the workspace"),
|
|
168
|
-
licensing: z.string().trim().url().default(STORM_DEFAULT_LICENSING).describe("The base licensing site for the workspace"),
|
|
169
|
-
branch: z.string().trim().default("main").describe("The branch of the workspace"),
|
|
170
|
-
preid: z.string().optional().describe("A tag specifying the version pre-release identifier"),
|
|
171
|
-
owner: z.string().trim().default("@storm-software/admin").describe("The owner of the package"),
|
|
172
|
-
bot: WorkspaceBotConfigSchema,
|
|
173
|
-
mode: z.enum([
|
|
174
|
-
"development",
|
|
175
|
-
"staging",
|
|
176
|
-
"production"
|
|
177
|
-
]).default("production").describe("The current runtime environment mode for the package"),
|
|
178
|
-
workspaceRoot: z.string().trim().default("").describe("The root directory of the workspace"),
|
|
179
|
-
externalPackagePatterns: z.array(z.string()).default([]).describe("The build will use these package patterns to determine if they should be external to the bundle"),
|
|
180
|
-
skipCache: z.boolean().default(false).describe("Should all known types of workspace caching be skipped?"),
|
|
181
|
-
directories: WorkspaceDirectoryConfigSchema,
|
|
182
|
-
packageManager: z.enum([
|
|
183
|
-
"npm",
|
|
184
|
-
"yarn",
|
|
185
|
-
"pnpm",
|
|
186
|
-
"bun"
|
|
187
|
-
]).default("npm").describe("The JavaScript/TypeScript package manager used by the repository"),
|
|
188
|
-
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
189
|
-
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
190
|
-
logLevel: z.enum([
|
|
191
|
-
"silent",
|
|
192
|
-
"fatal",
|
|
193
|
-
"error",
|
|
194
|
-
"warn",
|
|
195
|
-
"success",
|
|
196
|
-
"info",
|
|
197
|
-
"debug",
|
|
198
|
-
"trace",
|
|
199
|
-
"all"
|
|
200
|
-
]).default("info").describe("The log level used to filter out lower priority log messages. If not provided, this is defaulted using the `environment` config value (if `environment` is set to `production` then `level` is `error`, else `level` is `debug`)."),
|
|
201
|
-
skipConfigLogging: z.boolean().optional().describe("Should the logging of the current Storm Workspace configuration be skipped?"),
|
|
202
|
-
registry: RegistryConfigSchema,
|
|
203
|
-
configFile: z.string().trim().nullable().default(null).describe("The filepath of the Storm config. When this field is null, no config file was found in the current workspace."),
|
|
204
|
-
colors: ColorConfigSchema.or(ColorConfigMapSchema).describe("Storm theme config values used for styling various package elements"),
|
|
205
|
-
extensions: z.record(z.any()).optional().default({}).describe("Configuration of each used extension")
|
|
206
|
-
}).describe("Storm Workspace config values used during various dev-ops processes. This type is a combination of the StormPackageConfig and StormProject types. It represents the config of the entire monorepo.");
|
|
207
|
-
|
|
208
|
-
// ../config-tools/src/utilities/get-default-config.ts
|
|
209
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
210
|
-
import { readFile } from "node:fs/promises";
|
|
211
|
-
import { join as join2 } from "node:path";
|
|
212
|
-
|
|
213
|
-
// ../config-tools/src/utilities/correct-paths.ts
|
|
214
|
-
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
215
|
-
function normalizeWindowsPath(input = "") {
|
|
216
|
-
if (!input) {
|
|
217
|
-
return input;
|
|
218
|
-
}
|
|
219
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
220
|
-
}
|
|
221
|
-
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
222
|
-
var _UNC_REGEX = /^[/\\]{2}/;
|
|
223
|
-
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
224
|
-
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
225
|
-
var correctPaths = /* @__PURE__ */ __name(function(path) {
|
|
226
|
-
if (!path || path.length === 0) {
|
|
227
|
-
return ".";
|
|
228
|
-
}
|
|
229
|
-
path = normalizeWindowsPath(path);
|
|
230
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
231
|
-
const isPathAbsolute = isAbsolute(path);
|
|
232
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
233
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
234
|
-
if (path.length === 0) {
|
|
235
|
-
if (isPathAbsolute) {
|
|
236
|
-
return "/";
|
|
237
|
-
}
|
|
238
|
-
return trailingSeparator ? "./" : ".";
|
|
239
|
-
}
|
|
240
|
-
if (trailingSeparator) {
|
|
241
|
-
path += "/";
|
|
242
|
-
}
|
|
243
|
-
if (_DRIVE_LETTER_RE.test(path)) {
|
|
244
|
-
path += "/";
|
|
245
|
-
}
|
|
246
|
-
if (isUNCPath) {
|
|
247
|
-
if (!isPathAbsolute) {
|
|
248
|
-
return `//./${path}`;
|
|
249
|
-
}
|
|
250
|
-
return `//${path}`;
|
|
251
|
-
}
|
|
252
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
253
|
-
}, "correctPaths");
|
|
254
|
-
var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
255
|
-
let path = "";
|
|
256
|
-
for (const seg of segments) {
|
|
257
|
-
if (!seg) {
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
if (path.length > 0) {
|
|
261
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
262
|
-
const segLeading = seg[0] === "/";
|
|
263
|
-
const both = pathTrailing && segLeading;
|
|
264
|
-
if (both) {
|
|
265
|
-
path += seg.slice(1);
|
|
266
|
-
} else {
|
|
267
|
-
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
48
|
+
// src/configs/astro.ts
|
|
49
|
+
async function astro(options = {}) {
|
|
50
|
+
const { files = [
|
|
51
|
+
GLOB_ASTRO
|
|
52
|
+
], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
53
|
+
const [pluginAstro, parserAstro, parserTs] = await Promise.all([
|
|
54
|
+
interopDefault(import("eslint-plugin-astro")),
|
|
55
|
+
interopDefault(import("astro-eslint-parser")),
|
|
56
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
57
|
+
]);
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
name: "storm/astro/setup",
|
|
61
|
+
plugins: {
|
|
62
|
+
astro: pluginAstro
|
|
268
63
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
continue;
|
|
305
|
-
} else if (res.length > 0) {
|
|
306
|
-
res = "";
|
|
307
|
-
lastSegmentLength = 0;
|
|
308
|
-
lastSlash = index;
|
|
309
|
-
dots = 0;
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
if (allowAboveRoot) {
|
|
314
|
-
res += res.length > 0 ? "/.." : "..";
|
|
315
|
-
lastSegmentLength = 2;
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
if (res.length > 0) {
|
|
319
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
320
|
-
} else {
|
|
321
|
-
res = path.slice(lastSlash + 1, index);
|
|
322
|
-
}
|
|
323
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
files,
|
|
67
|
+
languageOptions: {
|
|
68
|
+
globals: pluginAstro.environments.astro.globals,
|
|
69
|
+
parser: parserAstro,
|
|
70
|
+
parserOptions: {
|
|
71
|
+
extraFileExtensions: [
|
|
72
|
+
".astro"
|
|
73
|
+
],
|
|
74
|
+
parser: parserTs
|
|
75
|
+
},
|
|
76
|
+
sourceType: "module"
|
|
77
|
+
},
|
|
78
|
+
name: "storm/astro/rules",
|
|
79
|
+
processor: "astro/client-side-ts",
|
|
80
|
+
rules: {
|
|
81
|
+
// use recommended rules
|
|
82
|
+
"astro/missing-client-only-directive-value": "error",
|
|
83
|
+
"astro/no-conflict-set-directives": "error",
|
|
84
|
+
"astro/no-deprecated-astro-canonicalurl": "error",
|
|
85
|
+
"astro/no-deprecated-astro-fetchcontent": "error",
|
|
86
|
+
"astro/no-deprecated-astro-resolve": "error",
|
|
87
|
+
"astro/no-deprecated-getentrybyslug": "error",
|
|
88
|
+
"astro/no-set-html-directive": "off",
|
|
89
|
+
"astro/no-unused-define-vars-in-style": "error",
|
|
90
|
+
"astro/semi": "off",
|
|
91
|
+
"astro/valid-compile": "error",
|
|
92
|
+
...stylistic2 ? {
|
|
93
|
+
"style/indent": "off",
|
|
94
|
+
"style/jsx-closing-tag-location": "off",
|
|
95
|
+
"style/jsx-one-expression-per-line": "off",
|
|
96
|
+
"style/no-multiple-empty-lines": "off"
|
|
97
|
+
} : {},
|
|
98
|
+
...overrides
|
|
324
99
|
}
|
|
325
|
-
lastSlash = index;
|
|
326
|
-
dots = 0;
|
|
327
|
-
} else if (char === "." && dots !== -1) {
|
|
328
|
-
++dots;
|
|
329
|
-
} else {
|
|
330
|
-
dots = -1;
|
|
331
100
|
}
|
|
332
|
-
|
|
333
|
-
return res;
|
|
101
|
+
];
|
|
334
102
|
}
|
|
335
|
-
__name(
|
|
336
|
-
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
337
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
338
|
-
}, "isAbsolute");
|
|
103
|
+
__name(astro, "astro");
|
|
339
104
|
|
|
340
|
-
//
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
];
|
|
397
|
-
var rootDirectories = [
|
|
398
|
-
".storm-workspace",
|
|
399
|
-
".nx",
|
|
400
|
-
".github",
|
|
401
|
-
".vscode",
|
|
402
|
-
".verdaccio"
|
|
403
|
-
];
|
|
404
|
-
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
405
|
-
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
406
|
-
return correctPaths(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
|
|
407
|
-
}
|
|
408
|
-
return correctPaths(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles, rootDirectories));
|
|
409
|
-
}
|
|
410
|
-
__name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
|
|
411
|
-
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
412
|
-
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
413
|
-
if (!result) {
|
|
414
|
-
throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
|
|
415
|
-
${rootFiles.join("\n")}
|
|
416
|
-
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
|
|
417
|
-
}
|
|
418
|
-
return result;
|
|
105
|
+
// src/configs/disables.ts
|
|
106
|
+
async function disables() {
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
files: [
|
|
110
|
+
`**/scripts/${GLOB_SRC}`
|
|
111
|
+
],
|
|
112
|
+
name: "storm/disables/scripts",
|
|
113
|
+
rules: {
|
|
114
|
+
"no-console": "off",
|
|
115
|
+
"ts/explicit-function-return-type": "off"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
files: [
|
|
120
|
+
`**/cli/${GLOB_SRC}`,
|
|
121
|
+
`**/cli.${GLOB_SRC_EXT}`
|
|
122
|
+
],
|
|
123
|
+
name: "storm/disables/cli",
|
|
124
|
+
rules: {
|
|
125
|
+
"no-console": "off"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
files: [
|
|
130
|
+
"**/*.d.?([cm])ts"
|
|
131
|
+
],
|
|
132
|
+
name: "storm/disables/dts",
|
|
133
|
+
rules: {
|
|
134
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
135
|
+
"import/no-duplicates": "off",
|
|
136
|
+
"no-restricted-syntax": "off",
|
|
137
|
+
"unused-imports/no-unused-vars": "off"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
files: [
|
|
142
|
+
"**/*.js",
|
|
143
|
+
"**/*.cjs"
|
|
144
|
+
],
|
|
145
|
+
name: "storm/disables/cjs",
|
|
146
|
+
rules: {
|
|
147
|
+
"ts/no-require-imports": "off"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
files: [
|
|
152
|
+
`**/*.config.${GLOB_SRC_EXT}`,
|
|
153
|
+
`**/*.config.*.${GLOB_SRC_EXT}`
|
|
154
|
+
],
|
|
155
|
+
name: "storm/disables/config-files",
|
|
156
|
+
rules: {
|
|
157
|
+
"no-console": "off",
|
|
158
|
+
"ts/explicit-function-return-type": "off"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
];
|
|
419
162
|
}
|
|
420
|
-
__name(
|
|
421
|
-
|
|
422
|
-
// ../config-tools/src/utilities/get-default-config.ts
|
|
423
|
-
var DEFAULT_COLOR_CONFIG = {
|
|
424
|
-
light: {
|
|
425
|
-
background: "#fafafa",
|
|
426
|
-
foreground: "#1d1e22",
|
|
427
|
-
brand: "#1fb2a6",
|
|
428
|
-
alternate: "#db2777",
|
|
429
|
-
help: "#5C4EE5",
|
|
430
|
-
success: "#087f5b",
|
|
431
|
-
info: "#0550ae",
|
|
432
|
-
warning: "#e3b341",
|
|
433
|
-
danger: "#D8314A",
|
|
434
|
-
positive: "#22c55e",
|
|
435
|
-
negative: "#dc2626"
|
|
436
|
-
},
|
|
437
|
-
dark: {
|
|
438
|
-
background: "#1d1e22",
|
|
439
|
-
foreground: "#cbd5e1",
|
|
440
|
-
brand: "#2dd4bf",
|
|
441
|
-
alternate: "#db2777",
|
|
442
|
-
help: "#818cf8",
|
|
443
|
-
success: "#10b981",
|
|
444
|
-
info: "#58a6ff",
|
|
445
|
-
warning: "#f3d371",
|
|
446
|
-
danger: "#D8314A",
|
|
447
|
-
positive: "#22c55e",
|
|
448
|
-
negative: "#dc2626"
|
|
449
|
-
}
|
|
450
|
-
};
|
|
163
|
+
__name(disables, "disables");
|
|
451
164
|
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}), "bgHex"),
|
|
459
|
-
whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright"),
|
|
460
|
-
gray: /* @__PURE__ */ __name((message) => message, "gray"),
|
|
461
|
-
bold: {
|
|
462
|
-
hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
|
|
463
|
-
bgHex: /* @__PURE__ */ __name((_) => ({
|
|
464
|
-
whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
|
|
465
|
-
}), "bgHex"),
|
|
466
|
-
whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
|
|
467
|
-
},
|
|
468
|
-
dim: {
|
|
469
|
-
hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
|
|
470
|
-
gray: /* @__PURE__ */ __name((message) => message, "gray")
|
|
471
|
-
}
|
|
165
|
+
// src/configs/stylistic.ts
|
|
166
|
+
var StylisticConfigDefaults = {
|
|
167
|
+
indent: 2,
|
|
168
|
+
jsx: true,
|
|
169
|
+
quotes: "single",
|
|
170
|
+
semi: false
|
|
472
171
|
};
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
return
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
172
|
+
async function stylistic(options = {}) {
|
|
173
|
+
const { indent, jsx: jsx2, overrides = {}, quotes, semi } = {
|
|
174
|
+
...StylisticConfigDefaults,
|
|
175
|
+
...options
|
|
176
|
+
};
|
|
177
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
178
|
+
const config = pluginStylistic.configs.customize({
|
|
179
|
+
indent,
|
|
180
|
+
jsx: jsx2,
|
|
181
|
+
pluginName: "style",
|
|
182
|
+
quotes,
|
|
183
|
+
semi
|
|
184
|
+
});
|
|
185
|
+
return [
|
|
186
|
+
{
|
|
187
|
+
name: "storm/stylistic/rules",
|
|
188
|
+
plugins: {
|
|
189
|
+
style: pluginStylistic
|
|
190
|
+
},
|
|
191
|
+
rules: {
|
|
192
|
+
...config.rules,
|
|
193
|
+
...overrides
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
];
|
|
490
197
|
}
|
|
491
|
-
__name(
|
|
198
|
+
__name(stylistic, "stylistic");
|
|
492
199
|
|
|
493
|
-
//
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
case "trace":
|
|
517
|
-
return LogLevel.TRACE;
|
|
518
|
-
case "debug":
|
|
519
|
-
return LogLevel.DEBUG;
|
|
520
|
-
case "info":
|
|
521
|
-
return LogLevel.INFO;
|
|
522
|
-
case "warn":
|
|
523
|
-
return LogLevel.WARN;
|
|
524
|
-
case "error":
|
|
525
|
-
return LogLevel.ERROR;
|
|
526
|
-
case "fatal":
|
|
527
|
-
return LogLevel.FATAL;
|
|
528
|
-
case "silent":
|
|
529
|
-
return LogLevel.SILENT;
|
|
530
|
-
default:
|
|
531
|
-
return LogLevel.INFO;
|
|
532
|
-
}
|
|
533
|
-
}, "getLogLevel");
|
|
534
|
-
|
|
535
|
-
// ../config-tools/src/logger/console.ts
|
|
536
|
-
var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
|
|
537
|
-
const colors = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? DEFAULT_COLOR_CONFIG : config.colors?.dark && typeof config.colors.dark === "string" ? config.colors : config.colors?.["base"]?.dark && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : config.colors?.["base"] ? config.colors?.["base"] : DEFAULT_COLOR_CONFIG;
|
|
538
|
-
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
539
|
-
if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
|
|
540
|
-
return (_) => {
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
|
|
544
|
-
return (message) => {
|
|
545
|
-
console.error(`
|
|
546
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
547
|
-
`);
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
|
|
551
|
-
return (message) => {
|
|
552
|
-
console.error(`
|
|
553
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
554
|
-
`);
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
|
|
558
|
-
return (message) => {
|
|
559
|
-
console.warn(`
|
|
560
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
561
|
-
`);
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
|
|
565
|
-
return (message) => {
|
|
566
|
-
console.info(`
|
|
567
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
568
|
-
`);
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
|
|
572
|
-
return (message) => {
|
|
573
|
-
console.info(`
|
|
574
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
575
|
-
`);
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
|
|
579
|
-
return (message) => {
|
|
580
|
-
console.debug(`
|
|
581
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
582
|
-
`);
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
|
|
586
|
-
return (message) => {
|
|
587
|
-
console.debug(`
|
|
588
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
589
|
-
`);
|
|
200
|
+
// src/configs/formatters.ts
|
|
201
|
+
function mergePrettierOptions(options, overrides = {}) {
|
|
202
|
+
return {
|
|
203
|
+
...options,
|
|
204
|
+
...overrides,
|
|
205
|
+
plugins: [
|
|
206
|
+
...overrides.plugins || [],
|
|
207
|
+
...options.plugins || []
|
|
208
|
+
]
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
__name(mergePrettierOptions, "mergePrettierOptions");
|
|
212
|
+
async function formatters(options = {}, stylistic2 = {}) {
|
|
213
|
+
if (options === true) {
|
|
214
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
215
|
+
options = {
|
|
216
|
+
astro: isPackageInScope("prettier-plugin-astro"),
|
|
217
|
+
css: true,
|
|
218
|
+
graphql: true,
|
|
219
|
+
html: true,
|
|
220
|
+
markdown: true,
|
|
221
|
+
svg: isPrettierPluginXmlInScope,
|
|
222
|
+
xml: isPrettierPluginXmlInScope
|
|
590
223
|
};
|
|
591
224
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
225
|
+
await ensurePackages([
|
|
226
|
+
"eslint-plugin-format",
|
|
227
|
+
options.astro ? "prettier-plugin-astro" : void 0,
|
|
228
|
+
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
229
|
+
]);
|
|
230
|
+
const { indent, quotes, semi } = {
|
|
231
|
+
...StylisticConfigDefaults,
|
|
232
|
+
...stylistic2
|
|
596
233
|
};
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
import reactCompiler from "eslint-plugin-react-compiler";
|
|
635
|
-
import reactHooks from "eslint-plugin-react-hooks";
|
|
636
|
-
import storybook from "eslint-plugin-storybook";
|
|
637
|
-
import tsdoc from "eslint-plugin-tsdoc";
|
|
638
|
-
import unicorn from "eslint-plugin-unicorn";
|
|
639
|
-
import yml from "eslint-plugin-yml";
|
|
640
|
-
import globalsObj from "globals";
|
|
641
|
-
import tsEslint from "typescript-eslint";
|
|
642
|
-
function getStormConfig(options = {
|
|
643
|
-
rules: {},
|
|
644
|
-
ignores: [],
|
|
645
|
-
globals: {},
|
|
646
|
-
useUnicorn: true,
|
|
647
|
-
markdown: {},
|
|
648
|
-
react: {},
|
|
649
|
-
nx: {},
|
|
650
|
-
useReactCompiler: false,
|
|
651
|
-
logLevel: "info",
|
|
652
|
-
cspellConfigFile: "./.vscode/cspell.json"
|
|
653
|
-
}, ...userConfigs) {
|
|
654
|
-
const tsconfig = options.tsconfig;
|
|
655
|
-
const parserOptions = options.parserOptions;
|
|
656
|
-
const typescriptEslintConfigType = options.typescriptEslintConfigType || "eslintRecommended";
|
|
657
|
-
const useUnicorn = options.useUnicorn ?? true;
|
|
658
|
-
const react = options.react ?? {};
|
|
659
|
-
const nx = options.nx ?? {};
|
|
660
|
-
const useReactCompiler = options.useReactCompiler ?? false;
|
|
661
|
-
const logLevel = options.logLevel ?? "info";
|
|
662
|
-
const globals = options.globals ?? {};
|
|
663
|
-
const cspellConfigFile = options.cspellConfigFile || "./.vscode/cspell.json";
|
|
664
|
-
try {
|
|
665
|
-
const ignoredFiles = [
|
|
666
|
-
...DEFAULT_IGNORES,
|
|
667
|
-
...options.ignores || []
|
|
668
|
-
].filter(Boolean);
|
|
669
|
-
const configs = [
|
|
670
|
-
// Prettier
|
|
671
|
-
prettierConfig,
|
|
672
|
-
// Import
|
|
673
|
-
// https://www.npmjs.com/package/eslint-plugin-import
|
|
674
|
-
// { plugins: { import: importEslint } },
|
|
675
|
-
// {
|
|
676
|
-
// files: [CODE_FILE],
|
|
677
|
-
// rules: importRules
|
|
678
|
-
// },
|
|
679
|
-
// Json
|
|
680
|
-
// https://www.npmjs.com/package/eslint-plugin-json
|
|
681
|
-
{
|
|
682
|
-
files: [
|
|
683
|
-
"**/*.json"
|
|
684
|
-
],
|
|
685
|
-
...json.configs["recommended"],
|
|
686
|
-
rules: {
|
|
687
|
-
"json/json": [
|
|
688
|
-
"warn",
|
|
689
|
-
{
|
|
690
|
-
allowComments: true
|
|
691
|
-
}
|
|
692
|
-
]
|
|
693
|
-
}
|
|
694
|
-
},
|
|
695
|
-
{
|
|
696
|
-
files: [
|
|
697
|
-
"**/executors/**/schema.json",
|
|
698
|
-
"**/generators/**/schema.json"
|
|
699
|
-
],
|
|
700
|
-
rules: nx !== false ? {
|
|
701
|
-
"@nx/workspace/valid-schema-description": "error"
|
|
702
|
-
} : {}
|
|
234
|
+
const prettierOptions = Object.assign({
|
|
235
|
+
endOfLine: "auto",
|
|
236
|
+
printWidth: 120,
|
|
237
|
+
semi,
|
|
238
|
+
singleQuote: quotes === "single",
|
|
239
|
+
tabWidth: typeof indent === "number" ? indent : 2,
|
|
240
|
+
trailingComma: "all",
|
|
241
|
+
useTabs: indent === "tab"
|
|
242
|
+
}, options.prettierOptions || {});
|
|
243
|
+
const prettierXmlOptions = {
|
|
244
|
+
xmlQuoteAttributes: "double",
|
|
245
|
+
xmlSelfClosingSpace: true,
|
|
246
|
+
xmlSortAttributesByKey: false,
|
|
247
|
+
xmlWhitespaceSensitivity: "ignore"
|
|
248
|
+
};
|
|
249
|
+
const dprintOptions = Object.assign({
|
|
250
|
+
indentWidth: typeof indent === "number" ? indent : 2,
|
|
251
|
+
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
252
|
+
useTabs: indent === "tab"
|
|
253
|
+
}, options.dprintOptions || {});
|
|
254
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
255
|
+
const configs2 = [
|
|
256
|
+
{
|
|
257
|
+
name: "storm/formatter/setup",
|
|
258
|
+
plugins: {
|
|
259
|
+
format: pluginFormat
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
];
|
|
263
|
+
if (options.css) {
|
|
264
|
+
configs2.push({
|
|
265
|
+
files: [
|
|
266
|
+
GLOB_CSS,
|
|
267
|
+
GLOB_POSTCSS
|
|
268
|
+
],
|
|
269
|
+
languageOptions: {
|
|
270
|
+
parser: parserPlain
|
|
703
271
|
},
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
checkMissingDependencies: true,
|
|
720
|
-
checkObsoleteDependencies: true,
|
|
721
|
-
checkVersionMismatches: false,
|
|
722
|
-
includeTransitiveDependencies: true,
|
|
723
|
-
useLocalPathsForWorkspaceDependencies: true
|
|
724
|
-
}
|
|
725
|
-
]
|
|
726
|
-
} : {}
|
|
272
|
+
name: "storm/formatter/css",
|
|
273
|
+
rules: {
|
|
274
|
+
"format/prettier": [
|
|
275
|
+
"error",
|
|
276
|
+
mergePrettierOptions(prettierOptions, {
|
|
277
|
+
parser: "css"
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
}, {
|
|
282
|
+
files: [
|
|
283
|
+
GLOB_SCSS
|
|
284
|
+
],
|
|
285
|
+
languageOptions: {
|
|
286
|
+
parser: parserPlain
|
|
727
287
|
},
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
]
|
|
744
|
-
}
|
|
288
|
+
name: "storm/formatter/scss",
|
|
289
|
+
rules: {
|
|
290
|
+
"format/prettier": [
|
|
291
|
+
"error",
|
|
292
|
+
mergePrettierOptions(prettierOptions, {
|
|
293
|
+
parser: "scss"
|
|
294
|
+
})
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
}, {
|
|
298
|
+
files: [
|
|
299
|
+
GLOB_LESS
|
|
300
|
+
],
|
|
301
|
+
languageOptions: {
|
|
302
|
+
parser: parserPlain
|
|
745
303
|
},
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
configs.push(eslint.configs.recommended);
|
|
757
|
-
if (typescriptEslintConfigType !== "none") {
|
|
758
|
-
if (!(typescriptEslintConfigType in tsEslint.configs)) {
|
|
759
|
-
console.warn("Invalid TypeScript ESLint configuration type:", typescriptEslintConfigType);
|
|
760
|
-
} else {
|
|
761
|
-
configs.push(...Array.isArray(tsEslint.configs[typescriptEslintConfigType]) ? tsEslint.configs[typescriptEslintConfigType] : [
|
|
762
|
-
tsEslint.configs[typescriptEslintConfigType]
|
|
763
|
-
]);
|
|
304
|
+
name: "storm/formatter/less",
|
|
305
|
+
rules: {
|
|
306
|
+
"format/prettier": [
|
|
307
|
+
"error",
|
|
308
|
+
mergePrettierOptions(prettierOptions, {
|
|
309
|
+
parser: "less"
|
|
310
|
+
})
|
|
311
|
+
]
|
|
764
312
|
}
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
TS_FILE
|
|
770
|
-
],
|
|
771
|
-
plugins: {
|
|
772
|
-
unicorn
|
|
773
|
-
},
|
|
774
|
-
rules: {
|
|
775
|
-
...unicorn.configs["flat/recommended"].rules
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
configs.push({
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
if (options.html) {
|
|
316
|
+
configs2.push({
|
|
780
317
|
files: [
|
|
781
|
-
|
|
318
|
+
GLOB_HTML
|
|
782
319
|
],
|
|
783
|
-
|
|
784
|
-
|
|
320
|
+
languageOptions: {
|
|
321
|
+
parser: parserPlain
|
|
785
322
|
},
|
|
786
|
-
|
|
323
|
+
name: "storm/formatter/html",
|
|
324
|
+
rules: {
|
|
325
|
+
"format/prettier": [
|
|
326
|
+
"error",
|
|
327
|
+
mergePrettierOptions(prettierOptions, {
|
|
328
|
+
parser: "html"
|
|
329
|
+
})
|
|
330
|
+
]
|
|
331
|
+
}
|
|
787
332
|
});
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
333
|
+
}
|
|
334
|
+
if (options.xml) {
|
|
335
|
+
configs2.push({
|
|
336
|
+
files: [
|
|
337
|
+
GLOB_XML
|
|
338
|
+
],
|
|
339
|
+
languageOptions: {
|
|
340
|
+
parser: parserPlain
|
|
793
341
|
},
|
|
342
|
+
name: "storm/formatter/xml",
|
|
343
|
+
rules: {
|
|
344
|
+
"format/prettier": [
|
|
345
|
+
"error",
|
|
346
|
+
mergePrettierOptions({
|
|
347
|
+
...prettierXmlOptions,
|
|
348
|
+
...prettierOptions
|
|
349
|
+
}, {
|
|
350
|
+
parser: "xml",
|
|
351
|
+
plugins: [
|
|
352
|
+
"@prettier/plugin-xml"
|
|
353
|
+
]
|
|
354
|
+
})
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
if (options.svg) {
|
|
360
|
+
configs2.push({
|
|
794
361
|
files: [
|
|
795
|
-
|
|
362
|
+
GLOB_SVG
|
|
796
363
|
],
|
|
364
|
+
languageOptions: {
|
|
365
|
+
parser: parserPlain
|
|
366
|
+
},
|
|
367
|
+
name: "storm/formatter/svg",
|
|
797
368
|
rules: {
|
|
798
|
-
"
|
|
369
|
+
"format/prettier": [
|
|
799
370
|
"error",
|
|
800
|
-
{
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
371
|
+
mergePrettierOptions({
|
|
372
|
+
...prettierXmlOptions,
|
|
373
|
+
...prettierOptions
|
|
374
|
+
}, {
|
|
375
|
+
parser: "xml",
|
|
376
|
+
plugins: [
|
|
377
|
+
"@prettier/plugin-xml"
|
|
378
|
+
]
|
|
379
|
+
})
|
|
805
380
|
]
|
|
806
381
|
}
|
|
807
382
|
});
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
{
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
"
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
}
|
|
829
|
-
];
|
|
830
|
-
if (useReactCompiler) {
|
|
831
|
-
reactConfigs.push({
|
|
832
|
-
files: [
|
|
833
|
-
"**/*.tsx"
|
|
834
|
-
],
|
|
835
|
-
plugins: {
|
|
836
|
-
"react-compiler": reactCompiler
|
|
837
|
-
},
|
|
838
|
-
rules: {
|
|
839
|
-
"react-compiler/react-compiler": "error"
|
|
383
|
+
}
|
|
384
|
+
if (options.markdown) {
|
|
385
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
386
|
+
configs2.push({
|
|
387
|
+
files: [
|
|
388
|
+
GLOB_MARKDOWN
|
|
389
|
+
],
|
|
390
|
+
languageOptions: {
|
|
391
|
+
parser: parserPlain
|
|
392
|
+
},
|
|
393
|
+
name: "storm/formatter/markdown",
|
|
394
|
+
rules: {
|
|
395
|
+
[`format/${formater}`]: [
|
|
396
|
+
"error",
|
|
397
|
+
formater === "prettier" ? mergePrettierOptions(prettierOptions, {
|
|
398
|
+
embeddedLanguageFormatting: "off",
|
|
399
|
+
parser: "markdown"
|
|
400
|
+
}) : {
|
|
401
|
+
...dprintOptions,
|
|
402
|
+
language: "markdown"
|
|
840
403
|
}
|
|
841
|
-
|
|
404
|
+
]
|
|
842
405
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
configs.push({
|
|
848
|
-
...next.configs["core-web-vitals"],
|
|
849
|
-
files: options.nextFiles
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
const typescriptConfig = {
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
if (options.astro) {
|
|
409
|
+
configs2.push({
|
|
853
410
|
files: [
|
|
854
|
-
|
|
411
|
+
GLOB_ASTRO
|
|
855
412
|
],
|
|
856
413
|
languageOptions: {
|
|
857
|
-
|
|
858
|
-
...Object.fromEntries(Object.keys(globalsObj).flatMap((group) => Object.keys(globalsObj[group]).map((key) => [
|
|
859
|
-
key,
|
|
860
|
-
"readonly"
|
|
861
|
-
]))),
|
|
862
|
-
...globalsObj.browser,
|
|
863
|
-
...globalsObj.node,
|
|
864
|
-
...globals,
|
|
865
|
-
window: "readonly"
|
|
866
|
-
},
|
|
867
|
-
parserOptions: {
|
|
868
|
-
projectService: true,
|
|
869
|
-
ecmaFeatures: {
|
|
870
|
-
jsx: react !== false
|
|
871
|
-
}
|
|
872
|
-
}
|
|
414
|
+
parser: parserPlain
|
|
873
415
|
},
|
|
416
|
+
name: "storm/formatter/astro",
|
|
874
417
|
rules: {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
}, {})
|
|
418
|
+
"format/prettier": [
|
|
419
|
+
"error",
|
|
420
|
+
mergePrettierOptions(prettierOptions, {
|
|
421
|
+
parser: "astro",
|
|
422
|
+
plugins: [
|
|
423
|
+
"prettier-plugin-astro"
|
|
424
|
+
]
|
|
425
|
+
})
|
|
426
|
+
]
|
|
885
427
|
}
|
|
886
|
-
};
|
|
887
|
-
if (parserOptions) {
|
|
888
|
-
typescriptConfig.languageOptions ??= {};
|
|
889
|
-
typescriptConfig.languageOptions.parserOptions = parserOptions;
|
|
890
|
-
}
|
|
891
|
-
if (tsconfig) {
|
|
892
|
-
typescriptConfig.languageOptions ??= {};
|
|
893
|
-
typescriptConfig.languageOptions.parserOptions ??= {};
|
|
894
|
-
typescriptConfig.languageOptions.parserOptions.project = tsconfig;
|
|
895
|
-
}
|
|
896
|
-
configs.push(typescriptConfig);
|
|
897
|
-
if (options.markdown) {
|
|
898
|
-
configs.push(...markdown.configs.recommended);
|
|
899
|
-
configs.push({
|
|
900
|
-
files: [
|
|
901
|
-
CODE_BLOCK
|
|
902
|
-
],
|
|
903
|
-
processor: "markdown/markdown",
|
|
904
|
-
rules: {
|
|
905
|
-
"unicorn/filename-case": "off",
|
|
906
|
-
"no-undef": "off",
|
|
907
|
-
"no-unused-expressions": "off",
|
|
908
|
-
"padded-blocks": "off",
|
|
909
|
-
"no-empty-pattern": "off",
|
|
910
|
-
"no-redeclare": "off",
|
|
911
|
-
"no-import-assign": "off",
|
|
912
|
-
...options.markdown
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
configs.push({
|
|
916
|
-
files: [
|
|
917
|
-
"**/*.md/*.js",
|
|
918
|
-
"**/*.md/*.ts"
|
|
919
|
-
],
|
|
920
|
-
rules: {
|
|
921
|
-
"unicorn/filename-case": "off",
|
|
922
|
-
"no-undef": "off",
|
|
923
|
-
"no-unused-expressions": "off",
|
|
924
|
-
"padded-blocks": "off",
|
|
925
|
-
"no-empty-pattern": "off",
|
|
926
|
-
"no-redeclare": "off",
|
|
927
|
-
"no-import-assign": "off",
|
|
928
|
-
...options.markdown
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
writeTrace(formatLogMessage(configs, {
|
|
933
|
-
skip: [
|
|
934
|
-
"globals"
|
|
935
|
-
]
|
|
936
|
-
}), {
|
|
937
|
-
logLevel
|
|
938
|
-
});
|
|
939
|
-
const result = formatConfig("Preset", configs.reduce((ret, config) => {
|
|
940
|
-
delete config.parserOptions;
|
|
941
|
-
const existingIndex = ret.findIndex((existing) => areFilesEqual(existing.files, config.files));
|
|
942
|
-
if (existingIndex >= 0) {
|
|
943
|
-
ret[existingIndex] = defu(ret[existingIndex], config);
|
|
944
|
-
} else {
|
|
945
|
-
ret.push(config);
|
|
946
|
-
}
|
|
947
|
-
return ret;
|
|
948
|
-
}, []));
|
|
949
|
-
result.unshift({
|
|
950
|
-
ignores: ignoredFiles
|
|
951
428
|
});
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
429
|
+
configs2.push({
|
|
430
|
+
files: [
|
|
431
|
+
GLOB_ASTRO,
|
|
432
|
+
GLOB_ASTRO_TS
|
|
433
|
+
],
|
|
434
|
+
name: "storm/formatter/astro/disables",
|
|
435
|
+
rules: {
|
|
436
|
+
"style/arrow-parens": "off",
|
|
437
|
+
"style/block-spacing": "off",
|
|
438
|
+
"style/comma-dangle": "off",
|
|
439
|
+
"style/indent": "off",
|
|
440
|
+
"style/no-multi-spaces": "off",
|
|
441
|
+
"style/quotes": "off",
|
|
442
|
+
"style/semi": "off"
|
|
443
|
+
}
|
|
961
444
|
});
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
445
|
+
}
|
|
446
|
+
if (options.graphql) {
|
|
447
|
+
configs2.push({
|
|
448
|
+
files: [
|
|
449
|
+
GLOB_GRAPHQL
|
|
450
|
+
],
|
|
451
|
+
languageOptions: {
|
|
452
|
+
parser: parserPlain
|
|
453
|
+
},
|
|
454
|
+
name: "storm/formatter/graphql",
|
|
455
|
+
rules: {
|
|
456
|
+
"format/prettier": [
|
|
457
|
+
"error",
|
|
458
|
+
mergePrettierOptions(prettierOptions, {
|
|
459
|
+
parser: "graphql"
|
|
460
|
+
})
|
|
461
|
+
]
|
|
462
|
+
}
|
|
966
463
|
});
|
|
967
|
-
|
|
968
|
-
|
|
464
|
+
}
|
|
465
|
+
return configs2;
|
|
466
|
+
}
|
|
467
|
+
__name(formatters, "formatters");
|
|
468
|
+
|
|
469
|
+
// src/configs/graphql.ts
|
|
470
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
471
|
+
var compat = new FlatCompat({
|
|
472
|
+
// import.meta.dirname is available after Node.js v20.11.0
|
|
473
|
+
baseDirectory: import.meta.dirname
|
|
474
|
+
});
|
|
475
|
+
async function graphql(options = {}) {
|
|
476
|
+
const { relay = true, operations = true, schema = true } = options;
|
|
477
|
+
await ensurePackages([
|
|
478
|
+
"@graphql-eslint/eslint-plugin",
|
|
479
|
+
"eslint-plugin-relay"
|
|
480
|
+
]);
|
|
481
|
+
const [pluginGraphQL] = await Promise.all([
|
|
482
|
+
interopDefault(import("@graphql-eslint/eslint-plugin"))
|
|
483
|
+
]);
|
|
484
|
+
return [
|
|
485
|
+
{
|
|
486
|
+
name: "storm/graphql/setup",
|
|
487
|
+
files: [
|
|
488
|
+
"**/*.graphql",
|
|
489
|
+
"**/*.gql"
|
|
490
|
+
],
|
|
491
|
+
languageOptions: {
|
|
492
|
+
parser: pluginGraphQL.parser
|
|
493
|
+
},
|
|
494
|
+
plugins: {
|
|
495
|
+
"@graphql-eslint": pluginGraphQL
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
name: "storm/graphql/rules",
|
|
500
|
+
plugins: {
|
|
501
|
+
graphql: pluginGraphQL
|
|
502
|
+
},
|
|
503
|
+
rules: {
|
|
504
|
+
...schema ? {
|
|
505
|
+
"@graphql-eslint/description-style": "error",
|
|
506
|
+
"@graphql-eslint/known-argument-names": "error",
|
|
507
|
+
"@graphql-eslint/known-directives": "error",
|
|
508
|
+
"@graphql-eslint/known-type-names": "error",
|
|
509
|
+
"@graphql-eslint/lone-schema-definition": "error",
|
|
510
|
+
"@graphql-eslint/naming-convention": [
|
|
511
|
+
"error",
|
|
512
|
+
{
|
|
513
|
+
types: "PascalCase",
|
|
514
|
+
FieldDefinition: "camelCase",
|
|
515
|
+
InputValueDefinition: "camelCase",
|
|
516
|
+
Argument: "camelCase",
|
|
517
|
+
DirectiveDefinition: "camelCase",
|
|
518
|
+
EnumValueDefinition: "UPPER_CASE",
|
|
519
|
+
"FieldDefinition[parent.name.value=Query]": {
|
|
520
|
+
forbiddenPrefixes: [
|
|
521
|
+
"query",
|
|
522
|
+
"get"
|
|
523
|
+
],
|
|
524
|
+
forbiddenSuffixes: [
|
|
525
|
+
"Query"
|
|
526
|
+
]
|
|
527
|
+
},
|
|
528
|
+
"FieldDefinition[parent.name.value=Mutation]": {
|
|
529
|
+
forbiddenPrefixes: [
|
|
530
|
+
"mutation"
|
|
531
|
+
],
|
|
532
|
+
forbiddenSuffixes: [
|
|
533
|
+
"Mutation"
|
|
534
|
+
]
|
|
535
|
+
},
|
|
536
|
+
"FieldDefinition[parent.name.value=Subscription]": {
|
|
537
|
+
forbiddenPrefixes: [
|
|
538
|
+
"subscription"
|
|
539
|
+
],
|
|
540
|
+
forbiddenSuffixes: [
|
|
541
|
+
"Subscription"
|
|
542
|
+
]
|
|
543
|
+
},
|
|
544
|
+
"EnumTypeDefinition,EnumTypeExtension": {
|
|
545
|
+
forbiddenPrefixes: [
|
|
546
|
+
"Enum"
|
|
547
|
+
],
|
|
548
|
+
forbiddenSuffixes: [
|
|
549
|
+
"Enum"
|
|
550
|
+
]
|
|
551
|
+
},
|
|
552
|
+
"InterfaceTypeDefinition,InterfaceTypeExtension": {
|
|
553
|
+
forbiddenPrefixes: [
|
|
554
|
+
"Interface"
|
|
555
|
+
],
|
|
556
|
+
forbiddenSuffixes: [
|
|
557
|
+
"Interface"
|
|
558
|
+
]
|
|
559
|
+
},
|
|
560
|
+
"UnionTypeDefinition,UnionTypeExtension": {
|
|
561
|
+
forbiddenPrefixes: [
|
|
562
|
+
"Union"
|
|
563
|
+
],
|
|
564
|
+
forbiddenSuffixes: [
|
|
565
|
+
"Union"
|
|
566
|
+
]
|
|
567
|
+
},
|
|
568
|
+
"ObjectTypeDefinition,ObjectTypeExtension": {
|
|
569
|
+
forbiddenPrefixes: [
|
|
570
|
+
"Type"
|
|
571
|
+
],
|
|
572
|
+
forbiddenSuffixes: [
|
|
573
|
+
"Type"
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
],
|
|
578
|
+
"@graphql-eslint/no-hashtag-description": "error",
|
|
579
|
+
"@graphql-eslint/no-typename-prefix": "error",
|
|
580
|
+
"@graphql-eslint/no-unreachable-types": "error",
|
|
581
|
+
"@graphql-eslint/possible-type-extension": "error",
|
|
582
|
+
"@graphql-eslint/provided-required-arguments": "error",
|
|
583
|
+
"@graphql-eslint/require-deprecation-reason": "error",
|
|
584
|
+
"@graphql-eslint/require-description": [
|
|
585
|
+
"error",
|
|
586
|
+
{
|
|
587
|
+
types: true,
|
|
588
|
+
DirectiveDefinition: true,
|
|
589
|
+
rootField: true
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
"@graphql-eslint/strict-id-in-types": "error",
|
|
593
|
+
"@graphql-eslint/unique-directive-names": "error",
|
|
594
|
+
"@graphql-eslint/unique-directive-names-per-location": "error",
|
|
595
|
+
"@graphql-eslint/unique-enum-value-names": "error",
|
|
596
|
+
"@graphql-eslint/unique-field-definition-names": "error",
|
|
597
|
+
"@graphql-eslint/unique-operation-types": "error",
|
|
598
|
+
"@graphql-eslint/unique-type-names": "error"
|
|
599
|
+
} : {},
|
|
600
|
+
...operations ? {
|
|
601
|
+
"@graphql-eslint/executable-definitions": "error",
|
|
602
|
+
"@graphql-eslint/fields-on-correct-type": "error",
|
|
603
|
+
"@graphql-eslint/fragments-on-composite-type": "error",
|
|
604
|
+
"@graphql-eslint/known-argument-names": "error",
|
|
605
|
+
"@graphql-eslint/known-directives": "error",
|
|
606
|
+
"@graphql-eslint/known-fragment-names": "error",
|
|
607
|
+
"@graphql-eslint/known-type-names": "error",
|
|
608
|
+
"@graphql-eslint/lone-anonymous-operation": "error",
|
|
609
|
+
"@graphql-eslint/naming-convention": [
|
|
610
|
+
"error",
|
|
611
|
+
{
|
|
612
|
+
VariableDefinition: "camelCase",
|
|
613
|
+
OperationDefinition: {
|
|
614
|
+
style: "PascalCase",
|
|
615
|
+
forbiddenPrefixes: [
|
|
616
|
+
"Query",
|
|
617
|
+
"Mutation",
|
|
618
|
+
"Subscription",
|
|
619
|
+
"Get"
|
|
620
|
+
],
|
|
621
|
+
forbiddenSuffixes: [
|
|
622
|
+
"Query",
|
|
623
|
+
"Mutation",
|
|
624
|
+
"Subscription"
|
|
625
|
+
]
|
|
626
|
+
},
|
|
627
|
+
FragmentDefinition: {
|
|
628
|
+
style: "PascalCase",
|
|
629
|
+
forbiddenPrefixes: [
|
|
630
|
+
"Fragment"
|
|
631
|
+
],
|
|
632
|
+
forbiddenSuffixes: [
|
|
633
|
+
"Fragment"
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
],
|
|
638
|
+
"@graphql-eslint/no-anonymous-operations": "error",
|
|
639
|
+
"@graphql-eslint/no-deprecated": "error",
|
|
640
|
+
"@graphql-eslint/no-duplicate-fields": "error",
|
|
641
|
+
"@graphql-eslint/no-fragment-cycles": "error",
|
|
642
|
+
"@graphql-eslint/no-undefined-variables": "error",
|
|
643
|
+
"@graphql-eslint/no-unused-fragments": "error",
|
|
644
|
+
"@graphql-eslint/no-unused-variables": "error",
|
|
645
|
+
"@graphql-eslint/one-field-subscriptions": "error",
|
|
646
|
+
"@graphql-eslint/overlapping-fields-can-be-merged": "error",
|
|
647
|
+
"@graphql-eslint/possible-fragment-spread": "error",
|
|
648
|
+
"@graphql-eslint/provided-required-arguments": "error",
|
|
649
|
+
"@graphql-eslint/require-selections": "error",
|
|
650
|
+
"@graphql-eslint/scalar-leafs": "error",
|
|
651
|
+
"@graphql-eslint/selection-set-depth": [
|
|
652
|
+
"error",
|
|
653
|
+
{
|
|
654
|
+
maxDepth: 7
|
|
655
|
+
}
|
|
656
|
+
],
|
|
657
|
+
"@graphql-eslint/unique-argument-names": "error",
|
|
658
|
+
"@graphql-eslint/unique-directive-names-per-location": "error",
|
|
659
|
+
"@graphql-eslint/unique-fragment-name": "error",
|
|
660
|
+
"@graphql-eslint/unique-input-field-names": "error",
|
|
661
|
+
"@graphql-eslint/unique-operation-name": "error",
|
|
662
|
+
"@graphql-eslint/unique-variable-names": "error",
|
|
663
|
+
"@graphql-eslint/value-literals-of-correct-type": "error",
|
|
664
|
+
"@graphql-eslint/variables-are-input-types": "error",
|
|
665
|
+
"@graphql-eslint/variables-in-allowed-position": "error"
|
|
666
|
+
} : {}
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
...relay ? compat.config({
|
|
670
|
+
name: "storm/graphql/relay",
|
|
671
|
+
plugins: [
|
|
672
|
+
"relay"
|
|
673
|
+
],
|
|
674
|
+
extends: [
|
|
675
|
+
"plugin:relay/ts-recommended"
|
|
676
|
+
],
|
|
677
|
+
rules: {
|
|
678
|
+
// errors
|
|
679
|
+
"relay/graphql-syntax": "error",
|
|
680
|
+
"relay/graphql-naming": "error",
|
|
681
|
+
// warnings
|
|
682
|
+
"relay/compat-uses-vars": "warn",
|
|
683
|
+
"relay/generated-typescript-types": "warn",
|
|
684
|
+
"relay/no-future-added-value": "warn",
|
|
685
|
+
"relay/unused-fields": "warn",
|
|
686
|
+
"relay/must-colocate-fragment-spreads": "warn",
|
|
687
|
+
"relay/function-required-argument": "warn",
|
|
688
|
+
"relay/hook-required-argument": "warn",
|
|
689
|
+
// @graphql-eslint rules
|
|
690
|
+
"@graphql-eslint/relay-arguments": "error",
|
|
691
|
+
"@graphql-eslint/relay-connection-types": "error",
|
|
692
|
+
"@graphql-eslint/relay-edge-types": "error",
|
|
693
|
+
"@graphql-eslint/relay-page-info": "error"
|
|
694
|
+
}
|
|
695
|
+
}) : []
|
|
696
|
+
];
|
|
697
|
+
}
|
|
698
|
+
__name(graphql, "graphql");
|
|
699
|
+
|
|
700
|
+
// src/configs/ignores.ts
|
|
701
|
+
async function ignores(userIgnores = []) {
|
|
702
|
+
return [
|
|
703
|
+
{
|
|
704
|
+
ignores: [
|
|
705
|
+
...GLOB_EXCLUDE,
|
|
706
|
+
...userIgnores
|
|
707
|
+
],
|
|
708
|
+
name: "storm/ignores"
|
|
709
|
+
}
|
|
710
|
+
];
|
|
711
|
+
}
|
|
712
|
+
__name(ignores, "ignores");
|
|
713
|
+
|
|
714
|
+
// src/plugins.ts
|
|
715
|
+
import { default as default2 } from "@cspell/eslint-plugin";
|
|
716
|
+
import { default as default3 } from "@nx/eslint-plugin/nx.js";
|
|
717
|
+
import * as pluginImport from "eslint-plugin-import-x";
|
|
718
|
+
import { default as default4 } from "eslint-plugin-n";
|
|
719
|
+
import { default as default5 } from "eslint-plugin-perfectionist";
|
|
720
|
+
import { default as default6 } from "eslint-plugin-unicorn";
|
|
721
|
+
import { default as default7 } from "eslint-plugin-unused-imports";
|
|
722
|
+
|
|
723
|
+
// src/configs/imports.ts
|
|
724
|
+
async function imports(options = {}) {
|
|
725
|
+
const { stylistic: stylistic2 = true } = options;
|
|
726
|
+
return [
|
|
727
|
+
{
|
|
728
|
+
name: "storm/imports/rules",
|
|
729
|
+
plugins: {
|
|
730
|
+
import: pluginImport
|
|
731
|
+
},
|
|
732
|
+
rules: {
|
|
733
|
+
"import/consistent-type-specifier-style": [
|
|
734
|
+
"error",
|
|
735
|
+
"prefer-top-level"
|
|
736
|
+
],
|
|
737
|
+
"import/first": "error",
|
|
738
|
+
"import/no-duplicates": "error",
|
|
739
|
+
"import/no-mutable-exports": "error",
|
|
740
|
+
"import/no-named-default": "error",
|
|
741
|
+
"import/no-self-import": "error",
|
|
742
|
+
"import/no-webpack-loader-syntax": "error",
|
|
743
|
+
...stylistic2 ? {
|
|
744
|
+
"import/newline-after-import": [
|
|
745
|
+
"error",
|
|
746
|
+
{
|
|
747
|
+
count: 1
|
|
748
|
+
}
|
|
749
|
+
]
|
|
750
|
+
} : {}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
];
|
|
754
|
+
}
|
|
755
|
+
__name(imports, "imports");
|
|
756
|
+
|
|
757
|
+
// src/configs/javascript.ts
|
|
758
|
+
import defu from "defu";
|
|
759
|
+
import globalsLib from "globals";
|
|
760
|
+
async function javascript(options = {}) {
|
|
761
|
+
const { isInEditor = false, overrides = {}, name = "storm", globals = {} } = options;
|
|
762
|
+
return [
|
|
763
|
+
{
|
|
764
|
+
name: "storm/javascript/setup",
|
|
765
|
+
languageOptions: {
|
|
766
|
+
ecmaVersion: 2022,
|
|
767
|
+
globals: defu(globals, {
|
|
768
|
+
...globalsLib.browser,
|
|
769
|
+
...globalsLib.es2021,
|
|
770
|
+
...globalsLib.node,
|
|
771
|
+
document: "readonly",
|
|
772
|
+
navigator: "readonly",
|
|
773
|
+
window: "readonly"
|
|
774
|
+
}),
|
|
775
|
+
parserOptions: {
|
|
776
|
+
ecmaFeatures: {
|
|
777
|
+
jsx: true
|
|
778
|
+
},
|
|
779
|
+
ecmaVersion: 2022,
|
|
780
|
+
sourceType: "module"
|
|
781
|
+
},
|
|
782
|
+
sourceType: "module"
|
|
783
|
+
},
|
|
784
|
+
linterOptions: {
|
|
785
|
+
reportUnusedDisableDirectives: true
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
// Banner
|
|
790
|
+
...banner_plugin_default.configs["recommended"],
|
|
791
|
+
name: "storm/javascript/banner",
|
|
792
|
+
plugins: {
|
|
793
|
+
banner: banner_plugin_default
|
|
794
|
+
},
|
|
795
|
+
rules: {
|
|
796
|
+
"banner/banner": [
|
|
797
|
+
"error",
|
|
798
|
+
{
|
|
799
|
+
commentType: "block",
|
|
800
|
+
numNewlines: 2,
|
|
801
|
+
repositoryName: name
|
|
802
|
+
}
|
|
803
|
+
]
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: "storm/javascript/rules",
|
|
808
|
+
plugins: {
|
|
809
|
+
"unused-imports": default7
|
|
810
|
+
},
|
|
811
|
+
rules: {
|
|
812
|
+
// disallow use of console
|
|
813
|
+
"no-console": "error",
|
|
814
|
+
// Disallows expressions where the operation doesn't affect the value
|
|
815
|
+
// https://eslint.org/docs/rules/no-constant-binary-expression
|
|
816
|
+
// TODO: semver-major, enable
|
|
817
|
+
"no-constant-binary-expression": "off",
|
|
818
|
+
// disallow use of constant expressions in conditions
|
|
819
|
+
"no-constant-condition": "warn",
|
|
820
|
+
// disallow control characters in regular expressions
|
|
821
|
+
"no-control-regex": "error",
|
|
822
|
+
// disallow use of debugger
|
|
823
|
+
"no-debugger": "warn",
|
|
824
|
+
// disallow duplicate arguments in functions
|
|
825
|
+
"no-dupe-args": "error",
|
|
826
|
+
// Disallow duplicate conditions in if-else-if chains
|
|
827
|
+
// https://eslint.org/docs/rules/no-dupe-else-if
|
|
828
|
+
"no-dupe-else-if": "error",
|
|
829
|
+
// disallow duplicate keys when creating object literals
|
|
830
|
+
"no-dupe-keys": "error",
|
|
831
|
+
// disallow a duplicate case label.
|
|
832
|
+
"no-duplicate-case": "error",
|
|
833
|
+
// disallow empty statements
|
|
834
|
+
"no-empty": "error",
|
|
835
|
+
// disallow the use of empty character classes in regular expressions
|
|
836
|
+
"no-empty-character-class": "error",
|
|
837
|
+
// disallow assigning to the exception in a catch block
|
|
838
|
+
"no-ex-assign": "error",
|
|
839
|
+
// disallow double-negation boolean casts in a boolean context
|
|
840
|
+
// https://eslint.org/docs/rules/no-extra-boolean-cast
|
|
841
|
+
"no-extra-boolean-cast": "error",
|
|
842
|
+
// disallow unnecessary parentheses
|
|
843
|
+
// https://eslint.org/docs/rules/no-extra-parens
|
|
844
|
+
"no-extra-parens": [
|
|
845
|
+
"off",
|
|
846
|
+
"all",
|
|
847
|
+
{
|
|
848
|
+
conditionalAssign: true,
|
|
849
|
+
nestedBinaryExpressions: false,
|
|
850
|
+
returnAssign: false,
|
|
851
|
+
ignoreJSX: "all",
|
|
852
|
+
enforceForArrowConditionals: false
|
|
853
|
+
}
|
|
854
|
+
],
|
|
855
|
+
// disallow unnecessary semicolons
|
|
856
|
+
"no-extra-semi": "error",
|
|
857
|
+
// disallow overwriting functions written as function declarations
|
|
858
|
+
"no-func-assign": "off",
|
|
859
|
+
// https://eslint.org/docs/rules/no-import-assign
|
|
860
|
+
"no-import-assign": "error",
|
|
861
|
+
// disallow function or variable declarations in nested blocks
|
|
862
|
+
"no-inner-declarations": "warn",
|
|
863
|
+
// disallow invalid regular expression strings in the RegExp constructor
|
|
864
|
+
"no-invalid-regexp": "error",
|
|
865
|
+
// disallow irregular whitespace outside of strings and comments
|
|
866
|
+
"no-irregular-whitespace": "error",
|
|
867
|
+
// Disallow Number Literals That Lose Precision
|
|
868
|
+
// https://eslint.org/docs/rules/no-loss-of-precision
|
|
869
|
+
"no-loss-of-precision": "error",
|
|
870
|
+
// Disallow characters which are made with multiple code points in character class syntax
|
|
871
|
+
// https://eslint.org/docs/rules/no-misleading-character-class
|
|
872
|
+
"no-misleading-character-class": "error",
|
|
873
|
+
// disallow the use of object properties of the global object (Math and JSON) as functions
|
|
874
|
+
"no-obj-calls": "error",
|
|
875
|
+
// Disallow new operators with global non-constructor functions
|
|
876
|
+
// https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
|
|
877
|
+
// TODO: semver-major, enable
|
|
878
|
+
"no-new-native-nonconstructor": "off",
|
|
879
|
+
// Disallow returning values from Promise executor functions
|
|
880
|
+
// https://eslint.org/docs/rules/no-promise-executor-return
|
|
881
|
+
"no-promise-executor-return": "error",
|
|
882
|
+
// disallow use of Object.prototypes builtins directly
|
|
883
|
+
// https://eslint.org/docs/rules/no-prototype-builtins
|
|
884
|
+
"no-prototype-builtins": "error",
|
|
885
|
+
// disallow multiple spaces in a regular expression literal
|
|
886
|
+
"no-regex-spaces": "error",
|
|
887
|
+
// Disallow returning values from setters
|
|
888
|
+
// https://eslint.org/docs/rules/no-setter-return
|
|
889
|
+
"no-setter-return": "error",
|
|
890
|
+
// disallow sparse arrays
|
|
891
|
+
"no-sparse-arrays": "error",
|
|
892
|
+
// Disallow template literal placeholder syntax in regular strings
|
|
893
|
+
// https://eslint.org/docs/rules/no-template-curly-in-string
|
|
894
|
+
"no-template-curly-in-string": "error",
|
|
895
|
+
// Avoid code that looks like two expressions but is actually one
|
|
896
|
+
// https://eslint.org/docs/rules/no-unexpected-multiline
|
|
897
|
+
"no-unexpected-multiline": "error",
|
|
898
|
+
// disallow unreachable statements after a return, throw, continue, or break statement
|
|
899
|
+
"no-unreachable": "error",
|
|
900
|
+
// Disallow loops with a body that allows only one iteration
|
|
901
|
+
// https://eslint.org/docs/rules/no-unreachable-loop
|
|
902
|
+
"no-unreachable-loop": [
|
|
903
|
+
"error",
|
|
904
|
+
{
|
|
905
|
+
ignore: []
|
|
906
|
+
// WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
|
|
907
|
+
}
|
|
908
|
+
],
|
|
909
|
+
// disallow return/throw/break/continue inside finally blocks
|
|
910
|
+
// https://eslint.org/docs/rules/no-unsafe-finally
|
|
911
|
+
"no-unsafe-finally": "error",
|
|
912
|
+
// disallow negating the left operand of relational operators
|
|
913
|
+
// https://eslint.org/docs/rules/no-unsafe-negation
|
|
914
|
+
"no-unsafe-negation": "error",
|
|
915
|
+
// disallow use of optional chaining in contexts where the undefined value is not allowed
|
|
916
|
+
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
|
|
917
|
+
"no-unsafe-optional-chaining": [
|
|
918
|
+
"error",
|
|
919
|
+
{
|
|
920
|
+
disallowArithmeticOperators: true
|
|
921
|
+
}
|
|
922
|
+
],
|
|
923
|
+
// Disallow Unused Private Class Members
|
|
924
|
+
// https://eslint.org/docs/rules/no-unused-private-class-members
|
|
925
|
+
// TODO: enable once eslint 7 is dropped (which is semver-major)
|
|
926
|
+
"no-unused-private-class-members": "off",
|
|
927
|
+
// Disallow useless backreferences in regular expressions
|
|
928
|
+
// https://eslint.org/docs/rules/no-useless-backreference
|
|
929
|
+
"no-useless-backreference": "error",
|
|
930
|
+
// disallow negation of the left operand of an in expression
|
|
931
|
+
// deprecated in favor of no-unsafe-negation
|
|
932
|
+
"no-negated-in-lhs": "off",
|
|
933
|
+
// Disallow assignments that can lead to race conditions due to usage of await or yield
|
|
934
|
+
// https://eslint.org/docs/rules/require-atomic-updates
|
|
935
|
+
// note: not enabled because it is very buggy
|
|
936
|
+
"require-atomic-updates": "off",
|
|
937
|
+
// disallow comparisons with the value NaN
|
|
938
|
+
"use-isnan": "error",
|
|
939
|
+
// ensure JSDoc comments are valid
|
|
940
|
+
// https://eslint.org/docs/rules/valid-jsdoc
|
|
941
|
+
"valid-jsdoc": "off",
|
|
942
|
+
// ensure that the results of typeof are compared against a valid string
|
|
943
|
+
// https://eslint.org/docs/rules/valid-typeof
|
|
944
|
+
"valid-typeof": [
|
|
945
|
+
"error",
|
|
946
|
+
{
|
|
947
|
+
requireStringLiterals: true
|
|
948
|
+
}
|
|
949
|
+
],
|
|
950
|
+
/*************************************************************
|
|
951
|
+
*
|
|
952
|
+
* Stylistic Rules - These rules relate to style guidelines
|
|
953
|
+
*
|
|
954
|
+
**************************************************************/
|
|
955
|
+
// enforce line breaks after opening and before closing array brackets
|
|
956
|
+
// https://eslint.org/docs/rules/array-bracket-newline
|
|
957
|
+
// TODO: enable? semver-major
|
|
958
|
+
"array-bracket-newline": [
|
|
959
|
+
"off",
|
|
960
|
+
"consistent"
|
|
961
|
+
],
|
|
962
|
+
// enforce line breaks between array elements
|
|
963
|
+
// https://eslint.org/docs/rules/array-element-newline
|
|
964
|
+
// TODO: enable? semver-major
|
|
965
|
+
"array-element-newline": [
|
|
966
|
+
"off",
|
|
967
|
+
{
|
|
968
|
+
multiline: true,
|
|
969
|
+
minItems: 3
|
|
970
|
+
}
|
|
971
|
+
],
|
|
972
|
+
// enforce spacing inside array brackets
|
|
973
|
+
"array-bracket-spacing": [
|
|
974
|
+
"error",
|
|
975
|
+
"never"
|
|
976
|
+
],
|
|
977
|
+
// enforce spacing inside single-line blocks
|
|
978
|
+
// https://eslint.org/docs/rules/block-spacing
|
|
979
|
+
"block-spacing": [
|
|
980
|
+
"error",
|
|
981
|
+
"always"
|
|
982
|
+
],
|
|
983
|
+
// enforce one true brace style
|
|
984
|
+
"brace-style": [
|
|
985
|
+
"error",
|
|
986
|
+
"1tbs",
|
|
987
|
+
{
|
|
988
|
+
allowSingleLine: true
|
|
989
|
+
}
|
|
990
|
+
],
|
|
991
|
+
// require camel case names
|
|
992
|
+
camelcase: [
|
|
993
|
+
"error",
|
|
994
|
+
{
|
|
995
|
+
properties: "never",
|
|
996
|
+
ignoreDestructuring: false
|
|
997
|
+
}
|
|
998
|
+
],
|
|
999
|
+
// enforce or disallow capitalization of the first letter of a comment
|
|
1000
|
+
// https://eslint.org/docs/rules/capitalized-comments
|
|
1001
|
+
"capitalized-comments": [
|
|
1002
|
+
"off",
|
|
1003
|
+
"never",
|
|
1004
|
+
{
|
|
1005
|
+
line: {
|
|
1006
|
+
ignorePattern: ".*",
|
|
1007
|
+
ignoreInlineComments: true,
|
|
1008
|
+
ignoreConsecutiveComments: true
|
|
1009
|
+
},
|
|
1010
|
+
block: {
|
|
1011
|
+
ignorePattern: ".*",
|
|
1012
|
+
ignoreInlineComments: true,
|
|
1013
|
+
ignoreConsecutiveComments: true
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
],
|
|
1017
|
+
// require trailing commas in multiline object literals
|
|
1018
|
+
"comma-dangle": [
|
|
1019
|
+
"error",
|
|
1020
|
+
"never"
|
|
1021
|
+
],
|
|
1022
|
+
// enforce spacing before and after comma
|
|
1023
|
+
"comma-spacing": [
|
|
1024
|
+
"error",
|
|
1025
|
+
{
|
|
1026
|
+
before: false,
|
|
1027
|
+
after: true
|
|
1028
|
+
}
|
|
1029
|
+
],
|
|
1030
|
+
// enforce one true comma style
|
|
1031
|
+
"comma-style": [
|
|
1032
|
+
"error",
|
|
1033
|
+
"last",
|
|
1034
|
+
{
|
|
1035
|
+
exceptions: {
|
|
1036
|
+
ArrayExpression: false,
|
|
1037
|
+
ArrayPattern: false,
|
|
1038
|
+
ArrowFunctionExpression: false,
|
|
1039
|
+
CallExpression: false,
|
|
1040
|
+
FunctionDeclaration: false,
|
|
1041
|
+
FunctionExpression: false,
|
|
1042
|
+
ImportDeclaration: false,
|
|
1043
|
+
ObjectExpression: false,
|
|
1044
|
+
ObjectPattern: false,
|
|
1045
|
+
VariableDeclaration: false,
|
|
1046
|
+
NewExpression: false
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
],
|
|
1050
|
+
// disallow padding inside computed properties
|
|
1051
|
+
"computed-property-spacing": [
|
|
1052
|
+
"error",
|
|
1053
|
+
"never"
|
|
1054
|
+
],
|
|
1055
|
+
// enforces consistent naming when capturing the current execution context
|
|
1056
|
+
"consistent-this": "off",
|
|
1057
|
+
// enforce newline at the end of file, with no multiple empty lines
|
|
1058
|
+
"eol-last": [
|
|
1059
|
+
"error",
|
|
1060
|
+
"always"
|
|
1061
|
+
],
|
|
1062
|
+
// https://eslint.org/docs/rules/function-call-argument-newline
|
|
1063
|
+
"function-call-argument-newline": [
|
|
1064
|
+
"error",
|
|
1065
|
+
"consistent"
|
|
1066
|
+
],
|
|
1067
|
+
// enforce spacing between functions and their invocations
|
|
1068
|
+
// https://eslint.org/docs/rules/func-call-spacing
|
|
1069
|
+
"func-call-spacing": [
|
|
1070
|
+
"error",
|
|
1071
|
+
"never"
|
|
1072
|
+
],
|
|
1073
|
+
// requires function names to match the name of the variable or property to which they are
|
|
1074
|
+
// assigned
|
|
1075
|
+
// https://eslint.org/docs/rules/func-name-matching
|
|
1076
|
+
"func-name-matching": [
|
|
1077
|
+
"off",
|
|
1078
|
+
"always",
|
|
1079
|
+
{
|
|
1080
|
+
includeCommonJSModuleExports: false,
|
|
1081
|
+
considerPropertyDescriptor: true
|
|
1082
|
+
}
|
|
1083
|
+
],
|
|
1084
|
+
// require function expressions to have a name
|
|
1085
|
+
// https://eslint.org/docs/rules/func-names
|
|
1086
|
+
"func-names": "warn",
|
|
1087
|
+
// enforces use of function declarations or expressions
|
|
1088
|
+
// https://eslint.org/docs/rules/func-style
|
|
1089
|
+
// TODO: enable
|
|
1090
|
+
"func-style": [
|
|
1091
|
+
"off",
|
|
1092
|
+
"expression"
|
|
1093
|
+
],
|
|
1094
|
+
// require line breaks inside function parentheses if there are line breaks between parameters
|
|
1095
|
+
// https://eslint.org/docs/rules/function-paren-newline
|
|
1096
|
+
"function-paren-newline": "off",
|
|
1097
|
+
// disallow specified identifiers
|
|
1098
|
+
// https://eslint.org/docs/rules/id-denylist
|
|
1099
|
+
"id-denylist": "off",
|
|
1100
|
+
// this option enforces minimum and maximum identifier lengths
|
|
1101
|
+
// (variable names, property names etc.)
|
|
1102
|
+
"id-length": "off",
|
|
1103
|
+
// require identifiers to match the provided regular expression
|
|
1104
|
+
"id-match": "off",
|
|
1105
|
+
// Enforce the location of arrow function bodies with implicit returns
|
|
1106
|
+
// https://eslint.org/docs/rules/implicit-arrow-linebreak
|
|
1107
|
+
"implicit-arrow-linebreak": "off",
|
|
1108
|
+
// this option sets a specific tab width for your code
|
|
1109
|
+
// https://eslint.org/docs/rules/indent
|
|
1110
|
+
indent: "off",
|
|
1111
|
+
// "error",
|
|
1112
|
+
// 2,
|
|
1113
|
+
// {
|
|
1114
|
+
// SwitchCase: 1,
|
|
1115
|
+
// VariableDeclarator: 1,
|
|
1116
|
+
// outerIIFEBody: 1,
|
|
1117
|
+
// // MemberExpression: null,
|
|
1118
|
+
// FunctionDeclaration: {
|
|
1119
|
+
// parameters: 1,
|
|
1120
|
+
// body: 1
|
|
1121
|
+
// },
|
|
1122
|
+
// FunctionExpression: {
|
|
1123
|
+
// parameters: 1,
|
|
1124
|
+
// body: 1
|
|
1125
|
+
// },
|
|
1126
|
+
// CallExpression: {
|
|
1127
|
+
// arguments: 1
|
|
1128
|
+
// },
|
|
1129
|
+
// ArrayExpression: 1,
|
|
1130
|
+
// ObjectExpression: 1,
|
|
1131
|
+
// ImportDeclaration: 1,
|
|
1132
|
+
// flatTernaryExpressions: false,
|
|
1133
|
+
// // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
|
|
1134
|
+
// ignoredNodes: [
|
|
1135
|
+
// "JSXElement",
|
|
1136
|
+
// "JSXElement > *",
|
|
1137
|
+
// "JSXAttribute",
|
|
1138
|
+
// "JSXIdentifier",
|
|
1139
|
+
// "JSXNamespacedName",
|
|
1140
|
+
// "JSXMemberExpression",
|
|
1141
|
+
// "JSXSpreadAttribute",
|
|
1142
|
+
// "JSXExpressionContainer",
|
|
1143
|
+
// "JSXOpeningElement",
|
|
1144
|
+
// "JSXClosingElement",
|
|
1145
|
+
// "JSXFragment",
|
|
1146
|
+
// "JSXOpeningFragment",
|
|
1147
|
+
// "JSXClosingFragment",
|
|
1148
|
+
// "JSXText",
|
|
1149
|
+
// "JSXEmptyExpression",
|
|
1150
|
+
// "JSXSpreadChild"
|
|
1151
|
+
// ],
|
|
1152
|
+
// ignoreComments: false
|
|
1153
|
+
// }
|
|
1154
|
+
// ],
|
|
1155
|
+
// specify whether double or single quotes should be used in JSX attributes
|
|
1156
|
+
// https://eslint.org/docs/rules/jsx-quotes
|
|
1157
|
+
"jsx-quotes": [
|
|
1158
|
+
"off",
|
|
1159
|
+
"prefer-double"
|
|
1160
|
+
],
|
|
1161
|
+
// enforces spacing between keys and values in object literal properties
|
|
1162
|
+
"key-spacing": [
|
|
1163
|
+
"error",
|
|
1164
|
+
{
|
|
1165
|
+
beforeColon: false,
|
|
1166
|
+
afterColon: true
|
|
1167
|
+
}
|
|
1168
|
+
],
|
|
1169
|
+
// require a space before & after certain keywords
|
|
1170
|
+
"keyword-spacing": [
|
|
1171
|
+
"error",
|
|
1172
|
+
{
|
|
1173
|
+
before: true,
|
|
1174
|
+
after: true,
|
|
1175
|
+
overrides: {
|
|
1176
|
+
return: {
|
|
1177
|
+
after: true
|
|
1178
|
+
},
|
|
1179
|
+
throw: {
|
|
1180
|
+
after: true
|
|
1181
|
+
},
|
|
1182
|
+
case: {
|
|
1183
|
+
after: true
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
],
|
|
1188
|
+
// enforce position of line comments
|
|
1189
|
+
// https://eslint.org/docs/rules/line-comment-position
|
|
1190
|
+
// TODO: enable?
|
|
1191
|
+
"line-comment-position": [
|
|
1192
|
+
"off",
|
|
1193
|
+
{
|
|
1194
|
+
position: "above",
|
|
1195
|
+
ignorePattern: "",
|
|
1196
|
+
applyDefaultPatterns: true
|
|
1197
|
+
}
|
|
1198
|
+
],
|
|
1199
|
+
// disallow mixed 'LF' and 'CRLF' as linebreaks
|
|
1200
|
+
// https://eslint.org/docs/rules/linebreak-style
|
|
1201
|
+
"linebreak-style": [
|
|
1202
|
+
"error",
|
|
1203
|
+
"unix"
|
|
1204
|
+
],
|
|
1205
|
+
// require or disallow an empty line between class members
|
|
1206
|
+
// https://eslint.org/docs/rules/lines-between-class-members
|
|
1207
|
+
"lines-between-class-members": [
|
|
1208
|
+
"error",
|
|
1209
|
+
"always",
|
|
1210
|
+
{
|
|
1211
|
+
exceptAfterSingleLine: false
|
|
1212
|
+
}
|
|
1213
|
+
],
|
|
1214
|
+
// enforces empty lines around comments
|
|
1215
|
+
"lines-around-comment": "off",
|
|
1216
|
+
// require or disallow newlines around directives
|
|
1217
|
+
// https://eslint.org/docs/rules/lines-around-directive
|
|
1218
|
+
"lines-around-directive": [
|
|
1219
|
+
"error",
|
|
1220
|
+
{
|
|
1221
|
+
before: "always",
|
|
1222
|
+
after: "always"
|
|
1223
|
+
}
|
|
1224
|
+
],
|
|
1225
|
+
// Require or disallow logical assignment logical operator shorthand
|
|
1226
|
+
// https://eslint.org/docs/latest/rules/logical-assignment-operators
|
|
1227
|
+
// TODO, semver-major: enable
|
|
1228
|
+
"logical-assignment-operators": [
|
|
1229
|
+
"off",
|
|
1230
|
+
"always",
|
|
1231
|
+
{
|
|
1232
|
+
enforceForIfStatements: true
|
|
1233
|
+
}
|
|
1234
|
+
],
|
|
1235
|
+
// specify the maximum depth that blocks can be nested
|
|
1236
|
+
"max-depth": [
|
|
1237
|
+
"off",
|
|
1238
|
+
4
|
|
1239
|
+
],
|
|
1240
|
+
// specify the maximum length of a line in your program
|
|
1241
|
+
// https://eslint.org/docs/rules/max-len
|
|
1242
|
+
"max-len": [
|
|
1243
|
+
"error",
|
|
1244
|
+
100,
|
|
1245
|
+
2,
|
|
1246
|
+
{
|
|
1247
|
+
ignoreUrls: true,
|
|
1248
|
+
ignoreComments: true,
|
|
1249
|
+
ignoreRegExpLiterals: true,
|
|
1250
|
+
ignoreStrings: true,
|
|
1251
|
+
ignoreTemplateLiterals: true
|
|
1252
|
+
}
|
|
1253
|
+
],
|
|
1254
|
+
// specify the max number of lines in a file
|
|
1255
|
+
// https://eslint.org/docs/rules/max-lines
|
|
1256
|
+
"max-lines": [
|
|
1257
|
+
"off",
|
|
1258
|
+
{
|
|
1259
|
+
max: 300,
|
|
1260
|
+
skipBlankLines: true,
|
|
1261
|
+
skipComments: true
|
|
1262
|
+
}
|
|
1263
|
+
],
|
|
1264
|
+
// enforce a maximum function length
|
|
1265
|
+
// https://eslint.org/docs/rules/max-lines-per-function
|
|
1266
|
+
"max-lines-per-function": [
|
|
1267
|
+
"off",
|
|
1268
|
+
{
|
|
1269
|
+
max: 50,
|
|
1270
|
+
skipBlankLines: true,
|
|
1271
|
+
skipComments: true,
|
|
1272
|
+
IIFEs: true
|
|
1273
|
+
}
|
|
1274
|
+
],
|
|
1275
|
+
// specify the maximum depth callbacks can be nested
|
|
1276
|
+
"max-nested-callbacks": "off",
|
|
1277
|
+
// limits the number of parameters that can be used in the function declaration.
|
|
1278
|
+
"max-params": [
|
|
1279
|
+
"off",
|
|
1280
|
+
3
|
|
1281
|
+
],
|
|
1282
|
+
// specify the maximum number of statement allowed in a function
|
|
1283
|
+
"max-statements": [
|
|
1284
|
+
"off",
|
|
1285
|
+
10
|
|
1286
|
+
],
|
|
1287
|
+
// restrict the number of statements per line
|
|
1288
|
+
// https://eslint.org/docs/rules/max-statements-per-line
|
|
1289
|
+
"max-statements-per-line": [
|
|
1290
|
+
"off",
|
|
1291
|
+
{
|
|
1292
|
+
max: 1
|
|
1293
|
+
}
|
|
1294
|
+
],
|
|
1295
|
+
// enforce a particular style for multiline comments
|
|
1296
|
+
// https://eslint.org/docs/rules/multiline-comment-style
|
|
1297
|
+
"multiline-comment-style": [
|
|
1298
|
+
"off",
|
|
1299
|
+
"starred-block"
|
|
1300
|
+
],
|
|
1301
|
+
// require multiline ternary
|
|
1302
|
+
// https://eslint.org/docs/rules/multiline-ternary
|
|
1303
|
+
// TODO: enable?
|
|
1304
|
+
"multiline-ternary": [
|
|
1305
|
+
"off",
|
|
1306
|
+
"never"
|
|
1307
|
+
],
|
|
1308
|
+
// require a capital letter for constructors
|
|
1309
|
+
"new-cap": [
|
|
1310
|
+
"error",
|
|
1311
|
+
{
|
|
1312
|
+
newIsCap: true,
|
|
1313
|
+
newIsCapExceptions: [],
|
|
1314
|
+
capIsNew: false,
|
|
1315
|
+
capIsNewExceptions: [
|
|
1316
|
+
"Immutable.Map",
|
|
1317
|
+
"Immutable.Set",
|
|
1318
|
+
"Immutable.List"
|
|
1319
|
+
]
|
|
1320
|
+
}
|
|
1321
|
+
],
|
|
1322
|
+
"no-unused-vars": [
|
|
1323
|
+
"error",
|
|
1324
|
+
{
|
|
1325
|
+
args: "none",
|
|
1326
|
+
caughtErrors: "none",
|
|
1327
|
+
ignoreRestSiblings: true,
|
|
1328
|
+
vars: "all"
|
|
1329
|
+
}
|
|
1330
|
+
],
|
|
1331
|
+
// disallow the omission of parentheses when invoking a constructor with no arguments
|
|
1332
|
+
// https://eslint.org/docs/rules/new-parens
|
|
1333
|
+
"new-parens": "error",
|
|
1334
|
+
// allow/disallow an empty newline after var statement
|
|
1335
|
+
"newline-after-var": "off",
|
|
1336
|
+
// Require or disallow padding lines between statements
|
|
1337
|
+
// https://eslint.org/docs/rules/padding-line-between-statements
|
|
1338
|
+
"padding-line-between-statements": [
|
|
1339
|
+
"error",
|
|
1340
|
+
{
|
|
1341
|
+
blankLine: "always",
|
|
1342
|
+
prev: [
|
|
1343
|
+
"const",
|
|
1344
|
+
"let",
|
|
1345
|
+
"var"
|
|
1346
|
+
],
|
|
1347
|
+
next: "return"
|
|
1348
|
+
}
|
|
1349
|
+
],
|
|
1350
|
+
// enforces new line after each method call in the chain to make it
|
|
1351
|
+
// more readable and easy to maintain
|
|
1352
|
+
// https://eslint.org/docs/rules/newline-per-chained-call
|
|
1353
|
+
"newline-per-chained-call": [
|
|
1354
|
+
"error",
|
|
1355
|
+
{
|
|
1356
|
+
ignoreChainWithDepth: 5
|
|
1357
|
+
}
|
|
1358
|
+
],
|
|
1359
|
+
// disallow use of the Array constructor
|
|
1360
|
+
"no-array-constructor": "error",
|
|
1361
|
+
// disallow use of bitwise operators
|
|
1362
|
+
// https://eslint.org/docs/rules/no-bitwise
|
|
1363
|
+
"no-bitwise": "off",
|
|
1364
|
+
// disallow use of the continue statement
|
|
1365
|
+
// https://eslint.org/docs/rules/no-continue
|
|
1366
|
+
"no-continue": "off",
|
|
1367
|
+
// disallow comments inline after code
|
|
1368
|
+
"no-inline-comments": "off",
|
|
1369
|
+
// disallow if as the only statement in an else block
|
|
1370
|
+
// https://eslint.org/docs/rules/no-lonely-if
|
|
1371
|
+
"no-lonely-if": "error",
|
|
1372
|
+
// disallow un-paren'd mixes of different operators
|
|
1373
|
+
// https://eslint.org/docs/rules/no-mixed-operators
|
|
1374
|
+
"no-mixed-operators": [
|
|
1375
|
+
"error",
|
|
1376
|
+
{
|
|
1377
|
+
// the list of arithmetic groups disallows mixing `%` and `**`
|
|
1378
|
+
// with other arithmetic operators.
|
|
1379
|
+
groups: [
|
|
1380
|
+
[
|
|
1381
|
+
"%",
|
|
1382
|
+
"**"
|
|
1383
|
+
],
|
|
1384
|
+
[
|
|
1385
|
+
"%",
|
|
1386
|
+
"+"
|
|
1387
|
+
],
|
|
1388
|
+
[
|
|
1389
|
+
"%",
|
|
1390
|
+
"-"
|
|
1391
|
+
],
|
|
1392
|
+
[
|
|
1393
|
+
"%",
|
|
1394
|
+
"*"
|
|
1395
|
+
],
|
|
1396
|
+
[
|
|
1397
|
+
"%",
|
|
1398
|
+
"/"
|
|
1399
|
+
],
|
|
1400
|
+
[
|
|
1401
|
+
"/",
|
|
1402
|
+
"*"
|
|
1403
|
+
],
|
|
1404
|
+
[
|
|
1405
|
+
"&",
|
|
1406
|
+
"|",
|
|
1407
|
+
"<<",
|
|
1408
|
+
">>",
|
|
1409
|
+
">>>"
|
|
1410
|
+
],
|
|
1411
|
+
[
|
|
1412
|
+
"==",
|
|
1413
|
+
"!=",
|
|
1414
|
+
"===",
|
|
1415
|
+
"!=="
|
|
1416
|
+
],
|
|
1417
|
+
[
|
|
1418
|
+
"&&",
|
|
1419
|
+
"||"
|
|
1420
|
+
]
|
|
1421
|
+
],
|
|
1422
|
+
allowSamePrecedence: false
|
|
1423
|
+
}
|
|
1424
|
+
],
|
|
1425
|
+
// disallow mixed spaces and tabs for indentation
|
|
1426
|
+
"no-mixed-spaces-and-tabs": "error",
|
|
1427
|
+
// disallow use of chained assignment expressions
|
|
1428
|
+
// https://eslint.org/docs/rules/no-multi-assign
|
|
1429
|
+
"no-multi-assign": [
|
|
1430
|
+
"error"
|
|
1431
|
+
],
|
|
1432
|
+
// disallow multiple empty lines, only one newline at the end, and no new lines at the beginning
|
|
1433
|
+
// https://eslint.org/docs/rules/no-multiple-empty-lines
|
|
1434
|
+
"no-multiple-empty-lines": [
|
|
1435
|
+
"error",
|
|
1436
|
+
{
|
|
1437
|
+
max: 1,
|
|
1438
|
+
maxBOF: 0,
|
|
1439
|
+
maxEOF: 0
|
|
1440
|
+
}
|
|
1441
|
+
],
|
|
1442
|
+
// disallow negated conditions
|
|
1443
|
+
// https://eslint.org/docs/rules/no-negated-condition
|
|
1444
|
+
"no-negated-condition": "off",
|
|
1445
|
+
// disallow nested ternary expressions
|
|
1446
|
+
"no-nested-ternary": "off",
|
|
1447
|
+
// disallow use of the Object constructor
|
|
1448
|
+
"no-new-object": "error",
|
|
1449
|
+
// disallow use of unary operators, ++ and --
|
|
1450
|
+
// https://eslint.org/docs/rules/no-plusplus
|
|
1451
|
+
"no-plusplus": "off",
|
|
1452
|
+
// disallow certain syntax forms
|
|
1453
|
+
// https://eslint.org/docs/rules/no-restricted-syntax
|
|
1454
|
+
"no-restricted-syntax": [
|
|
1455
|
+
"error",
|
|
1456
|
+
// {
|
|
1457
|
+
// selector: "ForInStatement",
|
|
1458
|
+
// message:
|
|
1459
|
+
// "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
|
|
1460
|
+
// },
|
|
1461
|
+
// {
|
|
1462
|
+
// selector: "ForOfStatement",
|
|
1463
|
+
// message:
|
|
1464
|
+
// "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations."
|
|
1465
|
+
// },
|
|
1466
|
+
"TSEnumDeclaration[const=true]",
|
|
1467
|
+
"TSExportAssignment",
|
|
1468
|
+
{
|
|
1469
|
+
selector: "LabeledStatement",
|
|
1470
|
+
message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
|
|
1471
|
+
},
|
|
1472
|
+
{
|
|
1473
|
+
selector: "WithStatement",
|
|
1474
|
+
message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
|
|
1475
|
+
}
|
|
1476
|
+
],
|
|
1477
|
+
// disallow space between function identifier and application
|
|
1478
|
+
// deprecated in favor of func-call-spacing
|
|
1479
|
+
"no-spaced-func": "off",
|
|
1480
|
+
// disallow tab characters entirely
|
|
1481
|
+
"no-tabs": "error",
|
|
1482
|
+
// disallow the use of ternary operators
|
|
1483
|
+
"no-ternary": "off",
|
|
1484
|
+
// disallow trailing whitespace at the end of lines
|
|
1485
|
+
"no-trailing-spaces": [
|
|
1486
|
+
"error",
|
|
1487
|
+
{
|
|
1488
|
+
skipBlankLines: false,
|
|
1489
|
+
ignoreComments: false
|
|
1490
|
+
}
|
|
1491
|
+
],
|
|
1492
|
+
// disallow dangling underscores in identifiers
|
|
1493
|
+
// https://eslint.org/docs/rules/no-underscore-dangle
|
|
1494
|
+
"no-underscore-dangle": [
|
|
1495
|
+
"off",
|
|
1496
|
+
{
|
|
1497
|
+
allow: [],
|
|
1498
|
+
allowAfterThis: false,
|
|
1499
|
+
allowAfterSuper: false,
|
|
1500
|
+
enforceInMethodNames: true
|
|
1501
|
+
}
|
|
1502
|
+
],
|
|
1503
|
+
// disallow the use of Boolean literals in conditional expressions
|
|
1504
|
+
// also, prefer `a || b` over `a ? a : b`
|
|
1505
|
+
// https://eslint.org/docs/rules/no-unneeded-ternary
|
|
1506
|
+
"no-unneeded-ternary": [
|
|
1507
|
+
"error",
|
|
1508
|
+
{
|
|
1509
|
+
defaultAssignment: false
|
|
1510
|
+
}
|
|
1511
|
+
],
|
|
1512
|
+
// disallow whitespace before properties
|
|
1513
|
+
// https://eslint.org/docs/rules/no-whitespace-before-property
|
|
1514
|
+
"no-whitespace-before-property": "error",
|
|
1515
|
+
// enforce the location of single-line statements
|
|
1516
|
+
// https://eslint.org/docs/rules/nonblock-statement-body-position
|
|
1517
|
+
"nonblock-statement-body-position": [
|
|
1518
|
+
"error",
|
|
1519
|
+
"beside",
|
|
1520
|
+
{
|
|
1521
|
+
overrides: {}
|
|
1522
|
+
}
|
|
1523
|
+
],
|
|
1524
|
+
// require padding inside curly braces
|
|
1525
|
+
"object-curly-spacing": [
|
|
1526
|
+
"error",
|
|
1527
|
+
"always"
|
|
1528
|
+
],
|
|
1529
|
+
// enforce line breaks between braces
|
|
1530
|
+
// https://eslint.org/docs/rules/object-curly-newline
|
|
1531
|
+
"object-curly-newline": [
|
|
1532
|
+
"error",
|
|
1533
|
+
{
|
|
1534
|
+
ObjectExpression: {
|
|
1535
|
+
minProperties: 5,
|
|
1536
|
+
multiline: true,
|
|
1537
|
+
consistent: true
|
|
1538
|
+
},
|
|
1539
|
+
ObjectPattern: {
|
|
1540
|
+
minProperties: 5,
|
|
1541
|
+
multiline: true,
|
|
1542
|
+
consistent: true
|
|
1543
|
+
},
|
|
1544
|
+
ImportDeclaration: {
|
|
1545
|
+
minProperties: 5,
|
|
1546
|
+
multiline: true,
|
|
1547
|
+
consistent: true
|
|
1548
|
+
},
|
|
1549
|
+
ExportDeclaration: {
|
|
1550
|
+
minProperties: 5,
|
|
1551
|
+
multiline: true,
|
|
1552
|
+
consistent: true
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
],
|
|
1556
|
+
// enforce "same line" or "multiple line" on object properties.
|
|
1557
|
+
// https://eslint.org/docs/rules/object-property-newline
|
|
1558
|
+
"object-property-newline": [
|
|
1559
|
+
"error",
|
|
1560
|
+
{
|
|
1561
|
+
allowAllPropertiesOnSameLine: false
|
|
1562
|
+
}
|
|
1563
|
+
],
|
|
1564
|
+
// allow just one var statement per function
|
|
1565
|
+
"one-var": [
|
|
1566
|
+
"error",
|
|
1567
|
+
"never"
|
|
1568
|
+
],
|
|
1569
|
+
// require a newline around variable declaration
|
|
1570
|
+
// https://eslint.org/docs/rules/one-var-declaration-per-line
|
|
1571
|
+
"one-var-declaration-per-line": [
|
|
1572
|
+
"error",
|
|
1573
|
+
"always"
|
|
1574
|
+
],
|
|
1575
|
+
// require assignment operator shorthand where possible or prohibit it entirely
|
|
1576
|
+
// https://eslint.org/docs/rules/operator-assignment
|
|
1577
|
+
"operator-assignment": [
|
|
1578
|
+
"error",
|
|
1579
|
+
"always"
|
|
1580
|
+
],
|
|
1581
|
+
// Requires operator at the beginning of the line in multiline statements
|
|
1582
|
+
// https://eslint.org/docs/rules/operator-linebreak
|
|
1583
|
+
"operator-linebreak": [
|
|
1584
|
+
"error",
|
|
1585
|
+
"after",
|
|
1586
|
+
{
|
|
1587
|
+
overrides: {
|
|
1588
|
+
"=": "none"
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
],
|
|
1592
|
+
// disallow padding within blocks
|
|
1593
|
+
"padded-blocks": [
|
|
1594
|
+
"error",
|
|
1595
|
+
{
|
|
1596
|
+
blocks: "never",
|
|
1597
|
+
classes: "never",
|
|
1598
|
+
switches: "never"
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
allowSingleLineBlocks: true
|
|
1602
|
+
}
|
|
1603
|
+
],
|
|
1604
|
+
// Disallow the use of Math.pow in favor of the ** operator
|
|
1605
|
+
// https://eslint.org/docs/rules/prefer-exponentiation-operator
|
|
1606
|
+
"prefer-exponentiation-operator": "error",
|
|
1607
|
+
// Prefer use of an object spread over Object.assign
|
|
1608
|
+
// https://eslint.org/docs/rules/prefer-object-spread
|
|
1609
|
+
"prefer-object-spread": "error",
|
|
1610
|
+
// require quotes around object literal property names
|
|
1611
|
+
// https://eslint.org/docs/rules/quote-props.html
|
|
1612
|
+
"quote-props": [
|
|
1613
|
+
"error",
|
|
1614
|
+
"as-needed",
|
|
1615
|
+
{
|
|
1616
|
+
keywords: false,
|
|
1617
|
+
unnecessary: true,
|
|
1618
|
+
numbers: false
|
|
1619
|
+
}
|
|
1620
|
+
],
|
|
1621
|
+
// specify whether double or single quotes should be used
|
|
1622
|
+
quotes: [
|
|
1623
|
+
"error",
|
|
1624
|
+
"double",
|
|
1625
|
+
{
|
|
1626
|
+
avoidEscape: true
|
|
1627
|
+
}
|
|
1628
|
+
],
|
|
1629
|
+
// do not require jsdoc
|
|
1630
|
+
// https://eslint.org/docs/rules/require-jsdoc
|
|
1631
|
+
"require-jsdoc": "off",
|
|
1632
|
+
// require or disallow use of semicolons instead of ASI
|
|
1633
|
+
semi: [
|
|
1634
|
+
"error",
|
|
1635
|
+
"always"
|
|
1636
|
+
],
|
|
1637
|
+
// enforce spacing before and after semicolons
|
|
1638
|
+
"semi-spacing": [
|
|
1639
|
+
"error",
|
|
1640
|
+
{
|
|
1641
|
+
before: false,
|
|
1642
|
+
after: true
|
|
1643
|
+
}
|
|
1644
|
+
],
|
|
1645
|
+
// Enforce location of semicolons
|
|
1646
|
+
// https://eslint.org/docs/rules/semi-style
|
|
1647
|
+
"semi-style": [
|
|
1648
|
+
"error",
|
|
1649
|
+
"last"
|
|
1650
|
+
],
|
|
1651
|
+
// requires object keys to be sorted
|
|
1652
|
+
"sort-keys": [
|
|
1653
|
+
"off",
|
|
1654
|
+
"asc",
|
|
1655
|
+
{
|
|
1656
|
+
caseSensitive: false,
|
|
1657
|
+
natural: true
|
|
1658
|
+
}
|
|
1659
|
+
],
|
|
1660
|
+
// sort variables within the same declaration block
|
|
1661
|
+
"sort-vars": "off",
|
|
1662
|
+
// require or disallow space before blocks
|
|
1663
|
+
"space-before-blocks": "error",
|
|
1664
|
+
// require or disallow space before function opening parenthesis
|
|
1665
|
+
// https://eslint.org/docs/rules/space-before-function-paren
|
|
1666
|
+
"space-before-function-paren": "off",
|
|
1667
|
+
// "error",
|
|
1668
|
+
// {
|
|
1669
|
+
// anonymous: "always",
|
|
1670
|
+
// named: "never",
|
|
1671
|
+
// asyncArrow: "always"
|
|
1672
|
+
// }
|
|
1673
|
+
// ],
|
|
1674
|
+
// require or disallow spaces inside parentheses
|
|
1675
|
+
"space-in-parens": [
|
|
1676
|
+
"error",
|
|
1677
|
+
"never"
|
|
1678
|
+
],
|
|
1679
|
+
// require spaces around operators
|
|
1680
|
+
"space-infix-ops": "error",
|
|
1681
|
+
// Require or disallow spaces before/after unary operators
|
|
1682
|
+
// https://eslint.org/docs/rules/space-unary-ops
|
|
1683
|
+
"space-unary-ops": [
|
|
1684
|
+
"error",
|
|
1685
|
+
{
|
|
1686
|
+
words: true,
|
|
1687
|
+
nonwords: false,
|
|
1688
|
+
overrides: {}
|
|
1689
|
+
}
|
|
1690
|
+
],
|
|
1691
|
+
// require or disallow a space immediately following the // or /* in a comment
|
|
1692
|
+
// https://eslint.org/docs/rules/spaced-comment
|
|
1693
|
+
"spaced-comment": [
|
|
1694
|
+
"error",
|
|
1695
|
+
"always",
|
|
1696
|
+
{
|
|
1697
|
+
line: {
|
|
1698
|
+
exceptions: [
|
|
1699
|
+
"-",
|
|
1700
|
+
"+"
|
|
1701
|
+
],
|
|
1702
|
+
markers: [
|
|
1703
|
+
"=",
|
|
1704
|
+
"!",
|
|
1705
|
+
"/"
|
|
1706
|
+
]
|
|
1707
|
+
// space here to support sprockets directives, slash for TS /// comments
|
|
1708
|
+
},
|
|
1709
|
+
block: {
|
|
1710
|
+
exceptions: [
|
|
1711
|
+
"-",
|
|
1712
|
+
"+"
|
|
1713
|
+
],
|
|
1714
|
+
markers: [
|
|
1715
|
+
"=",
|
|
1716
|
+
"!",
|
|
1717
|
+
":",
|
|
1718
|
+
"::"
|
|
1719
|
+
],
|
|
1720
|
+
balanced: true
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
],
|
|
1724
|
+
// Enforce spacing around colons of switch statements
|
|
1725
|
+
// https://eslint.org/docs/rules/switch-colon-spacing
|
|
1726
|
+
"switch-colon-spacing": [
|
|
1727
|
+
"error",
|
|
1728
|
+
{
|
|
1729
|
+
after: true,
|
|
1730
|
+
before: false
|
|
1731
|
+
}
|
|
1732
|
+
],
|
|
1733
|
+
// Require or disallow spacing between template tags and their literals
|
|
1734
|
+
// https://eslint.org/docs/rules/template-tag-spacing
|
|
1735
|
+
"template-tag-spacing": [
|
|
1736
|
+
"error",
|
|
1737
|
+
"never"
|
|
1738
|
+
],
|
|
1739
|
+
// require or disallow the Unicode Byte Order Mark
|
|
1740
|
+
// https://eslint.org/docs/rules/unicode-bom
|
|
1741
|
+
"unicode-bom": [
|
|
1742
|
+
"error",
|
|
1743
|
+
"never"
|
|
1744
|
+
],
|
|
1745
|
+
// require regex literals to be wrapped in parentheses
|
|
1746
|
+
"wrap-regex": "off",
|
|
1747
|
+
"class-methods-use-this": "off",
|
|
1748
|
+
"accessor-pairs": [
|
|
1749
|
+
"error",
|
|
1750
|
+
{
|
|
1751
|
+
enforceForClassMembers: true,
|
|
1752
|
+
setWithoutGet: true
|
|
1753
|
+
}
|
|
1754
|
+
],
|
|
1755
|
+
"constructor-super": "error",
|
|
1756
|
+
"dot-notation": [
|
|
1757
|
+
"error",
|
|
1758
|
+
{
|
|
1759
|
+
allowKeywords: true
|
|
1760
|
+
}
|
|
1761
|
+
],
|
|
1762
|
+
"no-case-declarations": "error",
|
|
1763
|
+
"no-class-assign": "error",
|
|
1764
|
+
"no-const-assign": "error",
|
|
1765
|
+
"no-delete-var": "error",
|
|
1766
|
+
"no-dupe-class-members": "error",
|
|
1767
|
+
"no-empty-pattern": "error",
|
|
1768
|
+
"no-eval": "error",
|
|
1769
|
+
"no-extend-native": "error",
|
|
1770
|
+
"no-extra-bind": "error",
|
|
1771
|
+
"no-fallthrough": "error",
|
|
1772
|
+
"no-global-assign": "error",
|
|
1773
|
+
"no-implied-eval": "error",
|
|
1774
|
+
"no-iterator": "error",
|
|
1775
|
+
"no-labels": [
|
|
1776
|
+
"error",
|
|
1777
|
+
{
|
|
1778
|
+
allowLoop: false,
|
|
1779
|
+
allowSwitch: false
|
|
1780
|
+
}
|
|
1781
|
+
],
|
|
1782
|
+
"no-lone-blocks": "error",
|
|
1783
|
+
"no-multi-str": "error",
|
|
1784
|
+
"no-new": "error",
|
|
1785
|
+
"no-new-func": "error",
|
|
1786
|
+
"no-new-wrappers": "error",
|
|
1787
|
+
"no-octal": "error",
|
|
1788
|
+
"no-octal-escape": "error",
|
|
1789
|
+
"no-proto": "error",
|
|
1790
|
+
"no-redeclare": [
|
|
1791
|
+
"error",
|
|
1792
|
+
{
|
|
1793
|
+
builtinGlobals: false
|
|
1794
|
+
}
|
|
1795
|
+
],
|
|
1796
|
+
"no-restricted-globals": [
|
|
1797
|
+
"error",
|
|
1798
|
+
{
|
|
1799
|
+
message: "Use `globalThis` instead.",
|
|
1800
|
+
name: "global"
|
|
1801
|
+
},
|
|
1802
|
+
{
|
|
1803
|
+
message: "Use `globalThis` instead.",
|
|
1804
|
+
name: "self"
|
|
1805
|
+
}
|
|
1806
|
+
],
|
|
1807
|
+
"no-restricted-properties": [
|
|
1808
|
+
"error",
|
|
1809
|
+
{
|
|
1810
|
+
message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
|
|
1811
|
+
property: "__proto__"
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
message: "Use `Object.defineProperty` instead.",
|
|
1815
|
+
property: "__defineGetter__"
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
message: "Use `Object.defineProperty` instead.",
|
|
1819
|
+
property: "__defineSetter__"
|
|
1820
|
+
},
|
|
1821
|
+
{
|
|
1822
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
1823
|
+
property: "__lookupGetter__"
|
|
1824
|
+
},
|
|
1825
|
+
{
|
|
1826
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
1827
|
+
property: "__lookupSetter__"
|
|
1828
|
+
}
|
|
1829
|
+
],
|
|
1830
|
+
"no-self-assign": [
|
|
1831
|
+
"error",
|
|
1832
|
+
{
|
|
1833
|
+
props: true
|
|
1834
|
+
}
|
|
1835
|
+
],
|
|
1836
|
+
"no-self-compare": "error",
|
|
1837
|
+
"no-sequences": "error",
|
|
1838
|
+
"no-shadow-restricted-names": "error",
|
|
1839
|
+
"no-this-before-super": "error",
|
|
1840
|
+
"no-throw-literal": "error",
|
|
1841
|
+
"no-undef": "error",
|
|
1842
|
+
"no-undef-init": "error",
|
|
1843
|
+
"no-unmodified-loop-condition": "error",
|
|
1844
|
+
"no-unused-expressions": [
|
|
1845
|
+
"error",
|
|
1846
|
+
{
|
|
1847
|
+
allowShortCircuit: true,
|
|
1848
|
+
allowTaggedTemplates: true,
|
|
1849
|
+
allowTernary: true
|
|
1850
|
+
}
|
|
1851
|
+
],
|
|
1852
|
+
"no-use-before-define": [
|
|
1853
|
+
"error",
|
|
1854
|
+
{
|
|
1855
|
+
classes: false,
|
|
1856
|
+
functions: false,
|
|
1857
|
+
variables: true
|
|
1858
|
+
}
|
|
1859
|
+
],
|
|
1860
|
+
"no-useless-call": "error",
|
|
1861
|
+
"no-useless-catch": "error",
|
|
1862
|
+
"no-useless-computed-key": "error",
|
|
1863
|
+
"no-useless-constructor": "error",
|
|
1864
|
+
"no-useless-rename": "error",
|
|
1865
|
+
"no-useless-return": "error",
|
|
1866
|
+
"no-var": "error",
|
|
1867
|
+
"no-with": "error",
|
|
1868
|
+
"object-shorthand": [
|
|
1869
|
+
"error",
|
|
1870
|
+
"always",
|
|
1871
|
+
{
|
|
1872
|
+
avoidQuotes: true,
|
|
1873
|
+
ignoreConstructors: false
|
|
1874
|
+
}
|
|
1875
|
+
],
|
|
1876
|
+
"prefer-arrow-callback": [
|
|
1877
|
+
"error",
|
|
1878
|
+
{
|
|
1879
|
+
allowNamedFunctions: false,
|
|
1880
|
+
allowUnboundThis: true
|
|
1881
|
+
}
|
|
1882
|
+
],
|
|
1883
|
+
"prefer-const": [
|
|
1884
|
+
isInEditor ? "warn" : "error",
|
|
1885
|
+
{
|
|
1886
|
+
destructuring: "all",
|
|
1887
|
+
ignoreReadBeforeAssign: true
|
|
1888
|
+
}
|
|
1889
|
+
],
|
|
1890
|
+
"prefer-promise-reject-errors": "error",
|
|
1891
|
+
"prefer-regex-literals": [
|
|
1892
|
+
"error",
|
|
1893
|
+
{
|
|
1894
|
+
disallowRedundantWrapping: true
|
|
1895
|
+
}
|
|
1896
|
+
],
|
|
1897
|
+
"prefer-rest-params": "error",
|
|
1898
|
+
"prefer-spread": "error",
|
|
1899
|
+
"prefer-template": "error",
|
|
1900
|
+
"symbol-description": "error",
|
|
1901
|
+
"unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
|
|
1902
|
+
"unused-imports/no-unused-vars": [
|
|
1903
|
+
"error",
|
|
1904
|
+
{
|
|
1905
|
+
args: "after-used",
|
|
1906
|
+
argsIgnorePattern: "^_",
|
|
1907
|
+
ignoreRestSiblings: true,
|
|
1908
|
+
vars: "all",
|
|
1909
|
+
varsIgnorePattern: "^_"
|
|
1910
|
+
}
|
|
1911
|
+
],
|
|
1912
|
+
"vars-on-top": "error",
|
|
1913
|
+
"yoda": [
|
|
1914
|
+
"error",
|
|
1915
|
+
"never"
|
|
1916
|
+
],
|
|
1917
|
+
...overrides
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
];
|
|
1921
|
+
}
|
|
1922
|
+
__name(javascript, "javascript");
|
|
1923
|
+
|
|
1924
|
+
// src/configs/jsdoc.ts
|
|
1925
|
+
async function jsdoc(options = {}) {
|
|
1926
|
+
const { stylistic: stylistic2 = true } = options;
|
|
1927
|
+
return [
|
|
1928
|
+
{
|
|
1929
|
+
name: "storm/jsdoc/rules",
|
|
1930
|
+
plugins: {
|
|
1931
|
+
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
1932
|
+
},
|
|
1933
|
+
rules: {
|
|
1934
|
+
"jsdoc/check-access": "warn",
|
|
1935
|
+
"jsdoc/check-param-names": "warn",
|
|
1936
|
+
"jsdoc/check-property-names": "warn",
|
|
1937
|
+
"jsdoc/check-types": "off",
|
|
1938
|
+
"jsdoc/empty-tags": "warn",
|
|
1939
|
+
"jsdoc/implements-on-classes": "warn",
|
|
1940
|
+
"jsdoc/no-defaults": "warn",
|
|
1941
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
1942
|
+
"jsdoc/require-param-name": "warn",
|
|
1943
|
+
"jsdoc/require-property": "warn",
|
|
1944
|
+
"jsdoc/require-property-description": "warn",
|
|
1945
|
+
"jsdoc/require-property-name": "warn",
|
|
1946
|
+
"jsdoc/require-returns-check": "warn",
|
|
1947
|
+
"jsdoc/require-returns-description": "warn",
|
|
1948
|
+
"jsdoc/require-yields-check": "warn",
|
|
1949
|
+
...stylistic2 ? {
|
|
1950
|
+
"jsdoc/check-alignment": "warn",
|
|
1951
|
+
"jsdoc/multiline-blocks": "warn"
|
|
1952
|
+
} : {}
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
];
|
|
1956
|
+
}
|
|
1957
|
+
__name(jsdoc, "jsdoc");
|
|
1958
|
+
|
|
1959
|
+
// src/configs/jsonc.ts
|
|
1960
|
+
async function jsonc(options = {}) {
|
|
1961
|
+
const { files = [
|
|
1962
|
+
GLOB_JSON,
|
|
1963
|
+
GLOB_JSON5,
|
|
1964
|
+
GLOB_JSONC
|
|
1965
|
+
], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
1966
|
+
const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1967
|
+
const [pluginJsonc, parserJsonc] = await Promise.all([
|
|
1968
|
+
interopDefault(import("eslint-plugin-jsonc")),
|
|
1969
|
+
interopDefault(import("jsonc-eslint-parser"))
|
|
1970
|
+
]);
|
|
1971
|
+
return [
|
|
1972
|
+
{
|
|
1973
|
+
name: "storm/jsonc/setup",
|
|
1974
|
+
plugins: {
|
|
1975
|
+
jsonc: pluginJsonc
|
|
1976
|
+
}
|
|
1977
|
+
},
|
|
1978
|
+
{
|
|
1979
|
+
files,
|
|
1980
|
+
languageOptions: {
|
|
1981
|
+
parser: parserJsonc
|
|
1982
|
+
},
|
|
1983
|
+
name: "storm/jsonc/rules",
|
|
1984
|
+
rules: {
|
|
1985
|
+
"jsonc/no-bigint-literals": "error",
|
|
1986
|
+
"jsonc/no-binary-expression": "error",
|
|
1987
|
+
"jsonc/no-binary-numeric-literals": "error",
|
|
1988
|
+
"jsonc/no-dupe-keys": "error",
|
|
1989
|
+
"jsonc/no-escape-sequence-in-identifier": "error",
|
|
1990
|
+
"jsonc/no-floating-decimal": "error",
|
|
1991
|
+
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
1992
|
+
"jsonc/no-infinity": "error",
|
|
1993
|
+
"jsonc/no-multi-str": "error",
|
|
1994
|
+
"jsonc/no-nan": "error",
|
|
1995
|
+
"jsonc/no-number-props": "error",
|
|
1996
|
+
"jsonc/no-numeric-separators": "error",
|
|
1997
|
+
"jsonc/no-octal": "error",
|
|
1998
|
+
"jsonc/no-octal-escape": "error",
|
|
1999
|
+
"jsonc/no-octal-numeric-literals": "error",
|
|
2000
|
+
"jsonc/no-parenthesized": "error",
|
|
2001
|
+
"jsonc/no-plus-sign": "error",
|
|
2002
|
+
"jsonc/no-regexp-literals": "error",
|
|
2003
|
+
"jsonc/no-sparse-arrays": "error",
|
|
2004
|
+
"jsonc/no-template-literals": "error",
|
|
2005
|
+
"jsonc/no-undefined-value": "error",
|
|
2006
|
+
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
2007
|
+
"jsonc/no-useless-escape": "error",
|
|
2008
|
+
"jsonc/space-unary-ops": "error",
|
|
2009
|
+
"jsonc/valid-json-number": "error",
|
|
2010
|
+
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
2011
|
+
...stylistic2 ? {
|
|
2012
|
+
"jsonc/array-bracket-spacing": [
|
|
2013
|
+
"error",
|
|
2014
|
+
"never"
|
|
2015
|
+
],
|
|
2016
|
+
"jsonc/comma-dangle": [
|
|
2017
|
+
"error",
|
|
2018
|
+
"never"
|
|
2019
|
+
],
|
|
2020
|
+
"jsonc/comma-style": [
|
|
2021
|
+
"error",
|
|
2022
|
+
"last"
|
|
2023
|
+
],
|
|
2024
|
+
"jsonc/indent": [
|
|
2025
|
+
"error",
|
|
2026
|
+
indent
|
|
2027
|
+
],
|
|
2028
|
+
"jsonc/key-spacing": [
|
|
2029
|
+
"error",
|
|
2030
|
+
{
|
|
2031
|
+
afterColon: true,
|
|
2032
|
+
beforeColon: false
|
|
2033
|
+
}
|
|
2034
|
+
],
|
|
2035
|
+
"jsonc/object-curly-newline": [
|
|
2036
|
+
"error",
|
|
2037
|
+
{
|
|
2038
|
+
consistent: true,
|
|
2039
|
+
multiline: true
|
|
2040
|
+
}
|
|
2041
|
+
],
|
|
2042
|
+
"jsonc/object-curly-spacing": [
|
|
2043
|
+
"error",
|
|
2044
|
+
"always"
|
|
2045
|
+
],
|
|
2046
|
+
"jsonc/object-property-newline": [
|
|
2047
|
+
"error",
|
|
2048
|
+
{
|
|
2049
|
+
allowMultiplePropertiesPerLine: true
|
|
2050
|
+
}
|
|
2051
|
+
],
|
|
2052
|
+
"jsonc/quote-props": "error",
|
|
2053
|
+
"jsonc/quotes": "error"
|
|
2054
|
+
} : {},
|
|
2055
|
+
...overrides
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
];
|
|
2059
|
+
}
|
|
2060
|
+
__name(jsonc, "jsonc");
|
|
2061
|
+
|
|
2062
|
+
// src/configs/jsx.ts
|
|
2063
|
+
async function jsx() {
|
|
2064
|
+
return [
|
|
2065
|
+
{
|
|
2066
|
+
files: [
|
|
2067
|
+
GLOB_JSX,
|
|
2068
|
+
GLOB_TSX
|
|
2069
|
+
],
|
|
2070
|
+
languageOptions: {
|
|
2071
|
+
parserOptions: {
|
|
2072
|
+
ecmaFeatures: {
|
|
2073
|
+
jsx: true
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
},
|
|
2077
|
+
name: "antfu/jsx/setup"
|
|
2078
|
+
}
|
|
2079
|
+
];
|
|
2080
|
+
}
|
|
2081
|
+
__name(jsx, "jsx");
|
|
2082
|
+
|
|
2083
|
+
// src/configs/markdown.ts
|
|
2084
|
+
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
2085
|
+
async function markdown(options = {}) {
|
|
2086
|
+
const { componentExts = [], files = [
|
|
2087
|
+
GLOB_MARKDOWN
|
|
2088
|
+
], overrides = {} } = options;
|
|
2089
|
+
const markdown1 = await interopDefault(import("@eslint/markdown"));
|
|
2090
|
+
return [
|
|
2091
|
+
{
|
|
2092
|
+
name: "storm/markdown/setup",
|
|
2093
|
+
plugins: {
|
|
2094
|
+
markdown: markdown1
|
|
2095
|
+
}
|
|
2096
|
+
},
|
|
2097
|
+
{
|
|
2098
|
+
files,
|
|
2099
|
+
ignores: [
|
|
2100
|
+
GLOB_MARKDOWN_IN_MARKDOWN
|
|
2101
|
+
],
|
|
2102
|
+
name: "storm/markdown/processor",
|
|
2103
|
+
// `eslint-plugin-markdown` only creates virtual files for code blocks,
|
|
2104
|
+
// but not the markdown file itself. We use `eslint-merge-processors` to
|
|
2105
|
+
// add a pass-through processor for the markdown file itself.
|
|
2106
|
+
processor: mergeProcessors([
|
|
2107
|
+
markdown1.processors.markdown,
|
|
2108
|
+
processorPassThrough
|
|
2109
|
+
])
|
|
2110
|
+
},
|
|
2111
|
+
{
|
|
2112
|
+
files,
|
|
2113
|
+
languageOptions: {
|
|
2114
|
+
parser: parserPlain
|
|
2115
|
+
},
|
|
2116
|
+
name: "storm/markdown/parser"
|
|
2117
|
+
},
|
|
2118
|
+
{
|
|
2119
|
+
files: [
|
|
2120
|
+
GLOB_MARKDOWN_CODE,
|
|
2121
|
+
...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
2122
|
+
],
|
|
2123
|
+
languageOptions: {
|
|
2124
|
+
parserOptions: {
|
|
2125
|
+
ecmaFeatures: {
|
|
2126
|
+
impliedStrict: true
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
},
|
|
2130
|
+
name: "storm/markdown/disables",
|
|
2131
|
+
rules: {
|
|
2132
|
+
"import/newline-after-import": "off",
|
|
2133
|
+
"no-alert": "off",
|
|
2134
|
+
"no-console": "off",
|
|
2135
|
+
"no-labels": "off",
|
|
2136
|
+
"no-lone-blocks": "off",
|
|
2137
|
+
"no-restricted-syntax": "off",
|
|
2138
|
+
"no-undef": "off",
|
|
2139
|
+
"no-unused-expressions": "off",
|
|
2140
|
+
"no-unused-labels": "off",
|
|
2141
|
+
"no-unused-vars": "off",
|
|
2142
|
+
"node/prefer-global/process": "off",
|
|
2143
|
+
"style/comma-dangle": "off",
|
|
2144
|
+
"style/eol-last": "off",
|
|
2145
|
+
"ts/consistent-type-imports": "off",
|
|
2146
|
+
"ts/explicit-function-return-type": "off",
|
|
2147
|
+
"ts/no-namespace": "off",
|
|
2148
|
+
"ts/no-redeclare": "off",
|
|
2149
|
+
"ts/no-require-imports": "off",
|
|
2150
|
+
"ts/no-unused-expressions": "off",
|
|
2151
|
+
"ts/no-unused-vars": "off",
|
|
2152
|
+
"ts/no-use-before-define": "off",
|
|
2153
|
+
"unicode-bom": "off",
|
|
2154
|
+
"unused-imports/no-unused-imports": "off",
|
|
2155
|
+
"unused-imports/no-unused-vars": "off",
|
|
2156
|
+
...overrides
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
];
|
|
2160
|
+
}
|
|
2161
|
+
__name(markdown, "markdown");
|
|
2162
|
+
|
|
2163
|
+
// src/configs/next.ts
|
|
2164
|
+
import { FlatCompat as FlatCompat2 } from "@eslint/eslintrc";
|
|
2165
|
+
var compat2 = new FlatCompat2({
|
|
2166
|
+
// import.meta.dirname is available after Node.js v20.11.0
|
|
2167
|
+
baseDirectory: import.meta.dirname
|
|
2168
|
+
});
|
|
2169
|
+
async function next(options = {}) {
|
|
2170
|
+
const { coreWebVitals = true, rootDir } = options;
|
|
2171
|
+
await ensurePackages([
|
|
2172
|
+
"@next/eslint-plugin-next"
|
|
2173
|
+
]);
|
|
2174
|
+
return [
|
|
2175
|
+
...compat2.config({
|
|
2176
|
+
name: "storm/next",
|
|
2177
|
+
extends: [
|
|
2178
|
+
"next"
|
|
2179
|
+
],
|
|
2180
|
+
settings: {
|
|
2181
|
+
next: {
|
|
2182
|
+
rootDir
|
|
2183
|
+
}
|
|
2184
|
+
},
|
|
2185
|
+
rules: {
|
|
2186
|
+
// warnings
|
|
2187
|
+
"@next/next/google-font-display": "warn",
|
|
2188
|
+
"@next/next/google-font-preconnect": "warn",
|
|
2189
|
+
"@next/next/next-script-for-ga": "warn",
|
|
2190
|
+
"@next/next/no-async-client-component": "warn",
|
|
2191
|
+
"@next/next/no-before-interactive-script-outside-document": "warn",
|
|
2192
|
+
"@next/next/no-css-tags": "warn",
|
|
2193
|
+
"@next/next/no-head-element": "warn",
|
|
2194
|
+
"@next/next/no-html-link-for-pages": "warn",
|
|
2195
|
+
"@next/next/no-img-element": "warn",
|
|
2196
|
+
"@next/next/no-page-custom-font": "warn",
|
|
2197
|
+
"@next/next/no-styled-jsx-in-document": "warn",
|
|
2198
|
+
"@next/next/no-sync-scripts": "warn",
|
|
2199
|
+
"@next/next/no-title-in-document-head": "warn",
|
|
2200
|
+
"@next/next/no-typos": "warn",
|
|
2201
|
+
"@next/next/no-unwanted-polyfillio": "warn",
|
|
2202
|
+
// errors
|
|
2203
|
+
"@next/next/inline-script-id": "error",
|
|
2204
|
+
"@next/next/no-assign-module-variable": "error",
|
|
2205
|
+
"@next/next/no-document-import-in-page": "error",
|
|
2206
|
+
"@next/next/no-duplicate-head": "error",
|
|
2207
|
+
"@next/next/no-head-import-in-document": "error",
|
|
2208
|
+
"@next/next/no-script-component-in-head": "error",
|
|
2209
|
+
// core web vitals
|
|
2210
|
+
...coreWebVitals ? {
|
|
2211
|
+
"@next/next/no-html-link-for-pages": "error",
|
|
2212
|
+
"@next/next/no-sync-scripts": "error"
|
|
2213
|
+
} : {}
|
|
2214
|
+
}
|
|
2215
|
+
})
|
|
2216
|
+
];
|
|
2217
|
+
}
|
|
2218
|
+
__name(next, "next");
|
|
2219
|
+
|
|
2220
|
+
// src/configs/node.ts
|
|
2221
|
+
async function node() {
|
|
2222
|
+
return [
|
|
2223
|
+
{
|
|
2224
|
+
name: "storm/node/rules",
|
|
2225
|
+
plugins: {
|
|
2226
|
+
node: default4
|
|
2227
|
+
},
|
|
2228
|
+
rules: {
|
|
2229
|
+
"node/handle-callback-err": [
|
|
2230
|
+
"error",
|
|
2231
|
+
"^(err|error)$"
|
|
2232
|
+
],
|
|
2233
|
+
"node/no-deprecated-api": "error",
|
|
2234
|
+
"node/no-exports-assign": "error",
|
|
2235
|
+
"node/no-new-require": "error",
|
|
2236
|
+
"node/no-path-concat": "error",
|
|
2237
|
+
"node/prefer-global/buffer": [
|
|
2238
|
+
"error",
|
|
2239
|
+
"never"
|
|
2240
|
+
],
|
|
2241
|
+
"node/prefer-global/process": [
|
|
2242
|
+
"error",
|
|
2243
|
+
"never"
|
|
2244
|
+
],
|
|
2245
|
+
"node/process-exit-as-throw": "error"
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
];
|
|
2249
|
+
}
|
|
2250
|
+
__name(node, "node");
|
|
2251
|
+
|
|
2252
|
+
// src/configs/nx.ts
|
|
2253
|
+
import defu2 from "defu";
|
|
2254
|
+
async function nx(options = {}) {
|
|
2255
|
+
const { depsCheck, moduleBoundaries } = options;
|
|
2256
|
+
return [
|
|
2257
|
+
{
|
|
2258
|
+
name: "storm/nx/setup",
|
|
2259
|
+
plugins: {
|
|
2260
|
+
"@nx": default3
|
|
2261
|
+
}
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
name: "storm/nx/schema",
|
|
2265
|
+
files: [
|
|
2266
|
+
"**/executors/**/schema.json",
|
|
2267
|
+
"**/generators/**/schema.json"
|
|
2268
|
+
],
|
|
2269
|
+
rules: {
|
|
2270
|
+
"@nx/workspace/valid-schema-description": "error"
|
|
2271
|
+
}
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
name: "storm/nx/dependency-check",
|
|
2275
|
+
files: [
|
|
2276
|
+
"**/package.json"
|
|
2277
|
+
],
|
|
2278
|
+
rules: {
|
|
2279
|
+
"@nx/dependency-checks": [
|
|
2280
|
+
"error",
|
|
2281
|
+
defu2(depsCheck ?? {}, {
|
|
2282
|
+
buildTargets: [
|
|
2283
|
+
"build-base",
|
|
2284
|
+
"build"
|
|
2285
|
+
],
|
|
2286
|
+
ignoredDependencies: [],
|
|
2287
|
+
ignoredFiles: [],
|
|
2288
|
+
checkMissingDependencies: true,
|
|
2289
|
+
checkObsoleteDependencies: true,
|
|
2290
|
+
checkVersionMismatches: false,
|
|
2291
|
+
includeTransitiveDependencies: true,
|
|
2292
|
+
useLocalPathsForWorkspaceDependencies: true
|
|
2293
|
+
})
|
|
2294
|
+
]
|
|
2295
|
+
}
|
|
2296
|
+
},
|
|
2297
|
+
{
|
|
2298
|
+
name: "storm/nx/module-boundaries",
|
|
2299
|
+
files: [
|
|
2300
|
+
"**/nx.json",
|
|
2301
|
+
"**/*.ts",
|
|
2302
|
+
"**/*.tsx",
|
|
2303
|
+
"**/*.js",
|
|
2304
|
+
"**/*.jsx"
|
|
2305
|
+
],
|
|
2306
|
+
rules: {
|
|
2307
|
+
"@nx/enforce-module-boundaries": [
|
|
2308
|
+
"error",
|
|
2309
|
+
moduleBoundaries ?? {
|
|
2310
|
+
enforceBuildableLibDependency: true,
|
|
2311
|
+
checkDynamicDependenciesExceptions: [
|
|
2312
|
+
".*"
|
|
2313
|
+
],
|
|
2314
|
+
allow: [],
|
|
2315
|
+
depConstraints: [
|
|
2316
|
+
{
|
|
2317
|
+
sourceTag: "*",
|
|
2318
|
+
onlyDependOnLibsWithTags: [
|
|
2319
|
+
"*"
|
|
2320
|
+
]
|
|
2321
|
+
}
|
|
2322
|
+
]
|
|
2323
|
+
}
|
|
2324
|
+
]
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
];
|
|
2328
|
+
}
|
|
2329
|
+
__name(nx, "nx");
|
|
2330
|
+
|
|
2331
|
+
// src/configs/perfectionist.ts
|
|
2332
|
+
async function perfectionist() {
|
|
2333
|
+
return [
|
|
2334
|
+
{
|
|
2335
|
+
name: "storm/perfectionist/setup",
|
|
2336
|
+
plugins: {
|
|
2337
|
+
perfectionist: default5
|
|
2338
|
+
},
|
|
2339
|
+
rules: {
|
|
2340
|
+
"perfectionist/sort-exports": [
|
|
2341
|
+
"error",
|
|
2342
|
+
{
|
|
2343
|
+
order: "asc",
|
|
2344
|
+
type: "natural"
|
|
2345
|
+
}
|
|
2346
|
+
],
|
|
2347
|
+
"perfectionist/sort-imports": [
|
|
2348
|
+
"error",
|
|
2349
|
+
{
|
|
2350
|
+
groups: [
|
|
2351
|
+
"type",
|
|
2352
|
+
[
|
|
2353
|
+
"parent-type",
|
|
2354
|
+
"sibling-type",
|
|
2355
|
+
"index-type",
|
|
2356
|
+
"internal-type"
|
|
2357
|
+
],
|
|
2358
|
+
"builtin",
|
|
2359
|
+
"external",
|
|
2360
|
+
"internal",
|
|
2361
|
+
[
|
|
2362
|
+
"parent",
|
|
2363
|
+
"sibling",
|
|
2364
|
+
"index"
|
|
2365
|
+
],
|
|
2366
|
+
"side-effect",
|
|
2367
|
+
"object",
|
|
2368
|
+
"unknown"
|
|
2369
|
+
],
|
|
2370
|
+
newlinesBetween: "ignore",
|
|
2371
|
+
order: "asc",
|
|
2372
|
+
type: "natural"
|
|
2373
|
+
}
|
|
2374
|
+
],
|
|
2375
|
+
"perfectionist/sort-named-exports": [
|
|
2376
|
+
"error",
|
|
2377
|
+
{
|
|
2378
|
+
order: "asc",
|
|
2379
|
+
type: "natural"
|
|
2380
|
+
}
|
|
2381
|
+
],
|
|
2382
|
+
"perfectionist/sort-named-imports": [
|
|
2383
|
+
"error",
|
|
2384
|
+
{
|
|
2385
|
+
order: "asc",
|
|
2386
|
+
type: "natural"
|
|
2387
|
+
}
|
|
2388
|
+
]
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
];
|
|
2392
|
+
}
|
|
2393
|
+
__name(perfectionist, "perfectionist");
|
|
2394
|
+
|
|
2395
|
+
// src/configs/react.ts
|
|
2396
|
+
import { isPackageExists } from "local-pkg";
|
|
2397
|
+
var ReactRefreshAllowConstantExportPackages = [
|
|
2398
|
+
"vite"
|
|
2399
|
+
];
|
|
2400
|
+
var ReactRouterPackages = [
|
|
2401
|
+
"@react-router/node",
|
|
2402
|
+
"@react-router/react",
|
|
2403
|
+
"@react-router/serve",
|
|
2404
|
+
"@react-router/dev"
|
|
2405
|
+
];
|
|
2406
|
+
var NextJsPackages = [
|
|
2407
|
+
"next"
|
|
2408
|
+
];
|
|
2409
|
+
async function react(options = {}) {
|
|
2410
|
+
const { files = [
|
|
2411
|
+
GLOB_SRC
|
|
2412
|
+
], filesTypeAware = [
|
|
2413
|
+
GLOB_TS,
|
|
2414
|
+
GLOB_TSX
|
|
2415
|
+
], ignoresTypeAware = [
|
|
2416
|
+
`${GLOB_MARKDOWN}/**`,
|
|
2417
|
+
GLOB_ASTRO_TS
|
|
2418
|
+
], overrides = {}, tsconfigPath } = options;
|
|
2419
|
+
await ensurePackages([
|
|
2420
|
+
"@eslint-react/eslint-plugin",
|
|
2421
|
+
"eslint-plugin-react-hooks",
|
|
2422
|
+
"eslint-plugin-react-refresh",
|
|
2423
|
+
"eslint-plugin-react-compiler"
|
|
2424
|
+
]);
|
|
2425
|
+
const isTypeAware = !!tsconfigPath;
|
|
2426
|
+
const typeAwareRules = {
|
|
2427
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
2428
|
+
};
|
|
2429
|
+
const [pluginReact, pluginReactHooks, pluginReactRefresh, pluginReactCompiler] = await Promise.all([
|
|
2430
|
+
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
2431
|
+
interopDefault(import("eslint-plugin-react-hooks")),
|
|
2432
|
+
interopDefault(import("eslint-plugin-react-refresh")),
|
|
2433
|
+
interopDefault(import("eslint-plugin-react-compiler"))
|
|
2434
|
+
]);
|
|
2435
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
|
|
2436
|
+
const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
|
|
2437
|
+
const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
|
|
2438
|
+
const plugins = pluginReact.configs.all.plugins;
|
|
2439
|
+
return [
|
|
2440
|
+
{
|
|
2441
|
+
name: "storm/react/setup",
|
|
2442
|
+
plugins: {
|
|
2443
|
+
"react": plugins["@eslint-react"],
|
|
2444
|
+
"react-dom": plugins["@eslint-react/dom"],
|
|
2445
|
+
"react-hooks": pluginReactHooks,
|
|
2446
|
+
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
2447
|
+
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
2448
|
+
"react-refresh": pluginReactRefresh,
|
|
2449
|
+
"react-web-api": plugins["@eslint-react/web-api"],
|
|
2450
|
+
"react-compiler": pluginReactCompiler
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
{
|
|
2454
|
+
files,
|
|
2455
|
+
languageOptions: {
|
|
2456
|
+
parserOptions: {
|
|
2457
|
+
ecmaFeatures: {
|
|
2458
|
+
jsx: true
|
|
2459
|
+
}
|
|
2460
|
+
},
|
|
2461
|
+
sourceType: "module"
|
|
2462
|
+
},
|
|
2463
|
+
name: "storm/react/rules",
|
|
2464
|
+
rules: {
|
|
2465
|
+
// recommended rules from @eslint-react/dom
|
|
2466
|
+
"react-dom/no-children-in-void-dom-elements": "warn",
|
|
2467
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
2468
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
2469
|
+
"react-dom/no-find-dom-node": "error",
|
|
2470
|
+
"react-dom/no-missing-button-type": "warn",
|
|
2471
|
+
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
2472
|
+
"react-dom/no-namespace": "error",
|
|
2473
|
+
"react-dom/no-render-return-value": "error",
|
|
2474
|
+
"react-dom/no-script-url": "warn",
|
|
2475
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
2476
|
+
"react-dom/no-unsafe-target-blank": "warn",
|
|
2477
|
+
// recommended rules react-hooks
|
|
2478
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
2479
|
+
"react-hooks/rules-of-hooks": "error",
|
|
2480
|
+
// react refresh
|
|
2481
|
+
"react-refresh/only-export-components": [
|
|
2482
|
+
"warn",
|
|
2483
|
+
{
|
|
2484
|
+
allowConstantExport: isAllowConstantExport,
|
|
2485
|
+
allowExportNames: [
|
|
2486
|
+
...isUsingNext ? [
|
|
2487
|
+
"dynamic",
|
|
2488
|
+
"dynamicParams",
|
|
2489
|
+
"revalidate",
|
|
2490
|
+
"fetchCache",
|
|
2491
|
+
"runtime",
|
|
2492
|
+
"preferredRegion",
|
|
2493
|
+
"maxDuration",
|
|
2494
|
+
"config",
|
|
2495
|
+
"generateStaticParams",
|
|
2496
|
+
"metadata",
|
|
2497
|
+
"generateMetadata",
|
|
2498
|
+
"viewport",
|
|
2499
|
+
"generateViewport"
|
|
2500
|
+
] : [],
|
|
2501
|
+
...isUsingReactRouter ? [
|
|
2502
|
+
"meta",
|
|
2503
|
+
"links",
|
|
2504
|
+
"headers",
|
|
2505
|
+
"loader",
|
|
2506
|
+
"action"
|
|
2507
|
+
] : []
|
|
2508
|
+
]
|
|
2509
|
+
}
|
|
2510
|
+
],
|
|
2511
|
+
// recommended rules from @eslint-react/web-api
|
|
2512
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
2513
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
2514
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
2515
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
2516
|
+
// recommended rules from @eslint-react
|
|
2517
|
+
"react/ensure-forward-ref-using-ref": "warn",
|
|
2518
|
+
"react/jsx-no-duplicate-props": "warn",
|
|
2519
|
+
"react/jsx-uses-vars": "warn",
|
|
2520
|
+
"react/no-access-state-in-setstate": "error",
|
|
2521
|
+
"react/no-array-index-key": "warn",
|
|
2522
|
+
"react/no-children-count": "warn",
|
|
2523
|
+
"react/no-children-for-each": "warn",
|
|
2524
|
+
"react/no-children-map": "warn",
|
|
2525
|
+
"react/no-children-only": "warn",
|
|
2526
|
+
"react/no-children-to-array": "warn",
|
|
2527
|
+
"react/no-clone-element": "warn",
|
|
2528
|
+
"react/no-comment-textnodes": "warn",
|
|
2529
|
+
"react/no-component-will-mount": "error",
|
|
2530
|
+
"react/no-component-will-receive-props": "error",
|
|
2531
|
+
"react/no-component-will-update": "error",
|
|
2532
|
+
"react/no-context-provider": "warn",
|
|
2533
|
+
"react/no-create-ref": "error",
|
|
2534
|
+
"react/no-default-props": "error",
|
|
2535
|
+
"react/no-direct-mutation-state": "error",
|
|
2536
|
+
"react/no-duplicate-key": "error",
|
|
2537
|
+
"react/no-forward-ref": "warn",
|
|
2538
|
+
"react/no-implicit-key": "warn",
|
|
2539
|
+
"react/no-missing-key": "error",
|
|
2540
|
+
"react/no-nested-components": "error",
|
|
2541
|
+
"react/no-prop-types": "error",
|
|
2542
|
+
"react/no-redundant-should-component-update": "error",
|
|
2543
|
+
"react/no-set-state-in-component-did-mount": "warn",
|
|
2544
|
+
"react/no-set-state-in-component-did-update": "warn",
|
|
2545
|
+
"react/no-set-state-in-component-will-update": "warn",
|
|
2546
|
+
"react/no-string-refs": "error",
|
|
2547
|
+
"react/no-unsafe-component-will-mount": "warn",
|
|
2548
|
+
"react/no-unsafe-component-will-receive-props": "warn",
|
|
2549
|
+
"react/no-unsafe-component-will-update": "warn",
|
|
2550
|
+
"react/no-unstable-context-value": "warn",
|
|
2551
|
+
"react/no-unstable-default-props": "warn",
|
|
2552
|
+
"react/no-unused-class-component-members": "warn",
|
|
2553
|
+
"react/no-unused-state": "warn",
|
|
2554
|
+
"react/prefer-destructuring-assignment": "warn",
|
|
2555
|
+
"react/prefer-shorthand-boolean": "warn",
|
|
2556
|
+
"react/prefer-shorthand-fragment": "warn",
|
|
2557
|
+
// recommended rules from eslint-plugin-react-compiler
|
|
2558
|
+
"react-compiler/react-compiler": "error",
|
|
2559
|
+
// overrides
|
|
2560
|
+
...overrides
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
...isTypeAware ? [
|
|
2564
|
+
{
|
|
2565
|
+
files: filesTypeAware,
|
|
2566
|
+
ignores: ignoresTypeAware,
|
|
2567
|
+
name: "storm/react/type-aware-rules",
|
|
2568
|
+
rules: {
|
|
2569
|
+
...typeAwareRules
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
] : []
|
|
2573
|
+
];
|
|
2574
|
+
}
|
|
2575
|
+
__name(react, "react");
|
|
2576
|
+
|
|
2577
|
+
// src/configs/regexp.ts
|
|
2578
|
+
import { configs } from "eslint-plugin-regexp";
|
|
2579
|
+
async function regexp(options = {}) {
|
|
2580
|
+
const config = configs["flat/recommended"];
|
|
2581
|
+
const rules = {
|
|
2582
|
+
...config.rules
|
|
2583
|
+
};
|
|
2584
|
+
if (options.level === "warn") {
|
|
2585
|
+
for (const key in rules) {
|
|
2586
|
+
if (rules[key] === "error") rules[key] = "warn";
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
return [
|
|
2590
|
+
{
|
|
2591
|
+
...config,
|
|
2592
|
+
name: "storm/regexp/rules",
|
|
2593
|
+
rules: {
|
|
2594
|
+
...rules,
|
|
2595
|
+
...options.overrides
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
];
|
|
2599
|
+
}
|
|
2600
|
+
__name(regexp, "regexp");
|
|
2601
|
+
|
|
2602
|
+
// src/configs/sort.ts
|
|
2603
|
+
async function sortPackageJson() {
|
|
2604
|
+
return [
|
|
2605
|
+
{
|
|
2606
|
+
files: [
|
|
2607
|
+
"**/package.json"
|
|
2608
|
+
],
|
|
2609
|
+
name: "storm/sort/package-json",
|
|
2610
|
+
rules: {
|
|
2611
|
+
"jsonc/sort-array-values": [
|
|
2612
|
+
"error",
|
|
2613
|
+
{
|
|
2614
|
+
order: {
|
|
2615
|
+
type: "asc"
|
|
2616
|
+
},
|
|
2617
|
+
pathPattern: "^files$"
|
|
2618
|
+
}
|
|
2619
|
+
],
|
|
2620
|
+
"jsonc/sort-keys": [
|
|
2621
|
+
"error",
|
|
2622
|
+
{
|
|
2623
|
+
order: [
|
|
2624
|
+
"publisher",
|
|
2625
|
+
"name",
|
|
2626
|
+
"displayName",
|
|
2627
|
+
"type",
|
|
2628
|
+
"version",
|
|
2629
|
+
"private",
|
|
2630
|
+
"packageManager",
|
|
2631
|
+
"description",
|
|
2632
|
+
"author",
|
|
2633
|
+
"contributors",
|
|
2634
|
+
"license",
|
|
2635
|
+
"funding",
|
|
2636
|
+
"homepage",
|
|
2637
|
+
"repository",
|
|
2638
|
+
"bugs",
|
|
2639
|
+
"keywords",
|
|
2640
|
+
"categories",
|
|
2641
|
+
"sideEffects",
|
|
2642
|
+
"exports",
|
|
2643
|
+
"main",
|
|
2644
|
+
"module",
|
|
2645
|
+
"unpkg",
|
|
2646
|
+
"jsdelivr",
|
|
2647
|
+
"types",
|
|
2648
|
+
"typesVersions",
|
|
2649
|
+
"bin",
|
|
2650
|
+
"icon",
|
|
2651
|
+
"files",
|
|
2652
|
+
"engines",
|
|
2653
|
+
"activationEvents",
|
|
2654
|
+
"contributes",
|
|
2655
|
+
"scripts",
|
|
2656
|
+
"peerDependencies",
|
|
2657
|
+
"peerDependenciesMeta",
|
|
2658
|
+
"dependencies",
|
|
2659
|
+
"optionalDependencies",
|
|
2660
|
+
"devDependencies",
|
|
2661
|
+
"pnpm",
|
|
2662
|
+
"overrides",
|
|
2663
|
+
"resolutions",
|
|
2664
|
+
"husky",
|
|
2665
|
+
"simple-git-hooks",
|
|
2666
|
+
"lint-staged",
|
|
2667
|
+
"eslintConfig"
|
|
2668
|
+
],
|
|
2669
|
+
pathPattern: "^$"
|
|
2670
|
+
},
|
|
2671
|
+
{
|
|
2672
|
+
order: {
|
|
2673
|
+
type: "asc"
|
|
2674
|
+
},
|
|
2675
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
2676
|
+
},
|
|
2677
|
+
{
|
|
2678
|
+
order: {
|
|
2679
|
+
type: "asc"
|
|
2680
|
+
},
|
|
2681
|
+
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
2682
|
+
},
|
|
2683
|
+
{
|
|
2684
|
+
order: [
|
|
2685
|
+
"types",
|
|
2686
|
+
"import",
|
|
2687
|
+
"require",
|
|
2688
|
+
"default"
|
|
2689
|
+
],
|
|
2690
|
+
pathPattern: "^exports.*$"
|
|
2691
|
+
},
|
|
2692
|
+
{
|
|
2693
|
+
order: [
|
|
2694
|
+
// client hooks only
|
|
2695
|
+
"pre-commit",
|
|
2696
|
+
"prepare-commit-msg",
|
|
2697
|
+
"commit-msg",
|
|
2698
|
+
"post-commit",
|
|
2699
|
+
"pre-rebase",
|
|
2700
|
+
"post-rewrite",
|
|
2701
|
+
"post-checkout",
|
|
2702
|
+
"post-merge",
|
|
2703
|
+
"pre-push",
|
|
2704
|
+
"pre-auto-gc"
|
|
2705
|
+
],
|
|
2706
|
+
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
2707
|
+
}
|
|
2708
|
+
]
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
];
|
|
2712
|
+
}
|
|
2713
|
+
__name(sortPackageJson, "sortPackageJson");
|
|
2714
|
+
function sortTsconfig() {
|
|
2715
|
+
return [
|
|
2716
|
+
{
|
|
2717
|
+
files: [
|
|
2718
|
+
"**/tsconfig.json",
|
|
2719
|
+
"**/tsconfig.*.json"
|
|
2720
|
+
],
|
|
2721
|
+
name: "storm/sort/tsconfig-json",
|
|
2722
|
+
rules: {
|
|
2723
|
+
"jsonc/sort-keys": [
|
|
2724
|
+
"error",
|
|
2725
|
+
{
|
|
2726
|
+
order: [
|
|
2727
|
+
"extends",
|
|
2728
|
+
"compilerOptions",
|
|
2729
|
+
"references",
|
|
2730
|
+
"files",
|
|
2731
|
+
"include",
|
|
2732
|
+
"exclude"
|
|
2733
|
+
],
|
|
2734
|
+
pathPattern: "^$"
|
|
2735
|
+
},
|
|
2736
|
+
{
|
|
2737
|
+
order: [
|
|
2738
|
+
/* Projects */
|
|
2739
|
+
"incremental",
|
|
2740
|
+
"composite",
|
|
2741
|
+
"tsBuildInfoFile",
|
|
2742
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
2743
|
+
"disableSolutionSearching",
|
|
2744
|
+
"disableReferencedProjectLoad",
|
|
2745
|
+
/* Language and Environment */
|
|
2746
|
+
"target",
|
|
2747
|
+
"jsx",
|
|
2748
|
+
"jsxFactory",
|
|
2749
|
+
"jsxFragmentFactory",
|
|
2750
|
+
"jsxImportSource",
|
|
2751
|
+
"lib",
|
|
2752
|
+
"moduleDetection",
|
|
2753
|
+
"noLib",
|
|
2754
|
+
"reactNamespace",
|
|
2755
|
+
"useDefineForClassFields",
|
|
2756
|
+
"emitDecoratorMetadata",
|
|
2757
|
+
"experimentalDecorators",
|
|
2758
|
+
/* Modules */
|
|
2759
|
+
"baseUrl",
|
|
2760
|
+
"rootDir",
|
|
2761
|
+
"rootDirs",
|
|
2762
|
+
"customConditions",
|
|
2763
|
+
"module",
|
|
2764
|
+
"moduleResolution",
|
|
2765
|
+
"moduleSuffixes",
|
|
2766
|
+
"noResolve",
|
|
2767
|
+
"paths",
|
|
2768
|
+
"resolveJsonModule",
|
|
2769
|
+
"resolvePackageJsonExports",
|
|
2770
|
+
"resolvePackageJsonImports",
|
|
2771
|
+
"typeRoots",
|
|
2772
|
+
"types",
|
|
2773
|
+
"allowArbitraryExtensions",
|
|
2774
|
+
"allowImportingTsExtensions",
|
|
2775
|
+
"allowUmdGlobalAccess",
|
|
2776
|
+
/* JavaScript Support */
|
|
2777
|
+
"allowJs",
|
|
2778
|
+
"checkJs",
|
|
2779
|
+
"maxNodeModuleJsDepth",
|
|
2780
|
+
/* Type Checking */
|
|
2781
|
+
"strict",
|
|
2782
|
+
"strictBindCallApply",
|
|
2783
|
+
"strictFunctionTypes",
|
|
2784
|
+
"strictNullChecks",
|
|
2785
|
+
"strictPropertyInitialization",
|
|
2786
|
+
"allowUnreachableCode",
|
|
2787
|
+
"allowUnusedLabels",
|
|
2788
|
+
"alwaysStrict",
|
|
2789
|
+
"exactOptionalPropertyTypes",
|
|
2790
|
+
"noFallthroughCasesInSwitch",
|
|
2791
|
+
"noImplicitAny",
|
|
2792
|
+
"noImplicitOverride",
|
|
2793
|
+
"noImplicitReturns",
|
|
2794
|
+
"noImplicitThis",
|
|
2795
|
+
"noPropertyAccessFromIndexSignature",
|
|
2796
|
+
"noUncheckedIndexedAccess",
|
|
2797
|
+
"noUnusedLocals",
|
|
2798
|
+
"noUnusedParameters",
|
|
2799
|
+
"useUnknownInCatchVariables",
|
|
2800
|
+
/* Emit */
|
|
2801
|
+
"declaration",
|
|
2802
|
+
"declarationDir",
|
|
2803
|
+
"declarationMap",
|
|
2804
|
+
"downlevelIteration",
|
|
2805
|
+
"emitBOM",
|
|
2806
|
+
"emitDeclarationOnly",
|
|
2807
|
+
"importHelpers",
|
|
2808
|
+
"importsNotUsedAsValues",
|
|
2809
|
+
"inlineSourceMap",
|
|
2810
|
+
"inlineSources",
|
|
2811
|
+
"mapRoot",
|
|
2812
|
+
"newLine",
|
|
2813
|
+
"noEmit",
|
|
2814
|
+
"noEmitHelpers",
|
|
2815
|
+
"noEmitOnError",
|
|
2816
|
+
"outDir",
|
|
2817
|
+
"outFile",
|
|
2818
|
+
"preserveConstEnums",
|
|
2819
|
+
"preserveValueImports",
|
|
2820
|
+
"removeComments",
|
|
2821
|
+
"sourceMap",
|
|
2822
|
+
"sourceRoot",
|
|
2823
|
+
"stripInternal",
|
|
2824
|
+
/* Interop Constraints */
|
|
2825
|
+
"allowSyntheticDefaultImports",
|
|
2826
|
+
"esModuleInterop",
|
|
2827
|
+
"forceConsistentCasingInFileNames",
|
|
2828
|
+
"isolatedDeclarations",
|
|
2829
|
+
"isolatedModules",
|
|
2830
|
+
"preserveSymlinks",
|
|
2831
|
+
"verbatimModuleSyntax",
|
|
2832
|
+
/* Completeness */
|
|
2833
|
+
"skipDefaultLibCheck",
|
|
2834
|
+
"skipLibCheck"
|
|
2835
|
+
],
|
|
2836
|
+
pathPattern: "^compilerOptions$"
|
|
2837
|
+
}
|
|
2838
|
+
]
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
];
|
|
2842
|
+
}
|
|
2843
|
+
__name(sortTsconfig, "sortTsconfig");
|
|
2844
|
+
|
|
2845
|
+
// src/configs/storybook.ts
|
|
2846
|
+
async function storybook(options = {}) {
|
|
2847
|
+
const { csf = "loose" } = options;
|
|
2848
|
+
await ensurePackages([
|
|
2849
|
+
"eslint-plugin-storybook"
|
|
2850
|
+
]);
|
|
2851
|
+
const [pluginStorybook] = await Promise.all([
|
|
2852
|
+
interopDefault(import("eslint-plugin-storybook"))
|
|
2853
|
+
]);
|
|
2854
|
+
return [
|
|
2855
|
+
{
|
|
2856
|
+
name: "storm/storybook/setup",
|
|
2857
|
+
plugins: {
|
|
2858
|
+
storybook: pluginStorybook
|
|
2859
|
+
},
|
|
2860
|
+
ignores: [
|
|
2861
|
+
"!.storybook"
|
|
2862
|
+
]
|
|
2863
|
+
},
|
|
2864
|
+
{
|
|
2865
|
+
name: "storm/storybook/rules",
|
|
2866
|
+
files: [
|
|
2867
|
+
"**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)",
|
|
2868
|
+
"**/*.story.@(ts|tsx|js|jsx|mjs|cjs)"
|
|
2869
|
+
],
|
|
2870
|
+
rules: {
|
|
2871
|
+
...csf !== "none" ? csf === "strict" ? {
|
|
2872
|
+
"storybook/csf-component": "error",
|
|
2873
|
+
"storybook/no-title-property-in-meta": "error"
|
|
2874
|
+
} : {
|
|
2875
|
+
"storybook/csf-component": "warn",
|
|
2876
|
+
"storybook/no-title-property-in-meta": "warn"
|
|
2877
|
+
} : {},
|
|
2878
|
+
// errors
|
|
2879
|
+
"storybook/await-interactions": "error",
|
|
2880
|
+
"storybook/context-in-play-function": "error",
|
|
2881
|
+
"storybook/default-exports": "error",
|
|
2882
|
+
"storybook/story-exports": "error",
|
|
2883
|
+
"storybook/use-storybook-expect": "error",
|
|
2884
|
+
"storybook/use-storybook-testing-library": "error",
|
|
2885
|
+
// warnings
|
|
2886
|
+
"storybook/hierarchy-separator": "warn",
|
|
2887
|
+
"storybook/no-redundant-story-name": "warn",
|
|
2888
|
+
"storybook/prefer-pascal-case": "warn",
|
|
2889
|
+
// off
|
|
2890
|
+
"react-hooks/rules-of-hooks": "off",
|
|
2891
|
+
"import/no-anonymous-default-export": "off"
|
|
2892
|
+
}
|
|
2893
|
+
},
|
|
2894
|
+
{
|
|
2895
|
+
name: "storm/storybook/main",
|
|
2896
|
+
files: [
|
|
2897
|
+
"**/.storybook/main.@(js|cjs|mjs|ts)"
|
|
2898
|
+
],
|
|
2899
|
+
rules: {
|
|
2900
|
+
"storybook/no-uninstalled-addons": "error"
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
];
|
|
2904
|
+
}
|
|
2905
|
+
__name(storybook, "storybook");
|
|
2906
|
+
|
|
2907
|
+
// src/configs/test.ts
|
|
2908
|
+
var _pluginTest;
|
|
2909
|
+
async function test(options = {}) {
|
|
2910
|
+
const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
|
|
2911
|
+
const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
|
|
2912
|
+
interopDefault(import("@vitest/eslint-plugin")),
|
|
2913
|
+
// @ts-expect-error missing types
|
|
2914
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
2915
|
+
]);
|
|
2916
|
+
_pluginTest = _pluginTest || {
|
|
2917
|
+
...pluginVitest,
|
|
2918
|
+
rules: {
|
|
2919
|
+
...pluginVitest.rules,
|
|
2920
|
+
// extend `test/no-only-tests` rule
|
|
2921
|
+
...pluginNoOnlyTests.rules
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
return [
|
|
2925
|
+
{
|
|
2926
|
+
name: "storm/test/setup",
|
|
2927
|
+
plugins: {
|
|
2928
|
+
test: _pluginTest
|
|
2929
|
+
}
|
|
2930
|
+
},
|
|
2931
|
+
{
|
|
2932
|
+
files,
|
|
2933
|
+
name: "storm/test/rules",
|
|
2934
|
+
rules: {
|
|
2935
|
+
"test/consistent-test-it": [
|
|
2936
|
+
"error",
|
|
2937
|
+
{
|
|
2938
|
+
fn: "it",
|
|
2939
|
+
withinDescribe: "it"
|
|
2940
|
+
}
|
|
2941
|
+
],
|
|
2942
|
+
"test/no-identical-title": "error",
|
|
2943
|
+
"test/no-import-node-test": "error",
|
|
2944
|
+
"test/no-only-tests": isInEditor ? "warn" : "error",
|
|
2945
|
+
"test/prefer-hooks-in-order": "error",
|
|
2946
|
+
"test/prefer-lowercase-title": "error",
|
|
2947
|
+
// Disables
|
|
2948
|
+
...{
|
|
2949
|
+
"no-unused-expressions": "off",
|
|
2950
|
+
"node/prefer-global/process": "off",
|
|
2951
|
+
"ts/explicit-function-return-type": "off"
|
|
2952
|
+
},
|
|
2953
|
+
...overrides
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
];
|
|
2957
|
+
}
|
|
2958
|
+
__name(test, "test");
|
|
2959
|
+
|
|
2960
|
+
// src/configs/toml.ts
|
|
2961
|
+
async function toml(options = {}) {
|
|
2962
|
+
const { files = [
|
|
2963
|
+
GLOB_TOML
|
|
2964
|
+
], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
2965
|
+
const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
2966
|
+
const [pluginToml, parserToml] = await Promise.all([
|
|
2967
|
+
interopDefault(import("eslint-plugin-toml")),
|
|
2968
|
+
interopDefault(import("toml-eslint-parser"))
|
|
2969
|
+
]);
|
|
2970
|
+
return [
|
|
2971
|
+
{
|
|
2972
|
+
name: "storm/toml/setup",
|
|
2973
|
+
plugins: {
|
|
2974
|
+
toml: pluginToml
|
|
2975
|
+
}
|
|
2976
|
+
},
|
|
2977
|
+
{
|
|
2978
|
+
files,
|
|
2979
|
+
languageOptions: {
|
|
2980
|
+
parser: parserToml
|
|
2981
|
+
},
|
|
2982
|
+
name: "storm/toml/rules",
|
|
2983
|
+
rules: {
|
|
2984
|
+
"style/spaced-comment": "off",
|
|
2985
|
+
"toml/comma-style": "error",
|
|
2986
|
+
"toml/keys-order": "error",
|
|
2987
|
+
"toml/no-space-dots": "error",
|
|
2988
|
+
"toml/no-unreadable-number-separator": "error",
|
|
2989
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
2990
|
+
"toml/precision-of-integer": "error",
|
|
2991
|
+
"toml/tables-order": "error",
|
|
2992
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
2993
|
+
...stylistic2 ? {
|
|
2994
|
+
"toml/array-bracket-newline": "error",
|
|
2995
|
+
"toml/array-bracket-spacing": "error",
|
|
2996
|
+
"toml/array-element-newline": "error",
|
|
2997
|
+
"toml/indent": [
|
|
2998
|
+
"error",
|
|
2999
|
+
indent === "tab" ? 2 : indent
|
|
3000
|
+
],
|
|
3001
|
+
"toml/inline-table-curly-spacing": "error",
|
|
3002
|
+
"toml/key-spacing": "error",
|
|
3003
|
+
"toml/padding-line-between-pairs": "error",
|
|
3004
|
+
"toml/padding-line-between-tables": "error",
|
|
3005
|
+
"toml/quoted-keys": "error",
|
|
3006
|
+
"toml/spaced-comment": "error",
|
|
3007
|
+
"toml/table-bracket-spacing": "error"
|
|
3008
|
+
} : {},
|
|
3009
|
+
...overrides
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
];
|
|
3013
|
+
}
|
|
3014
|
+
__name(toml, "toml");
|
|
3015
|
+
|
|
3016
|
+
// src/configs/typescript.ts
|
|
3017
|
+
import process from "node:process";
|
|
3018
|
+
async function typescript(options = {}) {
|
|
3019
|
+
const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
3020
|
+
const files = options.files ?? [
|
|
3021
|
+
GLOB_TS,
|
|
3022
|
+
GLOB_TSX,
|
|
3023
|
+
...componentExts.map((ext) => `**/*.${ext}`)
|
|
3024
|
+
];
|
|
3025
|
+
const filesTypeAware = options.filesTypeAware ?? [
|
|
3026
|
+
GLOB_TS,
|
|
3027
|
+
GLOB_TSX
|
|
3028
|
+
];
|
|
3029
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
3030
|
+
`${GLOB_MARKDOWN}/**`,
|
|
3031
|
+
GLOB_ASTRO_TS
|
|
3032
|
+
];
|
|
3033
|
+
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
3034
|
+
const isTypeAware = !!tsconfigPath;
|
|
3035
|
+
const typeAwareRules = {
|
|
3036
|
+
"dot-notation": "off",
|
|
3037
|
+
"no-implied-eval": "off",
|
|
3038
|
+
"ts/await-thenable": "error",
|
|
3039
|
+
"ts/dot-notation": [
|
|
3040
|
+
"error",
|
|
3041
|
+
{
|
|
3042
|
+
allowKeywords: true
|
|
3043
|
+
}
|
|
3044
|
+
],
|
|
3045
|
+
"ts/no-floating-promises": "error",
|
|
3046
|
+
"ts/no-for-in-array": "error",
|
|
3047
|
+
"ts/no-implied-eval": "error",
|
|
3048
|
+
"ts/no-misused-promises": "error",
|
|
3049
|
+
"ts/no-unnecessary-type-assertion": "error",
|
|
3050
|
+
"ts/no-unsafe-argument": "error",
|
|
3051
|
+
"ts/no-unsafe-assignment": "error",
|
|
3052
|
+
"ts/no-unsafe-call": "error",
|
|
3053
|
+
"ts/no-unsafe-member-access": "error",
|
|
3054
|
+
"ts/no-unsafe-return": "error",
|
|
3055
|
+
"ts/promise-function-async": "error",
|
|
3056
|
+
"ts/restrict-plus-operands": "error",
|
|
3057
|
+
"ts/restrict-template-expressions": "error",
|
|
3058
|
+
"ts/return-await": [
|
|
3059
|
+
"error",
|
|
3060
|
+
"in-try-catch"
|
|
3061
|
+
],
|
|
3062
|
+
"ts/strict-boolean-expressions": [
|
|
3063
|
+
"error",
|
|
3064
|
+
{
|
|
3065
|
+
allowNullableBoolean: true,
|
|
3066
|
+
allowNullableObject: true
|
|
3067
|
+
}
|
|
3068
|
+
],
|
|
3069
|
+
"ts/switch-exhaustiveness-check": "error",
|
|
3070
|
+
"ts/unbound-method": "error"
|
|
3071
|
+
};
|
|
3072
|
+
const [pluginTs, parserTs] = await Promise.all([
|
|
3073
|
+
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
3074
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
3075
|
+
]);
|
|
3076
|
+
function makeParser(typeAware, files2, ignores2) {
|
|
3077
|
+
return {
|
|
3078
|
+
files: files2,
|
|
3079
|
+
...ignores2 ? {
|
|
3080
|
+
ignores: ignores2
|
|
3081
|
+
} : {},
|
|
3082
|
+
languageOptions: {
|
|
3083
|
+
parser: parserTs,
|
|
3084
|
+
parserOptions: {
|
|
3085
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
3086
|
+
sourceType: "module",
|
|
3087
|
+
...typeAware ? {
|
|
3088
|
+
projectService: {
|
|
3089
|
+
allowDefaultProject: [
|
|
3090
|
+
"./*.js"
|
|
3091
|
+
],
|
|
3092
|
+
defaultProject: tsconfigPath
|
|
3093
|
+
},
|
|
3094
|
+
tsconfigRootDir: process.cwd()
|
|
3095
|
+
} : {},
|
|
3096
|
+
...parserOptions
|
|
3097
|
+
}
|
|
3098
|
+
},
|
|
3099
|
+
name: `storm/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
__name(makeParser, "makeParser");
|
|
3103
|
+
return [
|
|
3104
|
+
{
|
|
3105
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
3106
|
+
name: "storm/typescript/setup",
|
|
3107
|
+
plugins: {
|
|
3108
|
+
ts: pluginTs
|
|
3109
|
+
}
|
|
3110
|
+
},
|
|
3111
|
+
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
3112
|
+
...isTypeAware ? [
|
|
3113
|
+
makeParser(false, files),
|
|
3114
|
+
makeParser(true, filesTypeAware, ignoresTypeAware)
|
|
3115
|
+
] : [
|
|
3116
|
+
makeParser(false, files)
|
|
3117
|
+
],
|
|
3118
|
+
{
|
|
3119
|
+
files,
|
|
3120
|
+
name: "storm/typescript/rules",
|
|
3121
|
+
rules: {
|
|
3122
|
+
...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, {
|
|
3123
|
+
"@typescript-eslint": "ts"
|
|
3124
|
+
}),
|
|
3125
|
+
...renameRules(pluginTs.configs.strict.rules, {
|
|
3126
|
+
"@typescript-eslint": "ts"
|
|
3127
|
+
}),
|
|
3128
|
+
/*************************************************************
|
|
3129
|
+
*
|
|
3130
|
+
* TypeScript Rules - The following rules are specific to the TypeScript plugin
|
|
3131
|
+
*
|
|
3132
|
+
**************************************************************/
|
|
3133
|
+
"ts/no-explicit-any": "off",
|
|
3134
|
+
"ts/no-empty-function": "off",
|
|
3135
|
+
"ts/no-var-requires": "off",
|
|
3136
|
+
"ts/ban-ts-comment": "off",
|
|
3137
|
+
"ts/no-empty-interface": "off",
|
|
3138
|
+
"ts/explicit-module-boundary-types": "off",
|
|
3139
|
+
"ts/explicit-function-return-type": "off",
|
|
3140
|
+
"ts/no-unused-vars": [
|
|
3141
|
+
"error",
|
|
3142
|
+
{
|
|
3143
|
+
args: "none",
|
|
3144
|
+
varsIgnorePattern: "^_"
|
|
3145
|
+
}
|
|
3146
|
+
],
|
|
3147
|
+
"ts/prefer-nullish-coalescing": [
|
|
3148
|
+
"error",
|
|
3149
|
+
{
|
|
3150
|
+
ignorePrimitives: {
|
|
3151
|
+
string: true
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
],
|
|
3155
|
+
"ts/no-restricted-imports": [
|
|
3156
|
+
"error",
|
|
3157
|
+
{
|
|
3158
|
+
patterns: [
|
|
3159
|
+
{
|
|
3160
|
+
group: [
|
|
3161
|
+
"nx/src/plugins/js*"
|
|
3162
|
+
],
|
|
3163
|
+
message: "Imports from 'nx/src/plugins/js' are not allowed. Use '@nx/js' instead"
|
|
3164
|
+
},
|
|
3165
|
+
{
|
|
3166
|
+
group: [
|
|
3167
|
+
"**/native-bindings",
|
|
3168
|
+
"**/native-bindings.js"
|
|
3169
|
+
],
|
|
3170
|
+
message: "Direct imports from native-bindings.js are not allowed. Import from index.js instead."
|
|
3171
|
+
},
|
|
3172
|
+
{
|
|
3173
|
+
group: [
|
|
3174
|
+
"create-storm-workspace"
|
|
3175
|
+
],
|
|
3176
|
+
message: "Direct imports from `create-storm-workspace` are not allowed. Instead install this package globally (example: 'npm i create-storm-workspace -g')."
|
|
3177
|
+
},
|
|
3178
|
+
{
|
|
3179
|
+
group: [
|
|
3180
|
+
"create-nx-workspace"
|
|
3181
|
+
],
|
|
3182
|
+
message: "Direct imports from `create-nx-workspace` are not allowed. Instead install this package globally (example: 'npm i create-nx-workspace -g')."
|
|
3183
|
+
}
|
|
3184
|
+
]
|
|
3185
|
+
}
|
|
3186
|
+
],
|
|
3187
|
+
"no-dupe-class-members": "off",
|
|
3188
|
+
"no-redeclare": "off",
|
|
3189
|
+
"no-use-before-define": "off",
|
|
3190
|
+
"no-useless-constructor": "off",
|
|
3191
|
+
"ts/consistent-type-definitions": [
|
|
3192
|
+
"error",
|
|
3193
|
+
"interface"
|
|
3194
|
+
],
|
|
3195
|
+
"ts/consistent-type-imports": [
|
|
3196
|
+
"error",
|
|
3197
|
+
{
|
|
3198
|
+
disallowTypeAnnotations: false,
|
|
3199
|
+
fixStyle: "separate-type-imports",
|
|
3200
|
+
prefer: "type-imports"
|
|
3201
|
+
}
|
|
3202
|
+
],
|
|
3203
|
+
"ts/method-signature-style": [
|
|
3204
|
+
"error",
|
|
3205
|
+
"property"
|
|
3206
|
+
],
|
|
3207
|
+
"ts/no-dupe-class-members": "error",
|
|
3208
|
+
"ts/no-dynamic-delete": "off",
|
|
3209
|
+
"ts/no-empty-object-type": [
|
|
3210
|
+
"error",
|
|
3211
|
+
{
|
|
3212
|
+
allowInterfaces: "always"
|
|
3213
|
+
}
|
|
3214
|
+
],
|
|
3215
|
+
"ts/no-extraneous-class": "off",
|
|
3216
|
+
"ts/no-import-type-side-effects": "error",
|
|
3217
|
+
"ts/no-invalid-void-type": "off",
|
|
3218
|
+
"ts/no-non-null-assertion": "off",
|
|
3219
|
+
"ts/no-redeclare": [
|
|
3220
|
+
"error",
|
|
3221
|
+
{
|
|
3222
|
+
builtinGlobals: false
|
|
3223
|
+
}
|
|
3224
|
+
],
|
|
3225
|
+
"ts/no-require-imports": "error",
|
|
3226
|
+
"ts/no-unused-expressions": [
|
|
3227
|
+
"error",
|
|
3228
|
+
{
|
|
3229
|
+
allowShortCircuit: true,
|
|
3230
|
+
allowTaggedTemplates: true,
|
|
3231
|
+
allowTernary: true
|
|
3232
|
+
}
|
|
3233
|
+
],
|
|
3234
|
+
"ts/no-use-before-define": [
|
|
3235
|
+
"error",
|
|
3236
|
+
{
|
|
3237
|
+
classes: false,
|
|
3238
|
+
functions: false,
|
|
3239
|
+
variables: true
|
|
3240
|
+
}
|
|
3241
|
+
],
|
|
3242
|
+
"ts/no-useless-constructor": "off",
|
|
3243
|
+
"ts/no-wrapper-object-types": "error",
|
|
3244
|
+
"ts/triple-slash-reference": "off",
|
|
3245
|
+
"ts/unified-signatures": "off",
|
|
3246
|
+
...type === "lib" ? {
|
|
3247
|
+
"ts/explicit-function-return-type": [
|
|
3248
|
+
"error",
|
|
3249
|
+
{
|
|
3250
|
+
allowExpressions: true,
|
|
3251
|
+
allowHigherOrderFunctions: true,
|
|
3252
|
+
allowIIFEs: true
|
|
3253
|
+
}
|
|
3254
|
+
]
|
|
3255
|
+
} : {},
|
|
3256
|
+
...overrides
|
|
3257
|
+
}
|
|
3258
|
+
},
|
|
3259
|
+
...isTypeAware ? [
|
|
3260
|
+
{
|
|
3261
|
+
files: filesTypeAware,
|
|
3262
|
+
ignores: ignoresTypeAware,
|
|
3263
|
+
name: "storm/typescript/rules-type-aware",
|
|
3264
|
+
rules: {
|
|
3265
|
+
...typeAwareRules,
|
|
3266
|
+
...overridesTypeAware
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
] : []
|
|
3270
|
+
];
|
|
3271
|
+
}
|
|
3272
|
+
__name(typescript, "typescript");
|
|
3273
|
+
|
|
3274
|
+
// src/configs/unicorn.ts
|
|
3275
|
+
async function unicorn(options = {}) {
|
|
3276
|
+
return [
|
|
3277
|
+
{
|
|
3278
|
+
name: "storm/unicorn/rules",
|
|
3279
|
+
plugins: {
|
|
3280
|
+
unicorn: default6
|
|
3281
|
+
},
|
|
3282
|
+
rules: {
|
|
3283
|
+
...options.allRecommended ? default6.configs["recommended"].rules : {
|
|
3284
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
3285
|
+
"unicorn/error-message": "error",
|
|
3286
|
+
"unicorn/escape-case": "error",
|
|
3287
|
+
"unicorn/new-for-builtins": "error",
|
|
3288
|
+
"unicorn/no-instanceof-array": "error",
|
|
3289
|
+
"unicorn/no-new-array": "error",
|
|
3290
|
+
"unicorn/no-new-buffer": "error",
|
|
3291
|
+
"unicorn/number-literal-case": "error",
|
|
3292
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
3293
|
+
"unicorn/prefer-includes": "error",
|
|
3294
|
+
"unicorn/prefer-node-protocol": "error",
|
|
3295
|
+
"unicorn/prefer-number-properties": "error",
|
|
3296
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
3297
|
+
"unicorn/prefer-type-error": "error",
|
|
3298
|
+
"unicorn/throw-new-error": "error"
|
|
3299
|
+
},
|
|
3300
|
+
/*************************************************************
|
|
3301
|
+
*
|
|
3302
|
+
* Unicorn Rules - The following rules are specific to the Unicorn plugin
|
|
3303
|
+
*
|
|
3304
|
+
**************************************************************/
|
|
3305
|
+
"unicorn/number-literal-case": "off",
|
|
3306
|
+
"unicorn/template-indent": "off",
|
|
3307
|
+
"unicorn/prevent-abbreviations": "off",
|
|
3308
|
+
"unicorn/no-await-expression-member": "off",
|
|
3309
|
+
"unicorn/no-useless-undefined": "off",
|
|
3310
|
+
"unicorn/no-array-push-push": "off",
|
|
3311
|
+
"unicorn/no-array-reduce": "off",
|
|
3312
|
+
"unicorn/no-useless-switch-case": "off",
|
|
3313
|
+
"unicorn/prefer-string-replace-all": "off",
|
|
3314
|
+
"unicorn/no-abusive-eslint-disable": "off",
|
|
3315
|
+
"unicorn/import-style": "off",
|
|
3316
|
+
"unicorn/prefer-module": "off",
|
|
3317
|
+
"unicorn/consistent-function-scoping": "off",
|
|
3318
|
+
"unicorn/no-nested-ternary": "off"
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
];
|
|
3322
|
+
}
|
|
3323
|
+
__name(unicorn, "unicorn");
|
|
3324
|
+
|
|
3325
|
+
// src/configs/unocss.ts
|
|
3326
|
+
async function unocss(options = {}) {
|
|
3327
|
+
const { attributify = true, strict = false } = options;
|
|
3328
|
+
await ensurePackages([
|
|
3329
|
+
"@unocss/eslint-plugin"
|
|
3330
|
+
]);
|
|
3331
|
+
const [pluginUnoCSS] = await Promise.all([
|
|
3332
|
+
interopDefault(import("@unocss/eslint-plugin"))
|
|
3333
|
+
]);
|
|
3334
|
+
return [
|
|
3335
|
+
{
|
|
3336
|
+
name: "storm/unocss",
|
|
3337
|
+
plugins: {
|
|
3338
|
+
unocss: pluginUnoCSS
|
|
3339
|
+
},
|
|
3340
|
+
rules: {
|
|
3341
|
+
"unocss/order": "warn",
|
|
3342
|
+
...attributify ? {
|
|
3343
|
+
"unocss/order-attributify": "warn"
|
|
3344
|
+
} : {},
|
|
3345
|
+
...strict ? {
|
|
3346
|
+
"unocss/blocklist": "error"
|
|
3347
|
+
} : {}
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
];
|
|
3351
|
+
}
|
|
3352
|
+
__name(unocss, "unocss");
|
|
3353
|
+
|
|
3354
|
+
// src/configs/yaml.ts
|
|
3355
|
+
async function yaml(options = {}) {
|
|
3356
|
+
const { files = [
|
|
3357
|
+
GLOB_YAML
|
|
3358
|
+
], overrides = {}, stylistic: stylistic2 = true } = options;
|
|
3359
|
+
const { indent = 2, quotes = "single" } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
3360
|
+
const [pluginYaml, parserYaml] = await Promise.all([
|
|
3361
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
3362
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
3363
|
+
]);
|
|
3364
|
+
return [
|
|
3365
|
+
{
|
|
3366
|
+
name: "storm/yaml/setup",
|
|
3367
|
+
plugins: {
|
|
3368
|
+
yaml: pluginYaml
|
|
3369
|
+
}
|
|
3370
|
+
},
|
|
3371
|
+
// YML
|
|
3372
|
+
// https://www.npmjs.com/package/eslint-plugin-yml
|
|
3373
|
+
...pluginYaml.configs["flat/recommended"],
|
|
3374
|
+
{
|
|
3375
|
+
files,
|
|
3376
|
+
languageOptions: {
|
|
3377
|
+
parser: parserYaml
|
|
3378
|
+
},
|
|
3379
|
+
name: "storm/yaml/rules",
|
|
3380
|
+
rules: {
|
|
3381
|
+
"style/spaced-comment": "off",
|
|
3382
|
+
"yaml/block-mapping": "error",
|
|
3383
|
+
"yaml/block-sequence": "error",
|
|
3384
|
+
"yaml/no-empty-key": "error",
|
|
3385
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
3386
|
+
"yaml/no-irregular-whitespace": "error",
|
|
3387
|
+
"yaml/plain-scalar": "error",
|
|
3388
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
3389
|
+
...stylistic2 ? {
|
|
3390
|
+
"yaml/block-mapping-question-indicator-newline": "error",
|
|
3391
|
+
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
3392
|
+
"yaml/flow-mapping-curly-newline": "error",
|
|
3393
|
+
"yaml/flow-mapping-curly-spacing": "error",
|
|
3394
|
+
"yaml/flow-sequence-bracket-newline": "error",
|
|
3395
|
+
"yaml/flow-sequence-bracket-spacing": "error",
|
|
3396
|
+
"yaml/indent": [
|
|
3397
|
+
"error",
|
|
3398
|
+
indent === "tab" ? 2 : indent
|
|
3399
|
+
],
|
|
3400
|
+
"yaml/key-spacing": "error",
|
|
3401
|
+
"yaml/no-tab-indent": "error",
|
|
3402
|
+
"yaml/quotes": [
|
|
3403
|
+
"error",
|
|
3404
|
+
{
|
|
3405
|
+
avoidEscape: true,
|
|
3406
|
+
prefer: quotes === "backtick" ? "single" : quotes
|
|
3407
|
+
}
|
|
3408
|
+
],
|
|
3409
|
+
"yaml/spaced-comment": "error"
|
|
3410
|
+
} : {},
|
|
3411
|
+
...overrides
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
];
|
|
3415
|
+
}
|
|
3416
|
+
__name(yaml, "yaml");
|
|
3417
|
+
|
|
3418
|
+
// src/configs/cspell.ts
|
|
3419
|
+
import cspellConfig from "@cspell/eslint-plugin/recommended";
|
|
3420
|
+
import { findWorkspaceRoot, joinPaths } from "@storm-software/config-tools";
|
|
3421
|
+
async function cspell(options = {}) {
|
|
3422
|
+
const { configFile = "./.vscode/cspell.json" } = options;
|
|
3423
|
+
return [
|
|
3424
|
+
{
|
|
3425
|
+
name: "storm/cspell/setup",
|
|
3426
|
+
plugins: {
|
|
3427
|
+
"@cspell": default2
|
|
3428
|
+
}
|
|
3429
|
+
},
|
|
3430
|
+
{
|
|
3431
|
+
name: "storm/cspell/rules",
|
|
3432
|
+
...cspellConfig,
|
|
3433
|
+
rules: {
|
|
3434
|
+
...cspellConfig.rules,
|
|
3435
|
+
"@cspell/spellchecker": [
|
|
3436
|
+
"warn",
|
|
3437
|
+
{
|
|
3438
|
+
configFile: joinPaths(findWorkspaceRoot(), configFile),
|
|
3439
|
+
autoFix: true
|
|
3440
|
+
}
|
|
3441
|
+
]
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
];
|
|
3445
|
+
}
|
|
3446
|
+
__name(cspell, "cspell");
|
|
3447
|
+
|
|
3448
|
+
// src/preset.ts
|
|
3449
|
+
var flatConfigProps = [
|
|
3450
|
+
"name",
|
|
3451
|
+
"languageOptions",
|
|
3452
|
+
"linterOptions",
|
|
3453
|
+
"processor",
|
|
3454
|
+
"plugins",
|
|
3455
|
+
"rules",
|
|
3456
|
+
"settings"
|
|
3457
|
+
];
|
|
3458
|
+
var defaultPluginRenaming = {
|
|
3459
|
+
"@eslint-react": "react",
|
|
3460
|
+
"@eslint-react/dom": "react-dom",
|
|
3461
|
+
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
3462
|
+
"@eslint-react/naming-convention": "react-naming-convention",
|
|
3463
|
+
"@stylistic": "style",
|
|
3464
|
+
"@typescript-eslint": "ts",
|
|
3465
|
+
"import-x": "import",
|
|
3466
|
+
"n": "node",
|
|
3467
|
+
"vitest": "test",
|
|
3468
|
+
"yml": "yaml"
|
|
3469
|
+
};
|
|
3470
|
+
function resolveSubOptions(options, key) {
|
|
3471
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
3472
|
+
}
|
|
3473
|
+
__name(resolveSubOptions, "resolveSubOptions");
|
|
3474
|
+
function getOverrides(options, key) {
|
|
3475
|
+
const sub = resolveSubOptions(options, key);
|
|
3476
|
+
return "overrides" in sub ? sub.overrides : {};
|
|
3477
|
+
}
|
|
3478
|
+
__name(getOverrides, "getOverrides");
|
|
3479
|
+
function getStormConfig(options, ...userConfigs) {
|
|
3480
|
+
const { name, globals = {}, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, jsx: enableJsx = true, cspell: enableCSpell = true, react: enableReact = false, regexp: enableRegexp = true, next: enableNext = false, graphql: enableGraphQL = false, storybook: enableStorybook = false, typescript: enableTypeScript = isPackageExists2("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false } = options;
|
|
3481
|
+
let isInEditor = options.isInEditor;
|
|
3482
|
+
if (isInEditor == null) {
|
|
3483
|
+
isInEditor = isInEditorEnv();
|
|
3484
|
+
if (isInEditor)
|
|
3485
|
+
console.log("[@antfu/eslint-config] Detected running in editor, some rules are disabled.");
|
|
3486
|
+
}
|
|
3487
|
+
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
3488
|
+
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
|
|
3489
|
+
const configs2 = [];
|
|
3490
|
+
if (enableGitignore) {
|
|
3491
|
+
if (typeof enableGitignore !== "boolean") {
|
|
3492
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
3493
|
+
r({
|
|
3494
|
+
name: "storm/gitignore",
|
|
3495
|
+
...enableGitignore
|
|
3496
|
+
})
|
|
3497
|
+
]));
|
|
3498
|
+
} else {
|
|
3499
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
3500
|
+
r({
|
|
3501
|
+
name: "storm/gitignore",
|
|
3502
|
+
strict: false
|
|
3503
|
+
})
|
|
3504
|
+
]));
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
3508
|
+
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
3509
|
+
configs2.push(ignores(options.ignores), javascript({
|
|
3510
|
+
name,
|
|
3511
|
+
globals,
|
|
3512
|
+
isInEditor,
|
|
3513
|
+
overrides: getOverrides(options, "javascript")
|
|
3514
|
+
}), node(), jsdoc({
|
|
3515
|
+
stylistic: stylisticOptions
|
|
3516
|
+
}), imports({
|
|
3517
|
+
stylistic: stylisticOptions
|
|
3518
|
+
}), nx(resolveSubOptions(options, "nx")), perfectionist());
|
|
3519
|
+
if (enableCSpell) {
|
|
3520
|
+
configs2.push(cspell(resolveSubOptions(options, "cspell")));
|
|
3521
|
+
}
|
|
3522
|
+
if (enableUnicorn) {
|
|
3523
|
+
configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
3524
|
+
}
|
|
3525
|
+
if (enableJsx) {
|
|
3526
|
+
configs2.push(jsx());
|
|
3527
|
+
}
|
|
3528
|
+
if (enableTypeScript) {
|
|
3529
|
+
configs2.push(typescript({
|
|
3530
|
+
...typescriptOptions,
|
|
3531
|
+
componentExts,
|
|
3532
|
+
overrides: getOverrides(options, "typescript"),
|
|
3533
|
+
type: options.type
|
|
3534
|
+
}));
|
|
3535
|
+
}
|
|
3536
|
+
if (stylisticOptions) {
|
|
3537
|
+
configs2.push(stylistic({
|
|
3538
|
+
...stylisticOptions,
|
|
3539
|
+
lessOpinionated: options.lessOpinionated,
|
|
3540
|
+
overrides: getOverrides(options, "stylistic")
|
|
3541
|
+
}));
|
|
3542
|
+
}
|
|
3543
|
+
if (enableRegexp) {
|
|
3544
|
+
configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
3545
|
+
}
|
|
3546
|
+
if (options.test ?? true) {
|
|
3547
|
+
configs2.push(test({
|
|
3548
|
+
isInEditor,
|
|
3549
|
+
overrides: getOverrides(options, "test")
|
|
3550
|
+
}));
|
|
3551
|
+
}
|
|
3552
|
+
if (enableGraphQL) {
|
|
3553
|
+
configs2.push(graphql(resolveSubOptions(options, "graphql")));
|
|
3554
|
+
}
|
|
3555
|
+
if (enableReact) {
|
|
3556
|
+
configs2.push(react({
|
|
3557
|
+
...typescriptOptions,
|
|
3558
|
+
overrides: getOverrides(options, "react"),
|
|
3559
|
+
tsconfigPath
|
|
3560
|
+
}));
|
|
3561
|
+
}
|
|
3562
|
+
if (enableNext) {
|
|
3563
|
+
configs2.push(next(resolveSubOptions(options, "next")));
|
|
3564
|
+
}
|
|
3565
|
+
if (enableStorybook) {
|
|
3566
|
+
configs2.push(storybook(resolveSubOptions(options, "storybook")));
|
|
3567
|
+
}
|
|
3568
|
+
if (enableUnoCSS) {
|
|
3569
|
+
configs2.push(unocss({
|
|
3570
|
+
...resolveSubOptions(options, "unocss"),
|
|
3571
|
+
overrides: getOverrides(options, "unocss")
|
|
3572
|
+
}));
|
|
3573
|
+
}
|
|
3574
|
+
if (enableAstro) {
|
|
3575
|
+
configs2.push(astro({
|
|
3576
|
+
overrides: getOverrides(options, "astro"),
|
|
3577
|
+
stylistic: stylisticOptions
|
|
3578
|
+
}));
|
|
3579
|
+
}
|
|
3580
|
+
if (options.jsonc ?? true) {
|
|
3581
|
+
configs2.push(jsonc({
|
|
3582
|
+
overrides: getOverrides(options, "jsonc"),
|
|
3583
|
+
stylistic: stylisticOptions
|
|
3584
|
+
}), sortPackageJson(), sortTsconfig());
|
|
3585
|
+
}
|
|
3586
|
+
if (options.yaml ?? true) {
|
|
3587
|
+
configs2.push(yaml({
|
|
3588
|
+
overrides: getOverrides(options, "yaml"),
|
|
3589
|
+
stylistic: stylisticOptions
|
|
3590
|
+
}));
|
|
3591
|
+
}
|
|
3592
|
+
if (options.toml ?? true) {
|
|
3593
|
+
configs2.push(toml({
|
|
3594
|
+
overrides: getOverrides(options, "toml"),
|
|
3595
|
+
stylistic: stylisticOptions
|
|
3596
|
+
}));
|
|
3597
|
+
}
|
|
3598
|
+
if (options.markdown ?? true) {
|
|
3599
|
+
configs2.push(markdown({
|
|
3600
|
+
componentExts,
|
|
3601
|
+
overrides: getOverrides(options, "markdown")
|
|
3602
|
+
}));
|
|
3603
|
+
}
|
|
3604
|
+
if (options.formatters) {
|
|
3605
|
+
configs2.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
3606
|
+
}
|
|
3607
|
+
configs2.push(disables());
|
|
3608
|
+
if ("files" in options) {
|
|
3609
|
+
throw new Error('[@storm-software/eslint] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
|
|
3610
|
+
}
|
|
3611
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
3612
|
+
if (key in options) acc[key] = options[key];
|
|
3613
|
+
return acc;
|
|
3614
|
+
}, {});
|
|
3615
|
+
if (Object.keys(fusedConfig).length) configs2.push([
|
|
3616
|
+
fusedConfig
|
|
3617
|
+
]);
|
|
3618
|
+
let composer = new FlatConfigComposer();
|
|
3619
|
+
composer = composer.append(...configs2, ...userConfigs);
|
|
3620
|
+
if (autoRenamePlugins) {
|
|
3621
|
+
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
3622
|
+
}
|
|
3623
|
+
if (isInEditor) {
|
|
3624
|
+
composer = composer.disableRulesFix([
|
|
3625
|
+
"unused-imports/no-unused-imports",
|
|
3626
|
+
"test/no-only-tests",
|
|
3627
|
+
"prefer-const"
|
|
3628
|
+
], {
|
|
3629
|
+
builtinRules: /* @__PURE__ */ __name(() => import([
|
|
3630
|
+
"eslint",
|
|
3631
|
+
"use-at-your-own-risk"
|
|
3632
|
+
].join("/")).then((r) => r.builtinRules), "builtinRules")
|
|
969
3633
|
});
|
|
970
|
-
throw error;
|
|
971
3634
|
}
|
|
3635
|
+
return composer;
|
|
972
3636
|
}
|
|
973
3637
|
__name(getStormConfig, "getStormConfig");
|
|
974
|
-
var
|
|
975
|
-
if (files1 === files2) {
|
|
976
|
-
return true;
|
|
977
|
-
} else if (!files1 || !files2) {
|
|
978
|
-
return false;
|
|
979
|
-
} else if (typeof files1 === "string" && typeof files2 !== "string" || typeof files1 !== "string" && typeof files2 === "string" || Array.isArray(files1) && !Array.isArray(files2) || !Array.isArray(files1) && Array.isArray(files2)) {
|
|
980
|
-
return false;
|
|
981
|
-
} else if (files1.length !== files2.length) {
|
|
982
|
-
return false;
|
|
983
|
-
}
|
|
984
|
-
return files1.every((file, index) => Array.isArray(file) && Array.isArray(files2?.[index]) ? areFilesEqual(file, files2?.[index]) : !Array.isArray(file) && !Array.isArray(files2?.[index]) ? file?.toLowerCase() === files2?.[index]?.toLowerCase() : file === files2);
|
|
985
|
-
}, "areFilesEqual");
|
|
3638
|
+
var preset_default = getStormConfig;
|
|
986
3639
|
export {
|
|
987
|
-
|
|
3640
|
+
preset_default as default,
|
|
3641
|
+
defaultPluginRenaming,
|
|
3642
|
+
getOverrides,
|
|
3643
|
+
getStormConfig,
|
|
3644
|
+
resolveSubOptions
|
|
988
3645
|
};
|