@storm-software/eslint 0.169.93 → 0.169.94

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 (46) hide show
  1. package/dist/chunk-4CXNUMUG.js +2 -39
  2. package/dist/chunk-A32JZBPO.js +2 -6
  3. package/dist/chunk-DJ2ZXQYV.js +4 -10
  4. package/dist/chunk-FXLMJ2Y5.js +3 -9
  5. package/dist/{chunk-DPTIR64R.js → chunk-IWQLEJ77.js} +11 -19
  6. package/dist/chunk-O5CGESKJ.js +20 -29
  7. package/dist/chunk-PWQ34SJ2.js +4 -10
  8. package/dist/chunk-T4LUMNGJ.js +3 -21
  9. package/dist/chunk-UVJN4TQE.js +5 -12
  10. package/dist/preset.cjs +9387 -0
  11. package/dist/preset.d.cts +34 -0
  12. package/dist/preset.js +128 -329
  13. package/dist/types.cjs +2 -0
  14. package/dist/types.d.cts +18781 -0
  15. package/dist/types.js +1 -3
  16. package/dist/utils/banner-plugin.cjs +454 -0
  17. package/dist/utils/banner-plugin.d.cts +6 -0
  18. package/dist/utils/banner-plugin.js +4 -9
  19. package/dist/utils/combine.cjs +9 -0
  20. package/dist/utils/combine.d.cts +14 -0
  21. package/dist/utils/combine.js +3 -6
  22. package/dist/utils/constants.cjs +206 -0
  23. package/dist/utils/constants.d.cts +36 -0
  24. package/dist/utils/constants.js +2 -73
  25. package/dist/utils/correct-paths.cjs +232 -0
  26. package/dist/utils/correct-paths.d.cts +30 -0
  27. package/dist/utils/correct-paths.js +2 -33
  28. package/dist/utils/find-workspace-root.cjs +201 -0
  29. package/dist/utils/find-workspace-root.d.cts +16 -0
  30. package/dist/utils/find-workspace-root.js +3 -10
  31. package/dist/utils/format-config.cjs +20 -0
  32. package/dist/utils/format-config.d.cts +5 -0
  33. package/dist/utils/format-config.js +2 -7
  34. package/dist/utils/get-file-banner.cjs +103 -0
  35. package/dist/utils/get-file-banner.d.cts +12 -0
  36. package/dist/utils/get-file-banner.js +3 -8
  37. package/dist/utils/helpers.cjs +87 -0
  38. package/dist/utils/helpers.d.cts +55 -0
  39. package/dist/utils/helpers.js +2 -19
  40. package/dist/utils/index.cjs +224 -0
  41. package/dist/utils/index.d.cts +3 -0
  42. package/dist/utils/index.js +3 -79
  43. package/dist/utils/tsconfig-path.cjs +152 -0
  44. package/dist/utils/tsconfig-path.d.cts +3 -0
  45. package/dist/utils/tsconfig-path.js +3 -8
  46. package/package.json +44 -46
package/dist/types.js CHANGED
@@ -1,6 +1,4 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-PWQ34SJ2.js";
1
+ import { init_esm_shims } from './chunk-PWQ34SJ2.js';
4
2
 
5
3
  // src/types.ts
6
4
  init_esm_shims();
