@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.
Files changed (73) hide show
  1. package/README.md +1 -1
  2. package/dist/chunk-7NZUDX62.js +99 -0
  3. package/dist/{chunk-Y67QTC5U.js → chunk-K6KBWFPU.js} +1 -1
  4. package/dist/{chunk-LSG5T3ZK.js → chunk-W6QEP5VE.js} +7 -6
  5. package/dist/chunk-X3L37QNE.js +161 -0
  6. package/dist/preset.d.ts +23 -7048
  7. package/dist/preset.js +3590 -933
  8. package/dist/types-Drnq7vws.d.ts +14859 -0
  9. package/dist/utils/banner-plugin.js +3 -3
  10. package/dist/utils/combine.d.ts +14 -0
  11. package/dist/utils/combine.js +13 -0
  12. package/dist/utils/constants.d.ts +33 -22
  13. package/dist/utils/constants.js +65 -19
  14. package/dist/utils/get-file-banner.js +2 -2
  15. package/dist/utils/helpers.d.ts +55 -0
  16. package/dist/utils/helpers.js +19 -0
  17. package/dist/utils/index.d.ts +1 -1
  18. package/dist/utils/index.js +67 -21
  19. package/package.json +76 -50
  20. package/dist/chunk-723HQUNP.js +0 -14
  21. package/dist/chunk-ESFBJFNU.cjs +0 -149
  22. package/dist/chunk-GMT3V67N.cjs +0 -24
  23. package/dist/chunk-HMBBDY5L.cjs +0 -49
  24. package/dist/chunk-JS7W7LMD.cjs +0 -14
  25. package/dist/chunk-KISSHBCD.cjs +0 -1333
  26. package/dist/chunk-LFHG33FO.cjs +0 -313
  27. package/dist/chunk-QSFZU7HX.cjs +0 -47
  28. package/dist/chunk-RTM5LCEB.js +0 -149
  29. package/dist/chunk-USNT2KNT.cjs +0 -6
  30. package/dist/chunk-VIASOXKK.js +0 -1333
  31. package/dist/preset.cjs +0 -988
  32. package/dist/preset.d.cts +0 -7057
  33. package/dist/rules/import.cjs +0 -291
  34. package/dist/rules/import.d.cts +0 -5
  35. package/dist/rules/import.d.ts +0 -5
  36. package/dist/rules/import.js +0 -291
  37. package/dist/rules/jsx-a11y.cjs +0 -341
  38. package/dist/rules/jsx-a11y.d.cts +0 -5
  39. package/dist/rules/jsx-a11y.d.ts +0 -5
  40. package/dist/rules/jsx-a11y.js +0 -341
  41. package/dist/rules/react-hooks.cjs +0 -15
  42. package/dist/rules/react-hooks.d.cts +0 -5
  43. package/dist/rules/react-hooks.d.ts +0 -5
  44. package/dist/rules/react-hooks.js +0 -15
  45. package/dist/rules/react.cjs +0 -689
  46. package/dist/rules/react.d.cts +0 -5
  47. package/dist/rules/react.d.ts +0 -5
  48. package/dist/rules/react.js +0 -689
  49. package/dist/rules/storm.cjs +0 -7
  50. package/dist/rules/storm.d.cts +0 -11
  51. package/dist/rules/storm.d.ts +0 -11
  52. package/dist/rules/storm.js +0 -7
  53. package/dist/rules/ts-docs.cjs +0 -7
  54. package/dist/rules/ts-docs.d.cts +0 -5
  55. package/dist/rules/ts-docs.d.ts +0 -5
  56. package/dist/rules/ts-docs.js +0 -7
  57. package/dist/rules.d.ts +0 -7005
  58. package/dist/utils/banner-plugin.cjs +0 -9
  59. package/dist/utils/banner-plugin.d.cts +0 -6
  60. package/dist/utils/constants.cjs +0 -25
  61. package/dist/utils/constants.d.cts +0 -24
  62. package/dist/utils/create-flat-import-plugin.cjs +0 -20
  63. package/dist/utils/create-flat-import-plugin.d.cts +0 -11
  64. package/dist/utils/create-flat-import-plugin.d.ts +0 -11
  65. package/dist/utils/create-flat-import-plugin.js +0 -20
  66. package/dist/utils/format-config.cjs +0 -7
  67. package/dist/utils/format-config.d.cts +0 -5
  68. package/dist/utils/get-file-banner.cjs +0 -8
  69. package/dist/utils/get-file-banner.d.cts +0 -9
  70. package/dist/utils/ignores.cjs +0 -7
  71. package/dist/utils/ignores.d.cts +0 -3
  72. package/dist/utils/index.cjs +0 -33
  73. package/dist/utils/index.d.cts +0 -4
