@storm-software/eslint 0.170.157 → 0.170.158

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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.mts +40 -38
  3. package/dist/index.mjs +4 -2
  4. package/dist/plugins.d.mts +4 -605
  5. package/dist/plugins.mjs +15 -1
  6. package/dist/preset.d.mts +3 -1
  7. package/dist/preset.mjs +212 -2
  8. package/dist/typegen.d.mts +2 -0
  9. package/dist/types.d.mts +733 -1
  10. package/dist/types.mjs +3 -0
  11. package/dist/{find-workspace-root-D3UHWbgn.mjs → utils/correct-paths.mjs} +4 -79
  12. package/dist/utils/find-workspace-root.mjs +83 -0
  13. package/dist/{helpers-mce_MNwt.mjs → utils/helpers.mjs} +4 -1
  14. package/dist/utils/package-manager.mjs +20 -0
  15. package/dist/utils/tsconfig.mjs +48 -0
  16. package/package.json +15 -15
  17. package/dist/astro-CKzo6xci.d.mts +0 -5
  18. package/dist/banner-YnHf4ewf.d.mts +0 -5
  19. package/dist/bun-OJPLvfnX.d.mts +0 -5
  20. package/dist/cspell-CfGd6g7m.d.mts +0 -8
  21. package/dist/disables-Dx5b56Fi.d.mts +0 -5
  22. package/dist/formatters-VU6Zu_ju.d.mts +0 -5
  23. package/dist/graphql-ClFinA5J.d.mts +0 -5
  24. package/dist/ignores-CPeru9Fz.d.mts +0 -5
  25. package/dist/imports-CQToT7JW.d.mts +0 -5
  26. package/dist/javascript-BR8uv0Wr.d.mts +0 -5
  27. package/dist/jsdoc-Dy8bHykP.d.mts +0 -5
  28. package/dist/jsonc-YqDXTIOi.d.mts +0 -5
  29. package/dist/jsx-DzqEJSYd.d.mts +0 -5
  30. package/dist/markdown-C5lFEI83.d.mts +0 -5
  31. package/dist/mdx-CDEhveb1.d.mts +0 -5
  32. package/dist/next-DGhspeMc.d.mts +0 -8
  33. package/dist/node-CQgsZ8nv.d.mts +0 -5
  34. package/dist/nx-CLRc6QRM.d.mts +0 -8
  35. package/dist/perfectionist-CgSgqAjV.d.mts +0 -10
  36. package/dist/plugins-CZWNS7l4.mjs +0 -8291
  37. package/dist/pnpm-Cp9VzsCv.d.mts +0 -5
  38. package/dist/preset-x6MId9-7.mjs +0 -265
  39. package/dist/prettier-CboafVRp.d.mts +0 -8
  40. package/dist/react-C5HWHYPh.d.mts +0 -5
  41. package/dist/react-native-DjQo3PXB.d.mts +0 -8
  42. package/dist/regexp-D2Fm6vg7.d.mts +0 -5
  43. package/dist/rolldown-runtime-CMFfr-1z.mjs +0 -26
  44. package/dist/secrets-DfvPNLCF.d.mts +0 -10
  45. package/dist/sort-9_xeGmal.d.mts +0 -16
  46. package/dist/storybook-DqDJ5exI.d.mts +0 -5
  47. package/dist/stylistic-9jDGqsHH.d.mts +0 -9
  48. package/dist/test-Dw-h86ig.d.mts +0 -5
  49. package/dist/toml-ConAZLXy.d.mts +0 -5
  50. package/dist/tsdoc-DcYWMVl0.d.mts +0 -5
  51. package/dist/types-XIthLTox.d.mts +0 -852
  52. package/dist/typescript-BFiiMXDt.d.mts +0 -5
  53. package/dist/unicorn-CQ3PTdfT.d.mts +0 -5
  54. package/dist/unocss-Uw-vEvNU.d.mts +0 -5
  55. package/dist/yaml-Ddbh49WY.d.mts +0 -5
  56. package/dist/zod-7F7dUsU5.d.mts +0 -8
