@storm-software/eslint 0.101.0 → 0.107.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 CHANGED
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
21
 
22
22
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
23
23
 
24
- [![Version](https://img.shields.io/badge/version-0.96.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
24
+ [![Version](https://img.shields.io/badge/version-0.106.4-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
25
 
26
26
  <!-- prettier-ignore-start -->
27
27
  <!-- markdownlint-disable -->
@@ -0,0 +1,409 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var preset_exports = {};
30
+ __export(preset_exports, {
31
+ getStormConfig: () => getStormConfig
32
+ });
33
+ module.exports = __toCommonJS(preset_exports);
34
+ var getImportMetaUrl = /* @__PURE__ */ __name(() => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href, "getImportMetaUrl");
35
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
36
+ var import_js = __toESM(require("@eslint/js"), 1);
37
+ var import_eslint_plugin_next = __toESM(require("@next/eslint-plugin-next"), 1);
38
+ var import_nx = __toESM(require("@nx/eslint-plugin/nx.js"), 1);
39
+ var import_config_tools = require("@storm-software/config-tools");
40
+ var import_defu = require("defu");
41
+ var import_eslint_plugin_json = __toESM(require("eslint-plugin-json"), 1);
42
+ var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
43
+ var import_recommended = __toESM(require("eslint-plugin-prettier/recommended"), 1);
44
+ var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
45
+ var import_eslint_plugin_react_compiler = __toESM(require("eslint-plugin-react-compiler"), 1);
46
+ var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
47
+ var import_eslint_plugin_tsdoc = __toESM(require("eslint-plugin-tsdoc"), 1);
48
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
49
+ var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
50
+ var import_globals = __toESM(require("globals"), 1);
51
+ var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
52
+ var import_storm = require("./rules/storm");
53
+ var import_ts_docs = __toESM(require("./rules/ts-docs"), 1);
54
+ var import_banner_plugin = __toESM(require("./utils/banner-plugin"), 1);
55
+ var import_constants = require("./utils/constants");
56
+ var import_format_config = require("./utils/format-config");
57
+ var import_ignores = require("./utils/ignores");
58
+ function getStormConfig(options = {
59
+ rules: {},
60
+ ignores: [],
61
+ globals: {},
62
+ useUnicorn: true,
63
+ markdown: {},
64
+ react: {},
65
+ nx: {},
66
+ useReactCompiler: false,
67
+ logLevel: "info",
68
+ cspellConfigFile: ".vscode/cspell.json"
69
+ }, ...userConfigs) {
70
+ const tsconfig = options.tsconfig;
71
+ const parserOptions = options.parserOptions;
72
+ const typescriptEslintConfigType = options.typescriptEslintConfigType || "eslintRecommended";
73
+ const useUnicorn = options.useUnicorn ?? true;
74
+ const react = options.react ?? {};
75
+ const nx = options.nx ?? {};
76
+ const useReactCompiler = options.useReactCompiler ?? false;
77
+ const logLevel = options.logLevel ?? "info";
78
+ const globals = options.globals ?? {};
79
+ const cspellConfigFile = options.cspellConfigFile || ".vscode/cspell.json";
80
+ try {
81
+ const configs = [
82
+ // Prettier
83
+ import_recommended.default,
84
+ // Import
85
+ // https://www.npmjs.com/package/eslint-plugin-import
86
+ // { plugins: { import: importEslint } },
87
+ // {
88
+ // files: [CODE_FILE],
89
+ // rules: importRules
90
+ // },
91
+ // Json
92
+ // https://www.npmjs.com/package/eslint-plugin-json
93
+ {
94
+ files: [
95
+ "**/*.json"
96
+ ],
97
+ ...import_eslint_plugin_json.default.configs["recommended"],
98
+ rules: {
99
+ "json/json": [
100
+ "warn",
101
+ {
102
+ "allowComments": true
103
+ }
104
+ ]
105
+ }
106
+ },
107
+ {
108
+ files: [
109
+ "**/executors/**/schema.json",
110
+ "**/generators/**/schema.json"
111
+ ],
112
+ rules: nx !== false ? {
113
+ "@nx/workspace/valid-schema-description": "error"
114
+ } : {}
115
+ },
116
+ {
117
+ files: [
118
+ "**/package.json"
119
+ ],
120
+ rules: nx !== false ? {
121
+ "@nx/dependency-checks": [
122
+ "error",
123
+ {
124
+ buildTargets: [
125
+ "build"
126
+ ],
127
+ ignoredDependencies: [
128
+ "typescript"
129
+ ],
130
+ ignoredFiles: options.ignores,
131
+ checkMissingDependencies: true,
132
+ checkObsoleteDependencies: true,
133
+ checkVersionMismatches: false,
134
+ includeTransitiveDependencies: true,
135
+ useLocalPathsForWorkspaceDependencies: true
136
+ }
137
+ ]
138
+ } : {}
139
+ },
140
+ // YML
141
+ // https://www.npmjs.com/package/eslint-plugin-yml
142
+ ...import_eslint_plugin_yml.default.configs["flat/recommended"],
143
+ ...import_eslint_plugin_yml.default.configs["flat/prettier"],
144
+ // CSpell
145
+ {
146
+ ...import_eslint_plugin_json.default.configs["recommended"],
147
+ rules: {
148
+ ...import_eslint_plugin_json.default.configs["recommended"].rules,
149
+ "@cspell/spellchecker": [
150
+ "warn",
151
+ {
152
+ configFile: new URL(cspellConfigFile, importMetaUrl).toString(),
153
+ autoFix: true
154
+ }
155
+ ]
156
+ }
157
+ },
158
+ // User overrides
159
+ ...userConfigs
160
+ ].filter(Boolean);
161
+ if (nx) {
162
+ configs.push({
163
+ plugins: {
164
+ "@nx": import_nx.default
165
+ }
166
+ });
167
+ }
168
+ configs.push(import_js.default.configs.recommended);
169
+ if (typescriptEslintConfigType !== "none") {
170
+ if (!(typescriptEslintConfigType in import_typescript_eslint.default.configs)) {
171
+ console.warn("Invalid TypeScript ESLint configuration type:", typescriptEslintConfigType);
172
+ } else {
173
+ configs.push(...Array.isArray(import_typescript_eslint.default.configs[typescriptEslintConfigType]) ? import_typescript_eslint.default.configs[typescriptEslintConfigType] : [
174
+ import_typescript_eslint.default.configs[typescriptEslintConfigType]
175
+ ]);
176
+ }
177
+ }
178
+ if (useUnicorn) {
179
+ configs.push({
180
+ files: [
181
+ import_constants.TS_FILE
182
+ ],
183
+ plugins: {
184
+ unicorn: import_eslint_plugin_unicorn.default
185
+ },
186
+ rules: {
187
+ ...import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules
188
+ }
189
+ });
190
+ }
191
+ configs.push({
192
+ files: [
193
+ import_constants.TS_FILE
194
+ ],
195
+ plugins: {
196
+ tsdoc: import_eslint_plugin_tsdoc.default
197
+ },
198
+ rules: import_ts_docs.default
199
+ });
200
+ configs.push({
201
+ // ...banner.configs!["recommended"],
202
+ name: "banner",
203
+ plugins: {
204
+ banner: import_banner_plugin.default
205
+ },
206
+ files: [
207
+ import_constants.TS_FILE
208
+ ],
209
+ rules: {
210
+ "banner/banner": [
211
+ "error",
212
+ {
213
+ commentType: "block",
214
+ numNewlines: 2,
215
+ repositoryName: options.name
216
+ }
217
+ ]
218
+ }
219
+ });
220
+ if (react) {
221
+ const reactConfigs = [
222
+ {
223
+ ...import_eslint_plugin_react.default.configs?.recommended,
224
+ plugins: {
225
+ "react": import_eslint_plugin_react.default
226
+ },
227
+ files: [
228
+ "**/*.tsx"
229
+ ],
230
+ ignores: [
231
+ ...import_ignores.ignores,
232
+ ...options.ignores || []
233
+ ],
234
+ ...react
235
+ },
236
+ {
237
+ ...import_eslint_plugin_react_hooks.default.configs?.recommended,
238
+ plugins: {
239
+ "react-hooks": import_eslint_plugin_react_hooks.default
240
+ },
241
+ files: [
242
+ import_constants.TS_FILE
243
+ ],
244
+ ignores: [
245
+ ...import_ignores.ignores,
246
+ ...options.ignores || []
247
+ ]
248
+ }
249
+ ];
250
+ if (useReactCompiler) {
251
+ reactConfigs.push({
252
+ files: [
253
+ "**/*.tsx"
254
+ ],
255
+ ignores: [
256
+ ...import_ignores.ignores,
257
+ ...options.ignores || []
258
+ ],
259
+ plugins: {
260
+ "react-compiler": import_eslint_plugin_react_compiler.default
261
+ },
262
+ rules: {
263
+ "react-compiler/react-compiler": "error"
264
+ }
265
+ });
266
+ }
267
+ configs.push(...reactConfigs);
268
+ }
269
+ if (options.nextFiles && options.nextFiles.length > 0) {
270
+ configs.push({
271
+ ...import_eslint_plugin_next.default.configs["core-web-vitals"],
272
+ ignores: [
273
+ ...options.ignores || []
274
+ ],
275
+ files: options.nextFiles
276
+ });
277
+ }
278
+ const typescriptConfig = {
279
+ files: [
280
+ import_constants.TS_FILE
281
+ ],
282
+ languageOptions: {
283
+ globals: {
284
+ ...Object.fromEntries(Object.keys(import_globals.default).flatMap((group) => Object.keys(import_globals.default[group]).map((key) => [
285
+ key,
286
+ "readonly"
287
+ ]))),
288
+ ...import_globals.default.browser,
289
+ ...import_globals.default.node,
290
+ ...globals,
291
+ "window": "readonly"
292
+ },
293
+ parserOptions: {
294
+ projectService: true,
295
+ ecmaFeatures: {
296
+ jsx: react !== false
297
+ }
298
+ }
299
+ },
300
+ rules: {
301
+ ...(0, import_storm.getStormRulesConfig)({
302
+ ...options,
303
+ typescriptEslintConfigType,
304
+ useUnicorn,
305
+ useNx: nx !== false
306
+ }),
307
+ ...Object.keys(options.rules ?? {}).filter((ruleId) => !useUnicorn || !ruleId.startsWith("unicorn/") || !react || !ruleId.startsWith("react/") && !ruleId.startsWith("react-hooks/")).reduce((ret, ruleId) => {
308
+ ret[ruleId] = options.rules[ruleId];
309
+ return ret;
310
+ }, {})
311
+ },
312
+ ignores: [
313
+ ...import_ignores.ignores,
314
+ ...options.ignores || []
315
+ ]
316
+ };
317
+ if (parserOptions) {
318
+ typescriptConfig.languageOptions ??= {};
319
+ typescriptConfig.languageOptions.parserOptions = parserOptions;
320
+ }
321
+ if (tsconfig) {
322
+ typescriptConfig.languageOptions ??= {};
323
+ typescriptConfig.languageOptions.parserOptions ??= {};
324
+ typescriptConfig.languageOptions.parserOptions.project = tsconfig;
325
+ }
326
+ configs.push(typescriptConfig);
327
+ if (options.markdown) {
328
+ configs.push(...import_eslint_plugin_markdown.default.configs.recommended);
329
+ configs.push({
330
+ files: [
331
+ import_constants.CODE_BLOCK
332
+ ],
333
+ processor: "markdown/markdown",
334
+ rules: {
335
+ "unicorn/filename-case": "off",
336
+ "no-undef": "off",
337
+ "no-unused-expressions": "off",
338
+ "padded-blocks": "off",
339
+ "no-empty-pattern": "off",
340
+ "no-redeclare": "off",
341
+ "no-import-assign": "off",
342
+ ...options.markdown
343
+ }
344
+ });
345
+ configs.push({
346
+ files: [
347
+ "**/*.md/*.js",
348
+ "**/*.md/*.ts"
349
+ ],
350
+ rules: {
351
+ "unicorn/filename-case": "off",
352
+ "no-undef": "off",
353
+ "no-unused-expressions": "off",
354
+ "padded-blocks": "off",
355
+ "no-empty-pattern": "off",
356
+ "no-redeclare": "off",
357
+ "no-import-assign": "off",
358
+ ...options.markdown
359
+ }
360
+ });
361
+ }
362
+ const result = (0, import_format_config.formatConfig)("Preset", configs.reduce((ret, config) => {
363
+ delete config.parserOptions;
364
+ const existingIndex = ret.findIndex((existing) => areFilesEqual(existing.files, config.files));
365
+ if (existingIndex >= 0) {
366
+ ret[existingIndex] = (0, import_defu.defu)(ret[existingIndex], config);
367
+ } else {
368
+ ret.push(config);
369
+ }
370
+ return ret;
371
+ }, []));
372
+ (0, import_config_tools.writeInfo)("\u2699\uFE0F Completed generated Storm ESLint configuration objects", {
373
+ logLevel
374
+ });
375
+ (0, import_config_tools.writeDebug)((0, import_config_tools.formatLogMessage)(result, {
376
+ skip: [
377
+ "globals"
378
+ ]
379
+ }), {
380
+ logLevel
381
+ });
382
+ return result;
383
+ } catch (error) {
384
+ (0, import_config_tools.writeFatal)("Error generating Storm ESLint configuration objects", {
385
+ logLevel
386
+ });
387
+ (0, import_config_tools.writeError)(error, {
388
+ logLevel
389
+ });
390
+ throw error;
391
+ }
392
+ }
393
+ __name(getStormConfig, "getStormConfig");
394
+ const areFilesEqual = /* @__PURE__ */ __name((files1, files2) => {
395
+ if (files1 === files2) {
396
+ return true;
397
+ } else if (!files1 || !files2) {
398
+ return false;
399
+ } 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)) {
400
+ return false;
401
+ } else if (files1.length !== files2.length) {
402
+ return false;
403
+ }
404
+ 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);
405
+ }, "areFilesEqual");
406
+ // Annotate the CommonJS export names for ESM import in node:
407
+ 0 && (module.exports = {
408
+ getStormConfig
409
+ });
@@ -7049,6 +7049,7 @@ type PresetOptions = GetStormRulesConfigOptions & {
7049
7049
  useReactCompiler?: boolean;
7050
7050
  nextFiles?: string[];
7051
7051
  logLevel?: "all" | "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "silent";
7052
+ cspellConfigFile?: string;
7052
7053
  };
7053
7054
  /**
7054
7055
  * Get the ESLint configuration for a Storm workspace.
@@ -7056,6 +7057,6 @@ type PresetOptions = GetStormRulesConfigOptions & {
7056
7057
  * @param options - The preset options.
7057
7058
  * @param userConfigs - Additional ESLint configurations.
7058
7059
  */
7059
- declare function getStormConfig(options?: PresetOptions, ...userConfigs: Linter.FlatConfig[]): Linter.FlatConfig<Linter.RulesRecord>[];
7060
+ declare function getStormConfig(options?: PresetOptions, ...userConfigs: Linter.Config[]): Linter.Config[];
7060
7061
 
7061
7062
  export { type ESLintGlobalsPropValue, type PresetModuleBoundary, type PresetModuleBoundaryDepConstraints, type PresetOptions, getStormConfig };
package/dist/preset.d.ts CHANGED
@@ -7049,6 +7049,7 @@ type PresetOptions = GetStormRulesConfigOptions & {
7049
7049
  useReactCompiler?: boolean;
7050
7050
  nextFiles?: string[];
7051
7051
  logLevel?: "all" | "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "silent";
7052
+ cspellConfigFile?: string;
7052
7053
  };
7053
7054
  /**
7054
7055
  * Get the ESLint configuration for a Storm workspace.
@@ -7056,6 +7057,6 @@ type PresetOptions = GetStormRulesConfigOptions & {
7056
7057
  * @param options - The preset options.
7057
7058
  * @param userConfigs - Additional ESLint configurations.
7058
7059
  */
7059
- declare function getStormConfig(options?: PresetOptions, ...userConfigs: Linter.FlatConfig[]): Linter.FlatConfig<Linter.RulesRecord>[];
7060
+ declare function getStormConfig(options?: PresetOptions, ...userConfigs: Linter.Config[]): Linter.Config[];
7060
7061
 
7061
7062
  export { type ESLintGlobalsPropValue, type PresetModuleBoundary, type PresetModuleBoundaryDepConstraints, type PresetOptions, getStormConfig };