@@ -1,313 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
- var _chunkHMBBDY5Lcjs = require('./chunk-HMBBDY5L.cjs');
4
-
5
-
6
- var _chunkESFBJFNUcjs = require('./chunk-ESFBJFNU.cjs');
7
-
8
-
9
- var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
10
-
11
- // src/utils/banner-plugin.ts
12
- var _utils = require('@typescript-eslint/utils');
13
- var _os = require('os'); var _os2 = _interopRequireDefault(_os);
14
- function match(actual, expected) {
15
- if (expected.test) {
16
- return expected.test(actual);
17
- } else {
18
- return expected === actual;
19
- }
20
- }
21
- _chunkUSNT2KNTcjs.__name.call(void 0, match, "match");
22
- function excludeShebangs(comments) {
23
- return comments.filter(function(comment) {
24
- return comment.type !== "Shebang";
25
- });
26
- }
27
- _chunkUSNT2KNTcjs.__name.call(void 0, excludeShebangs, "excludeShebangs");
28
- function getLeadingComments(context, node) {
29
- const all = excludeShebangs(context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node));
30
- if (all[0].type.toLowerCase() === "block") {
31
- return [
32
- all[0]
33
- ];
34
- }
35
- let i = 1;
36
- for (i = 1; i < all.length; ++i) {
37
- const txt = context.getSourceCode().getText().slice(all[i - 1].range[1], all[i].range[0]);
38
- if (!txt.match(/^(\r\n|\r|\n)$/)) {
39
- break;
40
- }
41
- }
42
- return all.slice(0, i);
43
- }
44
- _chunkUSNT2KNTcjs.__name.call(void 0, getLeadingComments, "getLeadingComments");
45
- function genCommentBody(commentType, textArray, eol, numNewlines) {
46
- const eols = eol.repeat(numNewlines);
47
- if (commentType === "block") {
48
- return "/*" + textArray.join(eol) + "*/" + eols;
49
- } else {
50
- return "//" + textArray.join(eol + "//") + eols;
51
- }
52
- }
53
- _chunkUSNT2KNTcjs.__name.call(void 0, genCommentBody, "genCommentBody");
54
- function genCommentsRange(context, comments, eol) {
55
- const start = comments[0].range[0];
56
- let end = comments.slice(-1)[0].range[1];
57
- if (context.getSourceCode().text[end] === eol) {
58
- end += eol.length;
59
- }
60
- return [
61
- start,
62
- end
63
- ];
64
- }
65
- _chunkUSNT2KNTcjs.__name.call(void 0, genCommentsRange, "genCommentsRange");
66
- function genPrependFixer(commentType, node, bannerLines, eol, numNewlines) {
67
- return function(fixer) {
68
- return fixer.insertTextBefore(node, genCommentBody(commentType, bannerLines, eol, numNewlines));
69
- };
70
- }
71
- _chunkUSNT2KNTcjs.__name.call(void 0, genPrependFixer, "genPrependFixer");
72
- function genReplaceFixer(commentType, context, leadingComments, bannerLines, eol, numNewlines) {
73
- return function(fixer) {
74
- return fixer.replaceTextRange(genCommentsRange(context, leadingComments, eol), genCommentBody(commentType, bannerLines, eol, numNewlines));
75
- };
76
- }
77
- _chunkUSNT2KNTcjs.__name.call(void 0, genReplaceFixer, "genReplaceFixer");
78
- function getEOL(options) {
79
- if (options.lineEndings === "unix") {
80
- return "\n";
81
- }
82
- if (options.lineEndings === "windows") {
83
- return "\r\n";
84
- }
85
- return _os2.default.EOL;
86
- }
87
- _chunkUSNT2KNTcjs.__name.call(void 0, getEOL, "getEOL");
88
- function hasBanner(commentType, src) {
89
- if (src.startsWith("#!")) {
90
- const bannerLines = src.split(/\r?\n/);
91
- if (bannerLines && bannerLines.length > 1) {
92
- bannerLines.shift();
93
- while (bannerLines.length && bannerLines[0] && !bannerLines[0].replace(/\s+/, "")) {
94
- bannerLines.shift();
95
- }
96
- if (bannerLines.length) {
97
- src = bannerLines.join("\n");
98
- } else {
99
- return false;
100
- }
101
- }
102
- }
103
- return commentType === "block" && src.startsWith("/*") || commentType === "lint" && src.startsWith("//") || commentType !== "block" && commentType !== "lint" && commentType && src.startsWith(commentType);
104
- }
105
- _chunkUSNT2KNTcjs.__name.call(void 0, hasBanner, "hasBanner");
106
- function matchesLineEndings(src, num) {
107
- for (let j = 0; j < num; ++j) {
108
- const m = src.match(/^(\r\n|\r|\n)/);
109
- if (m) {
110
- src = src.slice(m.index + m[0].length);
111
- } else {
112
- return false;
113
- }
114
- }
115
- return true;
116
- }
117
- _chunkUSNT2KNTcjs.__name.call(void 0, matchesLineEndings, "matchesLineEndings");
118
- var bannerRule = _utils.ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/eslint/rules/banner`)({
119
- name: "banner",
120
- meta: {
121
- docs: {
122
- description: "Ensures the file has a Storm Software banner"
123
- },
124
- schema: [
125
- {
126
- type: "object",
127
- properties: {
128
- banner: {
129
- type: "string",
130
- 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"
131
- },
132
- repositoryName: {
133
- type: "string",
134
- description: "The name of the repository to use when reading the banner from a file."
135
- },
136
- commentType: {
137
- type: "string",
138
- description: "The comment token to use for the banner. Defaults to block ('/* <banner> */')"
139
- },
140
- numNewlines: {
141
- type: "number",
142
- description: "The number of newlines to use after the banner. Defaults to 2"
143
- }
144
- },
145
- additionalProperties: false
146
- }
147
- ],
148
- type: "layout",
149
- messages: {
150
- missingBanner: "Missing banner",
151
- incorrectComment: "Banner should use the {{commentType}} comment type",
152
- incorrectBanner: "Incorrect banner",
153
- noNewlineAfterBanner: "No newline after banner"
154
- },
155
- fixable: "whitespace"
156
- },
157
- defaultOptions: [
158
- {
159
- repositoryName: "",
160
- commentType: "block",
161
- numNewlines: 2
162
- }
163
- ],
164
- create(context, [{ banner, repositoryName = "", commentType = "block", numNewlines = 2 }]) {
165
- if (!banner) {
166
- banner = _chunkHMBBDY5Lcjs.getFileBanner.call(void 0, repositoryName);
167
- }
168
- const options = context.options;
169
- const eol = getEOL(options);
170
- const canFix = true;
171
- const bannerLines = banner.split(/\r?\n/);
172
- let fixLines = bannerLines;
173
- return {
174
- Program: /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, function(node) {
175
- if (!hasBanner(commentType, context.sourceCode.getText())) {
176
- context.report({
177
- loc: node.loc,
178
- messageId: "missingBanner",
179
- fix: genPrependFixer(commentType, node, fixLines, eol, numNewlines)
180
- });
181
- } else {
182
- const leadingComments = getLeadingComments(context, node);
183
- if (!leadingComments.length) {
184
- context.report({
185
- loc: node.loc,
186
- messageId: "missingBanner",
187
- fix: canFix ? genPrependFixer(commentType, node, fixLines, eol, numNewlines) : null
188
- });
189
- } else if (leadingComments[0].type.toLowerCase() !== commentType) {
190
- context.report({
191
- loc: node.loc,
192
- messageId: "incorrectComment",
193
- data: {
194
- commentType
195
- },
196
- fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
197
- });
198
- } else {
199
- if (commentType === "line") {
200
- if (leadingComments.length < bannerLines.length) {
201
- context.report({
202
- loc: node.loc,
203
- messageId: "missingBanner",
204
- fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
205
- });
206
- return;
207
- }
208
- for (let i = 0; i < bannerLines.length; i++) {
209
- if (!match(leadingComments[i].value, bannerLines[i])) {
210
- context.report({
211
- loc: node.loc,
212
- messageId: "incorrectBanner",
213
- fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
214
- });
215
- return;
216
- }
217
- }
218
- const postLineBanner = context.getSourceCode().text.substr(leadingComments[bannerLines.length - 1].range[1], (_nullishCoalesce(numNewlines, () => ( 1))) * 2);
219
- if (!matchesLineEndings(postLineBanner, numNewlines)) {
220
- context.report({
221
- loc: node.loc,
222
- messageId: "noNewlineAfterBanner",
223
- fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
224
- });
225
- }
226
- } else {
227
- let leadingLines = [
228
- leadingComments[0].value
229
- ];
230
- if (bannerLines.length > 1) {
231
- leadingLines = leadingComments[0].value.split(/\r?\n/);
232
- }
233
- let hasError = false;
234
- if (leadingLines.length > bannerLines.length) {
235
- hasError = true;
236
- }
237
- for (let i = 0; !hasError && i < bannerLines.length; i++) {
238
- if (!match(leadingLines[i], bannerLines[i])) {
239
- hasError = true;
240
- }
241
- }
242
- if (hasError) {
243
- if (canFix && bannerLines.length > 1) {
244
- fixLines = [
245
- fixLines.join(eol)
246
- ];
247
- }
248
- context.report({
249
- loc: node.loc,
250
- messageId: "incorrectBanner",
251
- fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
252
- });
253
- } else {
254
- const postBlockBanner = context.getSourceCode().text.substr(leadingComments[0].range[1], (_nullishCoalesce(numNewlines, () => ( 1))) * 2);
255
- if (!matchesLineEndings(postBlockBanner, numNewlines)) {
256
- context.report({
257
- loc: node.loc,
258
- messageId: "noNewlineAfterBanner",
259
- fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
260
- });
261
- }
262
- }
263
- }
264
- }
265
- }
266
- }, "Program")
267
- };
268
- }
269
- });
270
- var plugin = {
271
- meta: {
272
- name: "eslint-plugin-banner",
273
- version: "0.0.1"
274
- },
275
- configs: {},
276
- rules: {
277
- banner: bannerRule
278
- },
279
- processors: {}
280
- };
281
- plugin.configs && (plugin.configs.recommended = {
282
- name: "banner/recommended",
283
- plugins: {
284
- banner: plugin
285
- },
286
- files: [
287
- _chunkESFBJFNUcjs.CODE_FILE
288
- ],
289
- ignores: [
290
- "!**/docs/**/*",
291
- "!**/crates/**/*",
292
- "!**/tmp/**/*",
293
- "!**/dist/**/*",
294
- "!**/coverage/**/*",
295
- "!**/node_modules/**/*",
296
- "!**/.cache/**/*",
297
- "!**/.nx/**/*"
298
- ],
299
- rules: {
300
- "banner/banner": [
301
- "error",
302
- {
303
- commentType: "block",
304
- numNewlines: 2
305
- }
306
- ]
307
- }
308
- });
309
- var banner_plugin_default = plugin;
310
-
311
-
312
-
313
- exports.banner_plugin_default = banner_plugin_default;
@@ -1,47 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/ignores.ts
2
- var DEFAULT_IGNORES = [
3
- "**/.git/**",
4
- "**/node_modules/**",
5
- "**/src/generators/**/files/**/*",
6
- "**/dist/**",
7
- "**/tmp/**",
8
- "**/coverage/**",
9
- "**/bench/**",
10
- "**/__test__/**",
11
- "**/__mocks__/**",
12
- "**/__generated__/**",
13
- "**/.wrangler/**",
14
- "**/.docusaurus/**",
15
- "**/.tamagui/**",
16
- "**/tamagui.css",
17
- "**/.nx/**",
18
- "**/.next/**",
19
- "**/workbox*.js",
20
- "**/sw*.js",
21
- "**/service-worker.js",
22
- "**/fallback*.js",
23
- "**/ios/**",
24
- "**/.android/**",
25
- "**/.DS_Store/**",
26
- "**/Thumbs.db/**",
27
- "**/.cspellcache",
28
- "**/package-lock.*",
29
- "**/npm-lock.*",
30
- "**/pnpm-lock.*",
31
- "**/pnpm-lock.*",
32
- "**/bun.lockb",
33
- "**/cargo.lock",
34
- "**/next-env.d.ts",
35
- "**/CODEOWNERS",
36
- "**/yarn.lock",
37
- "**/jest.config.js",
38
- "**/jest.setup.js",
39
- "**/jest.config.ts",
40
- "**/jest.setup.ts",
41
- "**/jest.config.json",
42
- "**/jest.setup.json"
43
- ];
44
-
45
-
46
-
47
- exports.DEFAULT_IGNORES = DEFAULT_IGNORES;
@@ -1,149 +0,0 @@
1
- // src/utils/constants.ts
2
- var RESTRICTED_SYNTAX = [
3
- {
4
- // ❌ readFile(…, { encoding: … })
5
- selector: "CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]",
6
- message: "Specify encoding as last argument instead of object with encoding key"
7
- },
8
- {
9
- // ❌ readFile(…, {})
10
- selector: "CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]",
11
- message: "Specify encoding as last argument"
12
- },
13
- {
14
- // ❌ readFileSync(…).toString(…)
15
- selector: "CallExpression[callee.name=readFileSync][parent.property.name=toString]",
16
- message: "toString is redundant, specify encoding as last argument"
17
- },
18
- {
19
- // ❌ ….readFile(…, { encoding: … })
20
- selector: "CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]",
21
- message: "Specify encoding as last argument instead of object with encoding key"
22
- },
23
- {
24
- // ❌ ….readFile(…, {})
25
- selector: "CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]",
26
- message: "Specify encoding as last argument"
27
- },
28
- {
29
- // ❌ Boolean(…)
30
- selector: "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
31
- message: "Prefer `!!\u2026` over `Boolean(\u2026)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
32
- },
33
- {
34
- // ❌ process.browser
35
- selector: "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
36
- message: "`process.browser` is deprecated, use `!!globalThis.window`"
37
- }
38
- ];
39
- var REACT_RESTRICTED_SYNTAX = [
40
- ...RESTRICTED_SYNTAX,
41
- {
42
- // ❌ useMemo(…, [])
43
- selector: "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
44
- message: "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
45
- }
46
- ];
47
- var RESTRICTED_GLOBALS = [
48
- "stop",
49
- {
50
- name: "isNaN",
51
- message: "Use Number.isNaN instead"
52
- }
53
- ];
54
- var RESTRICTED_MODULES = [
55
- {
56
- name: "axios",
57
- message: "Use `fetch/node-fetch` instead."
58
- },
59
- {
60
- name: "moment",
61
- message: "Use `dayjs/date-fns` instead."
62
- },
63
- {
64
- name: "classnames",
65
- message: "Use `clsx` instead because it is faster."
66
- },
67
- {
68
- name: "lodash/isString.js",
69
- message: "Use `typeof yourVar === 'string'` instead."
70
- },
71
- {
72
- name: "lodash/isArray.js",
73
- message: "Use `Array.isArray` instead."
74
- },
75
- {
76
- name: "lodash/flatten.js",
77
- message: "Use `Array#flat()` instead."
78
- },
79
- {
80
- name: "lodash/compact.js",
81
- message: "Use `Array#filter(Boolean)` instead."
82
- },
83
- {
84
- name: "lodash/identity.js",
85
- message: "Use `(value) => value` instead."
86
- }
87
- ];
88
- var JS_FILES = [
89
- "*.js?(x)",
90
- "*.mjs"
91
- ];
92
- var CODE_BLOCK = "**/*.md{,x}/*";
93
- var CODE_FILE = "**/*.{,c,m}{j,t}s{,x}";
94
- var TS_FILE = "**/*.{,c,m}ts{,x}";
95
- var JS_FILE = "**/*.{,c}js{,x}";
96
- var ACRONYMS_LIST = [
97
- "API",
98
- "ASCII",
99
- "CPU",
100
- "CSS",
101
- "DNS",
102
- "EOF",
103
- "GUID",
104
- "HTML",
105
- "HTTP",
106
- "HTTPS",
107
- "ID",
108
- "IP",
109
- "JSON",
110
- "LHS",
111
- "OEM",
112
- "PP",
113
- "QA",
114
- "RAM",
115
- "RHS",
116
- "RPC",
117
- "RSS",
118
- "SLA",
119
- "SMTP",
120
- "SQL",
121
- "SSH",
122
- "SSL",
123
- "TCP",
124
- "TLS",
125
- "TTL",
126
- "UDP",
127
- "UI",
128
- "UID",
129
- "UUID",
130
- "URI",
131
- "URL",
132
- "UTF",
133
- "VM",
134
- "XML",
135
- "XSS"
136
- ];
137
-
138
- export {
139
- RESTRICTED_SYNTAX,
140
- REACT_RESTRICTED_SYNTAX,
141
- RESTRICTED_GLOBALS,
142
- RESTRICTED_MODULES,
143
- JS_FILES,
144
- CODE_BLOCK,
145
- CODE_FILE,
146
- TS_FILE,
147
- JS_FILE,
148
- ACRONYMS_LIST
149
- };
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
-
5
-
6
- exports.__name = __name;