@@ -0,0 +1,454 @@
1
+ 'use strict';
2
+
3
+ var utils = require('@typescript-eslint/utils');
4
+ var os = require('os');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var os__default = /*#__PURE__*/_interopDefault(os);
9
+
10
+ // src/utils/banner-plugin.ts
11
+
12
+ // src/utils/constants.ts
13
+ var ACRONYMS_LIST = [
14
+ "API",
15
+ "ASCII",
16
+ "CPU",
17
+ "CSS",
18
+ "DNS",
19
+ "EOF",
20
+ "GUID",
21
+ "HTML",
22
+ "HTTP",
23
+ "HTTPS",
24
+ "ID",
25
+ "IP",
26
+ "JSON",
27
+ "LHS",
28
+ "OEM",
29
+ "PP",
30
+ "QA",
31
+ "RAM",
32
+ "RHS",
33
+ "RPC",
34
+ "RSS",
35
+ "SLA",
36
+ "SMTP",
37
+ "SQL",
38
+ "SSH",
39
+ "SSL",
40
+ "TCP",
41
+ "TLS",
42
+ "TTL",
43
+ "UDP",
44
+ "UI",
45
+ "UID",
46
+ "UUID",
47
+ "URI",
48
+ "URL",
49
+ "UTF",
50
+ "VM",
51
+ "XML",
52
+ "XSS"
53
+ ];
54
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
55
+
56
+ // src/utils/get-file-banner.ts
57
+ var getFileBanner = (name = "", workspaceConfig) => {
58
+ if (!name) {
59
+ name = process.env.STORM_NAME || "";
60
+ }
61
+ let padding = " ";
62
+ for (let i = 0; i < name.length + 2 && padding.length > 4; i++) {
63
+ padding = padding.slice(0, -1);
64
+ }
65
+ let titleName = name || workspaceConfig?.name;
66
+ if (titleName) {
67
+ if (titleName?.startsWith("@")) {
68
+ titleName = titleName.slice(1);
69
+ }
70
+ titleName = (titleName.charAt(0).toUpperCase() + titleName.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
71
+ if (ACRONYMS_LIST.includes(word.toUpperCase())) {
72
+ return word.toUpperCase();
73
+ }
74
+ return word.charAt(0).toUpperCase() + word.slice(1);
75
+ }).join(" ");
76
+ }
77
+ const license = (process.env.STORM_LICENSE || workspaceConfig?.license || "Apache-2.0").split(" ").filter((word) => word && word.toLowerCase() !== "license").join(" ");
78
+ const organization = process.env.STORM_ORG_NAME || process.env.STORM_ORGANIZATION_NAME || process.env.STORM_ORG || process.env.STORM_ORGANIZATION || (void 0) || "storm-software";
79
+ return ` -------------------------------------------------------------------
80
+
81
+ ${padding}\u26A1 ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
82
+ if (ACRONYMS_LIST.includes(word.toUpperCase())) {
83
+ return word.toUpperCase();
84
+ }
85
+ return word.charAt(0).toUpperCase() + word.slice(1);
86
+ }).join(" ")} ${titleName ? `- ${titleName}` : ""}
87
+
88
+ This code was released as part of ${titleName ? `the ${titleName}` : `a ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
89
+ if (ACRONYMS_LIST.includes(word.toUpperCase())) {
90
+ return word.toUpperCase();
91
+ }
92
+ return word.charAt(0).toUpperCase() + word.slice(1);
93
+ }).join(" ")}`} project. ${titleName ? titleName : "The project"}
94
+ is maintained by ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
95
+ if (ACRONYMS_LIST.includes(word.toUpperCase())) {
96
+ return word.toUpperCase();
97
+ }
98
+ return word.charAt(0).toUpperCase() + word.slice(1);
99
+ }).join(" ")} under the ${license} license, and is
100
+ free for commercial and private use. For more information, please visit
101
+ our licensing page at ${process.env.STORM_LICENSING?.replace(/\/$/, "") || workspaceConfig?.licensing?.replace(/\/$/, "") || "https://stormsoftware.com/licenses"}/${name ? `projects/${name}` : ""}.
102
+
103
+ Website: ${process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com"}
104
+ Repository: ${process.env.STORM_REPOSITORY || workspaceConfig?.repository || `https://github.com/${organization}${name ? `/${name}` : ""}`}
105
+ Documentation: ${process.env.STORM_DOCS || workspaceConfig?.docs || `https://docs.stormsoftware.com${name ? `/projects/${name}` : ""}`}
106
+ Contact: ${(process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com").endsWith("/") ? (process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com").slice(-1) : process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com"}/contact
107
+
108
+ SPDX-License-Identifier: ${license}
109
+
110
+ ------------------------------------------------------------------- `;
111
+ };
112
+
113
+ // src/utils/banner-plugin.ts
114
+ function match(actual, expected) {
115
+ if (expected.test) {
116
+ return expected.test(actual);
117
+ } else {
118
+ return expected === actual;
119
+ }
120
+ }
121
+ function excludeShebangs(comments) {
122
+ return comments.filter((comment) => {
123
+ return comment.type !== "Shebang";
124
+ });
125
+ }
126
+ function getLeadingComments(context, node) {
127
+ const all = excludeShebangs(
128
+ context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node)
129
+ );
130
+ if (all[0].type.toLowerCase() === "block") {
131
+ return [all[0]];
132
+ }
133
+ let i = 1;
134
+ for (i = 1; i < all.length; ++i) {
135
+ const txt = context.getSourceCode().getText().slice(all[i - 1].range[1], all[i].range[0]);
136
+ if (!txt.match(/^(\r\n|\r|\n)$/)) {
137
+ break;
138
+ }
139
+ }
140
+ return all.slice(0, i);
141
+ }
142
+ function genCommentBody(commentType, textArray, eol, numNewlines) {
143
+ const eols = eol.repeat(numNewlines);
144
+ if (commentType === "block") {
145
+ return "/*" + textArray.join(eol) + "*/" + eols;
146
+ } else {
147
+ return "//" + textArray.join(eol + "//") + eols;
148
+ }
149
+ }
150
+ function genCommentsRange(context, comments, eol) {
151
+ const start = comments[0].range[0];
152
+ let end = comments.slice(-1)[0].range[1];
153
+ if (context.getSourceCode().text[end] === eol) {
154
+ end += eol.length;
155
+ }
156
+ return [start, end];
157
+ }
158
+ function genPrependFixer(commentType, node, bannerLines, eol, numNewlines) {
159
+ return function(fixer) {
160
+ return fixer.insertTextBefore(
161
+ node,
162
+ genCommentBody(commentType, bannerLines, eol, numNewlines)
163
+ );
164
+ };
165
+ }
166
+ function genReplaceFixer(commentType, context, leadingComments, bannerLines, eol, numNewlines) {
167
+ return function(fixer) {
168
+ return fixer.replaceTextRange(
169
+ genCommentsRange(context, leadingComments, eol),
170
+ genCommentBody(commentType, bannerLines, eol, numNewlines)
171
+ );
172
+ };
173
+ }
174
+ function getEOL(options) {
175
+ if (options.lineEndings === "unix") {
176
+ return "\n";
177
+ }
178
+ if (options.lineEndings === "windows") {
179
+ return "\r\n";
180
+ }
181
+ return os__default.default.EOL;
182
+ }
183
+ function hasBanner(commentType = "block", src, eol) {
184
+ if (src.startsWith("#!")) {
185
+ const bannerLines = src.split(eol);
186
+ if (bannerLines && bannerLines.length > 1) {
187
+ bannerLines.shift();
188
+ while (bannerLines.length && bannerLines[0] && !bannerLines[0].trim()) {
189
+ bannerLines.shift();
190
+ }
191
+ if (bannerLines.length) {
192
+ src = bannerLines.join(eol);
193
+ } else {
194
+ return false;
195
+ }
196
+ }
197
+ }
198
+ return commentType === "block" && src.startsWith("/*") || commentType === "line" && src.startsWith("//") || commentType !== "block" && commentType !== "line" && commentType && src.startsWith(commentType);
199
+ }
200
+ function matchesLineEndings(src, num) {
201
+ for (let j = 0; j < num; ++j) {
202
+ const m = src.match(/^(\r\n|\r|\n)/);
203
+ if (m) {
204
+ src = src.slice(m.index + m[0].length);
205
+ } else {
206
+ return false;
207
+ }
208
+ }
209
+ return true;
210
+ }
211
+ var bannerRule = utils.ESLintUtils.RuleCreator(
212
+ () => `https://developer.stormsoftware.com/eslint/rules/banner`
213
+ )({
214
+ name: "banner",
215
+ meta: {
216
+ docs: {
217
+ description: "Ensures the file has a organization specific banner at the top of source code files"
218
+ },
219
+ schema: [
220
+ {
221
+ type: "object",
222
+ properties: {
223
+ banner: {
224
+ type: "string",
225
+ description: "The banner to enforce at the top of the file. If not provided, the banner will be read from the file specified in the commentStart option"
226
+ },
227
+ name: {
228
+ type: "string",
229
+ description: "The name of the repository to use when reading the banner from a file."
230
+ },
231
+ commentType: {
232
+ type: "string",
233
+ description: "The comment token to use for the banner. Defaults to block ('/* <banner> */')"
234
+ },
235
+ numNewlines: {
236
+ type: "number",
237
+ description: "The number of newlines to use after the banner. Defaults to 1"
238
+ },
239
+ lineEndings: {
240
+ type: "string",
241
+ enum: ["unix", "windows"],
242
+ description: "The type of line endings to use. Defaults to the system default"
243
+ }
244
+ },
245
+ additionalProperties: false
246
+ }
247
+ ],
248
+ type: "layout",
249
+ messages: {
250
+ missingBanner: "Missing banner",
251
+ incorrectComment: "Banner should use the {{commentType}} comment type",
252
+ incorrectBanner: "Incorrect banner",
253
+ noNewlineAfterBanner: "No newline after banner"
254
+ },
255
+ fixable: "whitespace"
256
+ },
257
+ defaultOptions: [
258
+ {
259
+ name: "",
260
+ commentType: "block",
261
+ numNewlines: 2,
262
+ lineEndings: "unix"
263
+ }
264
+ ],
265
+ create(context, [
266
+ {
267
+ banner,
268
+ name = "",
269
+ commentType = "block",
270
+ numNewlines = 2,
271
+ lineEndings = "unix"
272
+ }
273
+ ]) {
274
+ if (!banner) {
275
+ banner = getFileBanner(name);
276
+ }
277
+ const options = context.options;
278
+ const eol = getEOL({ lineEndings, ...options });
279
+ const bannerLines = banner.split(/\r?\n/);
280
+ let fixLines = bannerLines;
281
+ return {
282
+ Program: function(node) {
283
+ if (!hasBanner(commentType, context.sourceCode.getText(), eol)) {
284
+ context.report({
285
+ loc: node.loc,
286
+ messageId: "missingBanner",
287
+ fix: genPrependFixer(commentType, node, fixLines, eol, numNewlines)
288
+ });
289
+ } else {
290
+ const leadingComments = getLeadingComments(context, node);
291
+ if (!leadingComments.length) {
292
+ context.report({
293
+ loc: node.loc,
294
+ messageId: "missingBanner",
295
+ fix: genPrependFixer(commentType, node, fixLines, eol, numNewlines)
296
+ });
297
+ } else if (leadingComments[0].type.toLowerCase() !== commentType) {
298
+ context.report({
299
+ loc: node.loc,
300
+ messageId: "incorrectComment",
301
+ data: {
302
+ commentType
303
+ },
304
+ fix: genReplaceFixer(
305
+ commentType,
306
+ context,
307
+ leadingComments,
308
+ fixLines,
309
+ eol,
310
+ numNewlines
311
+ )
312
+ });
313
+ } else {
314
+ if (commentType === "line") {
315
+ if (leadingComments.length < bannerLines.length) {
316
+ context.report({
317
+ loc: node.loc,
318
+ messageId: "missingBanner",
319
+ fix: genReplaceFixer(
320
+ commentType,
321
+ context,
322
+ leadingComments,
323
+ fixLines,
324
+ eol,
325
+ numNewlines
326
+ )
327
+ });
328
+ return;
329
+ }
330
+ for (let i = 0; i < bannerLines.length; i++) {
331
+ if (!match(leadingComments[i].value, bannerLines[i])) {
332
+ context.report({
333
+ loc: node.loc,
334
+ messageId: "incorrectBanner",
335
+ fix: genReplaceFixer(
336
+ commentType,
337
+ context,
338
+ leadingComments,
339
+ fixLines,
340
+ eol,
341
+ numNewlines
342
+ )
343
+ });
344
+ return;
345
+ }
346
+ }
347
+ const postLineBanner = context.getSourceCode().text.substr(
348
+ leadingComments[bannerLines.length - 1].range[1],
349
+ (numNewlines ?? 1) * 2
350
+ );
351
+ if (!matchesLineEndings(postLineBanner, numNewlines)) {
352
+ context.report({
353
+ loc: node.loc,
354
+ messageId: "noNewlineAfterBanner",
355
+ fix: genReplaceFixer(
356
+ commentType,
357
+ context,
358
+ leadingComments,
359
+ fixLines,
360
+ eol,
361
+ numNewlines
362
+ )
363
+ });
364
+ }
365
+ } else {
366
+ let leadingLines = [leadingComments[0].value];
367
+ if (bannerLines.length > 1) {
368
+ leadingLines = leadingComments[0].value.split(/\r?\n/);
369
+ }
370
+ let hasError = false;
371
+ if (leadingLines.length > bannerLines.length) {
372
+ hasError = true;
373
+ }
374
+ for (let i = 0; !hasError && i < bannerLines.length; i++) {
375
+ if (!match(leadingLines[i], bannerLines[i])) {
376
+ hasError = true;
377
+ }
378
+ }
379
+ if (hasError) {
380
+ if (bannerLines.length > 1) {
381
+ fixLines = [fixLines.join(eol)];
382
+ }
383
+ context.report({
384
+ loc: node.loc,
385
+ messageId: "incorrectBanner",
386
+ fix: genReplaceFixer(
387
+ commentType,
388
+ context,
389
+ leadingComments,
390
+ fixLines,
391
+ eol,
392
+ numNewlines
393
+ )
394
+ });
395
+ } else {
396
+ const postBlockBanner = context.getSourceCode().text.substr(
397
+ leadingComments[0].range[1],
398
+ (numNewlines ?? 1) * 2
399
+ );
400
+ if (!matchesLineEndings(postBlockBanner, numNewlines)) {
401
+ context.report({
402
+ loc: node.loc,
403
+ messageId: "noNewlineAfterBanner",
404
+ fix: genReplaceFixer(
405
+ commentType,
406
+ context,
407
+ leadingComments,
408
+ fixLines,
409
+ eol,
410
+ numNewlines
411
+ )
412
+ });
413
+ }
414
+ }
415
+ }
416
+ }
417
+ }
418
+ }
419
+ };
420
+ }
421
+ });
422
+ var plugin = {
423
+ meta: {
424
+ name: "eslint-plugin-banner",
425
+ version: "0.0.1"
426
+ },
427
+ configs: {},
428
+ rules: {
429
+ banner: bannerRule
430
+ },
431
+ processors: {}
432
+ };
433
+ plugin.configs && (plugin.configs.recommended = {
434
+ name: "banner/recommended",
435
+ plugins: { banner: plugin },
436
+ files: [GLOB_SRC],
437
+ ignores: [
438
+ "!**/docs/**/*",
439
+ "!**/crates/**/*",
440
+ "!**/tmp/**/*",
441
+ "!**/dist/**/*",
442
+ "!**/coverage/**/*",
443
+ "!**/node_modules/**/*",
444
+ "!**/.cache/**/*",
445
+ "!**/.nx/**/*",
446
+ "!**/.storm/**/*"
447
+ ],
448
+ rules: {
449
+ "banner/banner": ["error", { commentType: "block", numNewlines: 2 }]
450
+ }
451
+ });
452
+ var banner_plugin_default = plugin;
453
+
454
+ module.exports = banner_plugin_default;
@@ -0,0 +1,6 @@
1
+ import { ESLint } from 'eslint';
2
+
3
+ type MessageIds = "missingBanner" | "incorrectComment" | "incorrectBanner" | "noNewlineAfterBanner";
4
+ declare const plugin: ESLint.Plugin;
5
+
6
+ export { type MessageIds, plugin as default };
@@ -1,9 +1,4 @@
1
- import {
2
- banner_plugin_default
3
- } from "../chunk-O5CGESKJ.js";
4
- import "../chunk-FXLMJ2Y5.js";
5
- import "../chunk-4CXNUMUG.js";
6
- import "../chunk-PWQ34SJ2.js";
7
- export {
8
- banner_plugin_default as default
9
- };
1
+ export { banner_plugin_default as default } from '../chunk-O5CGESKJ.js';
2
+ import '../chunk-FXLMJ2Y5.js';
3
+ import '../chunk-4CXNUMUG.js';
4
+ import '../chunk-PWQ34SJ2.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ // src/utils/combine.ts
4
+ async function combine(...configs) {
5
+ const resolved = await Promise.all(configs);
6
+ return resolved.flat();
7
+ }
8
+
9
+ exports.combine = combine;
@@ -0,0 +1,14 @@
1
+ import { Awaitable } from 'eslint-flat-config-utils';
2
+ import { TypedFlatConfigItem } from '../types.cjs';
3
+ import '@nx/eslint-plugin/src/utils/runtime-lint-utils';
4
+ import '@stylistic/eslint-plugin';
5
+ import '@typescript-eslint/parser';
6
+ import 'eslint';
7
+ import 'eslint-config-flat-gitignore';
8
+
9
+ /**
10
+ * Combine array and non-array configs into a single array.
11
+ */
12
+ declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]): Promise<TypedFlatConfigItem[]>;
13
+
14
+ export { combine };
@@ -1,6 +1,4 @@
1
- import {
2
- init_esm_shims
3
- } from "../chunk-PWQ34SJ2.js";
1
+ import { init_esm_shims } from '../chunk-PWQ34SJ2.js';
4
2
 
5
3
  // src/utils/combine.ts
6
4
  init_esm_shims();
@@ -8,6 +6,5 @@ async function combine(...configs) {
8
6
  const resolved = await Promise.all(configs);
9
7
  return resolved.flat();
10
8
  }
11
- export {
12
- combine
13
- };
9
+
10
+ export { combine };