package/dist/preset.mjs CHANGED
@@ -1,3 +1,213 @@
1
- import "./configs/index.mjs";
2
- import { a as preset, i as getOverrides, n as defineConfig, o as resolveSubOptions, r as getConfig, t as defaultPluginRenaming } from "./preset-x6MId9-7.mjs";
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { interopDefault, isInEditorEnv } from "./utils/helpers.mjs";
5
+ import { astro } from "./configs/astro.mjs";
6
+ import { banner } from "./configs/banner.mjs";
7
+ import { bun } from "./configs/bun.mjs";
8
+ import { cspell } from "./configs/cspell.mjs";
9
+ import { disables } from "./configs/disables.mjs";
10
+ import { stylistic } from "./configs/stylistic.mjs";
11
+ import { formatters } from "./configs/formatters.mjs";
12
+ import { graphql } from "./configs/graphql.mjs";
13
+ import { ignores } from "./configs/ignores.mjs";
14
+ import { imports } from "./configs/imports.mjs";
15
+ import { javascript } from "./configs/javascript.mjs";
16
+ import { jsdoc } from "./configs/jsdoc.mjs";
17
+ import { jsonc } from "./configs/jsonc.mjs";
18
+ import { jsx } from "./configs/jsx.mjs";
19
+ import { markdown } from "./configs/markdown.mjs";
20
+ import { mdx } from "./configs/mdx.mjs";
21
+ import { next } from "./configs/next.mjs";
22
+ import { node } from "./configs/node.mjs";
23
+ import { nx } from "./configs/nx.mjs";
24
+ import { perfectionist } from "./configs/perfectionist.mjs";
25
+ import { pnpm } from "./configs/pnpm.mjs";
26
+ import { prettier } from "./configs/prettier.mjs";
27
+ import { react } from "./configs/react.mjs";
28
+ import { reactNative } from "./configs/react-native.mjs";
29
+ import { regexp } from "./configs/regexp.mjs";
30
+ import { secrets } from "./configs/secrets.mjs";
31
+ import { sortPackageJson, sortTsconfig } from "./configs/sort.mjs";
32
+ import { storybook } from "./configs/storybook.mjs";
33
+ import { test } from "./configs/test.mjs";
34
+ import { toml } from "./configs/toml.mjs";
35
+ import { tsdoc } from "./configs/tsdoc.mjs";
36
+ import { typescript } from "./configs/typescript.mjs";
37
+ import { unicorn } from "./configs/unicorn.mjs";
38
+ import { unocss } from "./configs/unocss.mjs";
39
+ import { yaml } from "./configs/yaml.mjs";
40
+ import { zod } from "./configs/zod.mjs";
41
+ import { getTsConfigPath } from "./utils/tsconfig.mjs";
42
+ import { detectPackageManager } from "./utils/package-manager.mjs";
43
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
44
+ import { isPackageExists } from "local-pkg";
45
+ //#region src/preset.ts
46
+ const flatConfigProps = [
47
+ "name",
48
+ "languageOptions",
49
+ "linterOptions",
50
+ "processor",
51
+ "plugins",
52
+ "rules",
53
+ "settings"
54
+ ];
55
+ const defaultPluginRenaming = {
56
+ "@eslint-react": "react",
57
+ "@eslint-react/dom": "react-dom",
58
+ "@eslint-react/hooks-extra": "react-hooks-extra",
59
+ "@eslint-react/naming-convention": "react-naming-convention",
60
+ "@stylistic": "style",
61
+ "@typescript-eslint": "ts",
62
+ "import-x": "import",
63
+ n: "node",
64
+ vitest: "test",
65
+ yml: "yaml"
66
+ };
67
+ function resolveSubOptions(options, key) {
68
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
69
+ }
70
+ function getOverrides(options, key) {
71
+ const sub = resolveSubOptions(options, key);
72
+ return "overrides" in sub ? sub.overrides : {};
73
+ }
74
+ /**
75
+ * Get the ESLint configuration for a Storm workspace.
76
+ *
77
+ * @param options - The preset options.
78
+ * @param userConfigs - Additional ESLint configurations.
79
+ */
80
+ function preset(options, ...userConfigs) {
81
+ const { name, globals = {}, banner: enableBanner = true, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, jsx: enableJsx = true, mdx: enableMdx = false, cspell: enableCSpell = true, react: enableReact = false, "react-native": enableReactNative = false, regexp: enableRegexp = true, next: enableNext = false, graphql: enableGraphQL = false, storybook: enableStorybook = false, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, jsdoc: enableJSDoc = false, tsdoc: enableTSDoc = true, test: enableTest = true, unocss: enableUnoCSS = false, zod: enableZod = false, bun: enableBun, pnpm: enablePnpm } = options;
82
+ const packageManager = detectPackageManager();
83
+ let isInEditor = options.isInEditor;
84
+ if (!isInEditor) {
85
+ isInEditor = isInEditorEnv();
86
+ if (isInEditor) console.log("[@storm-software/eslint] Detected running in editor, some rules are disabled.");
87
+ }
88
+ const stylisticOptions = !options.stylistic ? false : typeof options.stylistic === "object" ? options.stylistic : {};
89
+ if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
90
+ const configs = [];
91
+ if (enableGitignore) {
92
+ if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
93
+ name: "storm/gitignore",
94
+ ...enableGitignore
95
+ })]));
96
+ else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
97
+ name: "storm/gitignore",
98
+ strict: false
99
+ })]));
100
+ }
101
+ configs.push(ignores(options.ignores), javascript({
102
+ globals,
103
+ isInEditor,
104
+ overrides: getOverrides(options, "javascript")
105
+ }), node(), imports({ stylistic: stylisticOptions }), nx(resolveSubOptions(options, "nx")), perfectionist(), secrets({ json: options.jsonc !== false }));
106
+ let typescriptOptions = {};
107
+ if (enableTypeScript) {
108
+ typescriptOptions = resolveSubOptions(options, "typescript");
109
+ if (typescriptOptions.tsconfigPath !== false) typescriptOptions.tsconfigPath = getTsConfigPath(typescriptOptions.tsconfigPath, options.type);
110
+ }
111
+ if (enableTypeScript) configs.push(typescript({
112
+ ...typescriptOptions,
113
+ tsconfigPath: typescriptOptions.tsconfigPath === false ? void 0 : typescriptOptions.tsconfigPath,
114
+ componentExts,
115
+ overrides: getOverrides(options, "typescript"),
116
+ type: options.type
117
+ }));
118
+ if (enableBanner) configs.push(banner({
119
+ ...resolveSubOptions(options, "banner"),
120
+ name,
121
+ overrides: getOverrides(options, "banner")
122
+ }));
123
+ if (!stylisticOptions) configs.push(prettier());
124
+ if (enableCSpell) configs.push(cspell(resolveSubOptions(options, "cspell")));
125
+ if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
126
+ if (enableJSDoc) configs.push(jsdoc({
127
+ ...resolveSubOptions(options, "jsdoc"),
128
+ overrides: getOverrides(options, "jsdoc")
129
+ }));
130
+ if (enableTSDoc) configs.push(tsdoc({
131
+ ...resolveSubOptions(options, "tsdoc"),
132
+ overrides: getOverrides(options, "tsdoc")
133
+ }));
134
+ if (enableJsx) configs.push(jsx());
135
+ if (enableZod) configs.push(zod({ overrides: getOverrides(options, "zod") }));
136
+ if (stylisticOptions) configs.push(stylistic({
137
+ ...stylisticOptions,
138
+ lineEndings: stylisticOptions.lineEndings ?? "unix",
139
+ lessOpinionated: options.lessOpinionated,
140
+ overrides: getOverrides(options, "stylistic")
141
+ }));
142
+ if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
143
+ if (enableTest) configs.push(test({
144
+ isInEditor,
145
+ overrides: getOverrides(options, "test")
146
+ }));
147
+ if (enableGraphQL) configs.push(graphql(resolveSubOptions(options, "graphql")));
148
+ if (enableReact) configs.push(react({
149
+ ...typescriptOptions,
150
+ tsconfigPath: typescriptOptions.tsconfigPath === false ? void 0 : typescriptOptions.tsconfigPath,
151
+ ...typeof enableReact === "boolean" ? { strict: false } : enableReact,
152
+ overrides: getOverrides(options, "react")
153
+ }));
154
+ if (enableReactNative) configs.push(reactNative({
155
+ ...resolveSubOptions(options, "react-native"),
156
+ overrides: getOverrides(options, "react-native")
157
+ }));
158
+ if (enableNext) configs.push(next(resolveSubOptions(options, "next")));
159
+ if (enableStorybook) configs.push(storybook(resolveSubOptions(options, "storybook")));
160
+ if (enableUnoCSS) configs.push(unocss({
161
+ ...resolveSubOptions(options, "unocss"),
162
+ overrides: getOverrides(options, "unocss")
163
+ }));
164
+ if (enableAstro) configs.push(astro({
165
+ overrides: getOverrides(options, "astro"),
166
+ stylistic: stylisticOptions
167
+ }));
168
+ if (enablePnpm ?? packageManager !== "bun") configs.push(pnpm({
169
+ overrides: getOverrides(options, "pnpm"),
170
+ ignore: typeof enablePnpm !== "boolean" ? enablePnpm?.ignore : void 0
171
+ }));
172
+ if (enableBun ?? packageManager === "bun") configs.push(bun({
173
+ overrides: getOverrides(options, "bun"),
174
+ ignore: typeof enableBun !== "boolean" ? enableBun?.ignore : void 0
175
+ }));
176
+ if (options.jsonc ?? true) {
177
+ configs.push(jsonc({
178
+ overrides: getOverrides(options, "jsonc"),
179
+ stylistic: stylisticOptions
180
+ }), sortTsconfig());
181
+ if (stylisticOptions) configs.push(sortPackageJson());
182
+ }
183
+ if (options.yaml ?? true) configs.push(yaml({
184
+ overrides: getOverrides(options, "yaml"),
185
+ stylistic: stylisticOptions
186
+ }));
187
+ if (options.toml ?? true) configs.push(toml({
188
+ overrides: getOverrides(options, "toml"),
189
+ stylistic: stylisticOptions
190
+ }));
191
+ if (options.markdown === true) configs.push(markdown({
192
+ componentExts,
193
+ overrides: getOverrides(options, "markdown")
194
+ }));
195
+ if (enableMdx) configs.push(mdx({ overrides: getOverrides(options, "mdx") }));
196
+ if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
197
+ configs.push(disables());
198
+ if ("files" in options) 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.");
199
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
200
+ if (key in options) acc[key] = options[key];
201
+ return acc;
202
+ }, {});
203
+ if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
204
+ let composer = new FlatConfigComposer();
205
+ composer = composer.append(...configs, ...userConfigs);
206
+ if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
207
+ if (isInEditor) composer = composer.disableRulesFix(["test/no-only-tests"], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
208
+ return composer;
209
+ }
210
+ const getConfig = preset;
211
+ const defineConfig = preset;
212
+ //#endregion
3
213
  export { preset as default, preset, defaultPluginRenaming, defineConfig, getConfig, getOverrides, resolveSubOptions };
@@ -1,3 +1,5 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
1
3
  import { Linter } from "eslint";
2
4
  //#region src/typegen.d.ts
3
5
  interface RuleOptions {