@storm-software/eslint 0.170.155 → 0.170.156

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/preset.js CHANGED
@@ -1,8 +1,344 @@
1
- export { preset_default as default, defaultPluginRenaming, defineConfig, getConfig, getOverrides, preset, resolveSubOptions } from './chunk-XSM4AYON.js';
2
- import './chunk-Y5JY2DPL.js';
3
- import './chunk-F7ZJ6N35.js';
4
- import './chunk-T6GDWDAB.js';
5
- import './chunk-XFFMMX6A.js';
6
- import './chunk-I4ZWVHOG.js';
7
- import './chunk-JBIA43L4.js';
8
- import './chunk-2TYJ2VM7.js';
1
+ import { FlatConfigComposer } from 'eslint-flat-config-utils';
2
+ import { isPackageExists } from 'local-pkg';
3
+ import { ignores, javascript, node, imports, nx, perfectionist, secrets, typescript, banner, prettier, cspell, unicorn, jsdoc, tsdoc, jsx, zod, stylistic, regexp, test, graphql, react, reactNative, next, storybook, unocss, astro, pnpm, jsonc, sortTsconfig, sortPackageJson, yaml, toml, markdown, mdx, formatters, disables } from './configs';
4
+ import { isInEditorEnv, interopDefault } from './utils/helpers';
5
+ import { getTsConfigPath } from './utils/tsconfig';
6
+ import { detectPackageManager } from './utils/package-manager';
7
+ import { bun } from './configs/bun';
8
+
9
+ const flatConfigProps = [
10
+ "name",
11
+ "languageOptions",
12
+ "linterOptions",
13
+ "processor",
14
+ "plugins",
15
+ "rules",
16
+ "settings"
17
+ ];
18
+ const defaultPluginRenaming = {
19
+ "@eslint-react": "react",
20
+ "@eslint-react/dom": "react-dom",
21
+ "@eslint-react/hooks-extra": "react-hooks-extra",
22
+ "@eslint-react/naming-convention": "react-naming-convention",
23
+ "@stylistic": "style",
24
+ "@typescript-eslint": "ts",
25
+ "import-x": "import",
26
+ n: "node",
27
+ vitest: "test",
28
+ yml: "yaml"
29
+ };
30
+ function resolveSubOptions(options, key) {
31
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
32
+ }
33
+ function getOverrides(options, key) {
34
+ const sub = resolveSubOptions(options, key);
35
+ return "overrides" in sub ? sub.overrides : {};
36
+ }
37
+ function preset(options, ...userConfigs) {
38
+ const {
39
+ name,
40
+ globals = {},
41
+ banner: enableBanner = true,
42
+ astro: enableAstro = false,
43
+ autoRenamePlugins = true,
44
+ componentExts = [],
45
+ gitignore: enableGitignore = true,
46
+ jsx: enableJsx = true,
47
+ mdx: enableMdx = false,
48
+ cspell: enableCSpell = true,
49
+ react: enableReact = false,
50
+ "react-native": enableReactNative = false,
51
+ regexp: enableRegexp = true,
52
+ next: enableNext = false,
53
+ graphql: enableGraphQL = false,
54
+ storybook: enableStorybook = false,
55
+ typescript: enableTypeScript = isPackageExists("typescript"),
56
+ unicorn: enableUnicorn = true,
57
+ jsdoc: enableJSDoc = false,
58
+ tsdoc: enableTSDoc = true,
59
+ test: enableTest = true,
60
+ unocss: enableUnoCSS = false,
61
+ zod: enableZod = false,
62
+ bun: enableBun,
63
+ pnpm: enablePnpm
64
+ } = options;
65
+ const packageManager = detectPackageManager();
66
+ let isInEditor = options.isInEditor;
67
+ if (!isInEditor) {
68
+ isInEditor = isInEditorEnv();
69
+ if (isInEditor) {
70
+ console.log(
71
+ "[@storm-software/eslint] Detected running in editor, some rules are disabled."
72
+ );
73
+ }
74
+ }
75
+ const stylisticOptions = !options.stylistic ? false : typeof options.stylistic === "object" ? options.stylistic : {};
76
+ if (stylisticOptions && !("jsx" in stylisticOptions)) {
77
+ stylisticOptions.jsx = enableJsx;
78
+ }
79
+ const configs = [];
80
+ if (enableGitignore) {
81
+ if (typeof enableGitignore !== "boolean") {
82
+ configs.push(
83
+ interopDefault(import('eslint-config-flat-gitignore')).then((r) => [
84
+ r({
85
+ name: "storm/gitignore",
86
+ ...enableGitignore
87
+ })
88
+ ])
89
+ );
90
+ } else {
91
+ configs.push(
92
+ interopDefault(import('eslint-config-flat-gitignore')).then((r) => [
93
+ r({
94
+ name: "storm/gitignore",
95
+ strict: false
96
+ })
97
+ ])
98
+ );
99
+ }
100
+ }
101
+ configs.push(
102
+ ignores(options.ignores),
103
+ javascript({
104
+ globals,
105
+ isInEditor,
106
+ overrides: getOverrides(options, "javascript")
107
+ }),
108
+ node(),
109
+ imports({
110
+ stylistic: stylisticOptions
111
+ }),
112
+ nx(resolveSubOptions(options, "nx")),
113
+ perfectionist(),
114
+ secrets({ json: options.jsonc !== false })
115
+ );
116
+ let typescriptOptions = {};
117
+ if (enableTypeScript) {
118
+ typescriptOptions = resolveSubOptions(options, "typescript");
119
+ if (typescriptOptions.tsconfigPath !== false) {
120
+ typescriptOptions.tsconfigPath = getTsConfigPath(
121
+ typescriptOptions.tsconfigPath,
122
+ options.type
123
+ );
124
+ }
125
+ }
126
+ if (enableTypeScript) {
127
+ configs.push(
128
+ typescript({
129
+ ...typescriptOptions,
130
+ tsconfigPath: typescriptOptions.tsconfigPath === false ? void 0 : typescriptOptions.tsconfigPath,
131
+ componentExts,
132
+ overrides: getOverrides(options, "typescript"),
133
+ type: options.type
134
+ })
135
+ );
136
+ }
137
+ if (enableBanner) {
138
+ configs.push(
139
+ banner({
140
+ ...resolveSubOptions(options, "banner"),
141
+ name,
142
+ overrides: getOverrides(options, "banner")
143
+ })
144
+ );
145
+ }
146
+ if (!stylisticOptions) {
147
+ configs.push(prettier());
148
+ }
149
+ if (enableCSpell) {
150
+ configs.push(cspell(resolveSubOptions(options, "cspell")));
151
+ }
152
+ if (enableUnicorn) {
153
+ configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
154
+ }
155
+ if (enableJSDoc) {
156
+ configs.push(
157
+ jsdoc({
158
+ ...resolveSubOptions(options, "jsdoc"),
159
+ overrides: getOverrides(options, "jsdoc")
160
+ })
161
+ );
162
+ }
163
+ if (enableTSDoc) {
164
+ configs.push(
165
+ tsdoc({
166
+ ...resolveSubOptions(options, "tsdoc"),
167
+ overrides: getOverrides(options, "tsdoc")
168
+ })
169
+ );
170
+ }
171
+ if (enableJsx) {
172
+ configs.push(jsx());
173
+ }
174
+ if (enableZod) {
175
+ configs.push(
176
+ zod({
177
+ overrides: getOverrides(options, "zod")
178
+ })
179
+ );
180
+ }
181
+ if (stylisticOptions) {
182
+ configs.push(
183
+ stylistic({
184
+ ...stylisticOptions,
185
+ lineEndings: stylisticOptions.lineEndings ?? "unix",
186
+ lessOpinionated: options.lessOpinionated,
187
+ overrides: getOverrides(options, "stylistic")
188
+ })
189
+ );
190
+ }
191
+ if (enableRegexp) {
192
+ configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
193
+ }
194
+ if (enableTest) {
195
+ configs.push(
196
+ test({
197
+ isInEditor,
198
+ overrides: getOverrides(options, "test")
199
+ })
200
+ );
201
+ }
202
+ if (enableGraphQL) {
203
+ configs.push(graphql(resolveSubOptions(options, "graphql")));
204
+ }
205
+ if (enableReact) {
206
+ configs.push(
207
+ react({
208
+ ...typescriptOptions,
209
+ tsconfigPath: typescriptOptions.tsconfigPath === false ? void 0 : typescriptOptions.tsconfigPath,
210
+ ...typeof enableReact === "boolean" ? { strict: false } : enableReact,
211
+ overrides: getOverrides(options, "react")
212
+ })
213
+ );
214
+ }
215
+ if (enableReactNative) {
216
+ configs.push(
217
+ reactNative({
218
+ ...resolveSubOptions(options, "react-native"),
219
+ overrides: getOverrides(options, "react-native")
220
+ })
221
+ );
222
+ }
223
+ if (enableNext) {
224
+ configs.push(next(resolveSubOptions(options, "next")));
225
+ }
226
+ if (enableStorybook) {
227
+ configs.push(storybook(resolveSubOptions(options, "storybook")));
228
+ }
229
+ if (enableUnoCSS) {
230
+ configs.push(
231
+ unocss({
232
+ ...resolveSubOptions(options, "unocss"),
233
+ overrides: getOverrides(options, "unocss")
234
+ })
235
+ );
236
+ }
237
+ if (enableAstro) {
238
+ configs.push(
239
+ astro({
240
+ overrides: getOverrides(options, "astro"),
241
+ stylistic: stylisticOptions
242
+ })
243
+ );
244
+ }
245
+ if (enablePnpm ?? packageManager !== "bun") {
246
+ configs.push(
247
+ pnpm({
248
+ overrides: getOverrides(options, "pnpm"),
249
+ ignore: typeof enablePnpm !== "boolean" ? enablePnpm?.ignore : void 0
250
+ })
251
+ );
252
+ }
253
+ if (enableBun ?? packageManager === "bun") {
254
+ configs.push(bun({
255
+ overrides: getOverrides(options, "bun"),
256
+ ignore: typeof enableBun !== "boolean" ? enableBun?.ignore : void 0
257
+ }));
258
+ }
259
+ if (options.jsonc ?? true) {
260
+ configs.push(
261
+ jsonc({
262
+ overrides: getOverrides(options, "jsonc"),
263
+ stylistic: stylisticOptions
264
+ }),
265
+ sortTsconfig()
266
+ );
267
+ if (stylisticOptions) {
268
+ configs.push(sortPackageJson());
269
+ }
270
+ }
271
+ if (options.yaml ?? true) {
272
+ configs.push(
273
+ yaml({
274
+ overrides: getOverrides(options, "yaml"),
275
+ stylistic: stylisticOptions
276
+ })
277
+ );
278
+ }
279
+ if (options.toml ?? true) {
280
+ configs.push(
281
+ toml({
282
+ overrides: getOverrides(options, "toml"),
283
+ stylistic: stylisticOptions
284
+ })
285
+ );
286
+ }
287
+ if (options.markdown === true) {
288
+ configs.push(
289
+ markdown({
290
+ componentExts,
291
+ overrides: getOverrides(options, "markdown")
292
+ })
293
+ );
294
+ }
295
+ if (enableMdx) {
296
+ configs.push(
297
+ mdx({
298
+ overrides: getOverrides(options, "mdx")
299
+ })
300
+ );
301
+ }
302
+ if (options.formatters) {
303
+ configs.push(
304
+ formatters(
305
+ options.formatters,
306
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
307
+ )
308
+ );
309
+ }
310
+ configs.push(disables());
311
+ if ("files" in options) {
312
+ throw new Error(
313
+ '[@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.'
314
+ );
315
+ }
316
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
317
+ if (key in options) {
318
+ acc[key] = options[key];
319
+ }
320
+ return acc;
321
+ }, {});
322
+ if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
323
+ let composer = new FlatConfigComposer();
324
+ composer = composer.append(
325
+ ...configs,
326
+ ...userConfigs
327
+ );
328
+ if (autoRenamePlugins) {
329
+ composer = composer.renamePlugins(defaultPluginRenaming);
330
+ }
331
+ if (isInEditor) {
332
+ composer = composer.disableRulesFix(["test/no-only-tests"], {
333
+ builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then(
334
+ (r) => r.builtinRules
335
+ )
336
+ });
337
+ }
338
+ return composer;
339
+ }
340
+ const getConfig = preset;
341
+ const defineConfig = preset;
342
+ var preset_default = preset;
343
+
344
+ export { preset_default as default, defaultPluginRenaming, defineConfig, getConfig, getOverrides, preset, resolveSubOptions };
package/dist/types.cjs CHANGED
@@ -1,2 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var typegen_d = require('./typegen.d');
4
+
5
+
6
+
7
+ Object.keys(typegen_d).forEach(function (k) {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
+ enumerable: true,
10
+ get: function () { return typegen_d[k]; }
11
+ });
12
+ });
package/dist/types.js CHANGED
@@ -1,4 +1 @@
1
- import { init_esm_shims } from './chunk-2TYJ2VM7.js';
2
-
3
- // src/types.ts
4
- init_esm_shims();
1
+ export * from './typegen.d';
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // src/utils/combine.ts
4
3
  async function combine(...configs) {
5
4
  const resolved = await Promise.all(configs);
6
5
  return resolved.flat();
@@ -1,7 +1,3 @@
1
- import { init_esm_shims } from '../chunk-2TYJ2VM7.js';
2
-
3
- // src/utils/combine.ts
4
- init_esm_shims();
5
1
  async function combine(...configs) {
6
2
  const resolved = await Promise.all(configs);
7
3
  return resolved.flat();
@@ -1,21 +1,20 @@
1
1
  'use strict';
2
2
 
3
- // src/utils/correct-paths.ts
4
- var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
5
4
  function normalizeWindowsPath(input = "") {
6
5
  if (!input) {
7
6
  return input;
8
7
  }
9
8
  return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
10
9
  }
11
- var _UNC_REGEX = /^[/\\]{2}/;
12
- var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
13
- var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
14
- var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
15
- var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
16
- var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
17
- var sep = "/";
18
- var correctPaths = function(path) {
10
+ const _UNC_REGEX = /^[/\\]{2}/;
11
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
12
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
13
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
14
+ const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
15
+ const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
16
+ const sep = "/";
17
+ const correctPaths = function(path) {
19
18
  if (!path || path.length === 0) {
20
19
  return ".";
21
20
  }
@@ -44,7 +43,7 @@ var correctPaths = function(path) {
44
43
  }
45
44
  return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
46
45
  };
47
- var joinPaths = function(...segments) {
46
+ const joinPaths = function(...segments) {
48
47
  let path = "";
49
48
  for (const seg of segments) {
50
49
  if (!seg) {
@@ -71,7 +70,7 @@ function cwd() {
71
70
  }
72
71
  return "/";
73
72
  }
74
- var resolve = function(...arguments_) {
73
+ const resolve = function(...arguments_) {
75
74
  arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
76
75
  let resolvedPath = "";
77
76
  let resolvedAbsolute = false;
@@ -148,18 +147,18 @@ function normalizeString(path, allowAboveRoot) {
148
147
  }
149
148
  return res;
150
149
  }
151
- var isAbsolute = function(p) {
150
+ const isAbsolute = function(p) {
152
151
  return _IS_ABSOLUTE_RE.test(p);
153
152
  };
154
- var toNamespacedPath = function(p) {
153
+ const toNamespacedPath = function(p) {
155
154
  return normalizeWindowsPath(p);
156
155
  };
157
- var extname = function(p) {
156
+ const extname = function(p) {
158
157
  if (p === "..") return "";
159
158
  const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
160
159
  return match && match[1] || "";
161
160
  };
162
- var relative = function(from, to) {
161
+ const relative = function(from, to) {
163
162
  const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
164
163
  const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
165
164
  if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
@@ -175,14 +174,14 @@ var relative = function(from, to) {
175
174
  }
176
175
  return [..._from.map(() => ".."), ..._to].join("/");
177
176
  };
178
- var dirname = function(p) {
177
+ const dirname = function(p) {
179
178
  const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
180
179
  if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
181
180
  segments[0] += "/";
182
181
  }
183
182
  return segments.join("/") || (isAbsolute(p) ? "/" : ".");
184
183
  };
185
- var format = function(p) {
184
+ const format = function(p) {
186
185
  const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
187
186
  const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
188
187
  Boolean
@@ -191,7 +190,7 @@ var format = function(p) {
191
190
  p.root ? resolve(...segments) : segments.join("/")
192
191
  );
193
192
  };
194
- var basename = function(p, extension) {
193
+ const basename = function(p, extension) {
195
194
  const segments = normalizeWindowsPath(p).split("/");
196
195
  let lastSegment = "";
197
196
  for (let i = segments.length - 1; i >= 0; i--) {
@@ -203,7 +202,7 @@ var basename = function(p, extension) {
203
202
  }
204
203
  return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
205
204
  };
206
- var parse = function(p) {
205
+ const parse = function(p) {
207
206
  const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
208
207
  const base = basename(p);
209
208
  const extension = extname(base);