@storm-software/eslint 0.170.68 → 0.170.70

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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-Z2ZFJBUD.js → chunk-C74DAXLP.js} +0 -2
  3. package/dist/{chunk-WEPTDP5X.js → chunk-DMZFJCWX.js} +2 -5
  4. package/dist/{chunk-ZZRQVLBJ.js → chunk-RU7GXBCG.js} +0 -3
  5. package/dist/chunk-WBEFFLSU.js +13 -0
  6. package/dist/{chunk-EIPIQB5E.js → chunk-WYU7W4UW.js} +1 -4
  7. package/dist/preset.cjs +14708 -16062
  8. package/dist/preset.d.cts +1 -0
  9. package/dist/preset.d.ts +1 -0
  10. package/dist/preset.js +14549 -15253
  11. package/dist/types.d.cts +29 -31
  12. package/dist/types.d.ts +29 -31
  13. package/dist/types.js +1 -4
  14. package/dist/utils/combine.d.cts +1 -0
  15. package/dist/utils/combine.d.ts +1 -0
  16. package/dist/utils/combine.js +1 -2
  17. package/dist/utils/correct-paths.js +2 -2
  18. package/dist/utils/find-workspace-root.js +3 -3
  19. package/dist/utils/format-config.js +20 -2
  20. package/dist/utils/helpers.cjs +1 -1
  21. package/dist/utils/helpers.js +2 -2
  22. package/dist/utils/tsconfig-path.js +4 -4
  23. package/package.json +13 -12
  24. package/dist/chunk-2FWJ22PW.js +0 -349
  25. package/dist/chunk-LRVZTK6Y.js +0 -21
  26. package/dist/chunk-QO5ZXGIE.js +0 -46
  27. package/dist/chunk-UVAZFUOB.js +0 -62
  28. package/dist/chunk-WHUEAYCR.js +0 -236
  29. package/dist/utils/banner-plugin.cjs +0 -458
  30. package/dist/utils/banner-plugin.d.cts +0 -6
  31. package/dist/utils/banner-plugin.d.ts +0 -6
  32. package/dist/utils/banner-plugin.js +0 -4
  33. package/dist/utils/constants.cjs +0 -315
  34. package/dist/utils/constants.d.cts +0 -83
  35. package/dist/utils/constants.d.ts +0 -83
  36. package/dist/utils/constants.js +0 -2
  37. package/dist/utils/get-file-banner.cjs +0 -103
  38. package/dist/utils/get-file-banner.d.cts +0 -12
  39. package/dist/utils/get-file-banner.d.ts +0 -12
  40. package/dist/utils/get-file-banner.js +0 -3
  41. package/dist/utils/index.cjs +0 -333
  42. package/dist/utils/index.d.cts +0 -3
  43. package/dist/utils/index.d.ts +0 -3
  44. package/dist/utils/index.js +0 -6
@@ -1,236 +0,0 @@
1
- import { init_esm_shims } from './chunk-QO5ZXGIE.js';
2
-
3
- // src/utils/constants.ts
4
- init_esm_shims();
5
- var GLOB_CODE_BLOCK = "**/*.md{,x}/*";
6
- var GLOB_CODE_FILE = "**/*.{,c,m}{j,t}s{,x}";
7
- var ACRONYMS_LIST = [
8
- "API",
9
- "ASCII",
10
- "CPU",
11
- "CSS",
12
- "DNS",
13
- "EOF",
14
- "GUID",
15
- "HTML",
16
- "HTTP",
17
- "HTTPS",
18
- "ID",
19
- "IP",
20
- "JSON",
21
- "LHS",
22
- "OEM",
23
- "PP",
24
- "QA",
25
- "RAM",
26
- "RHS",
27
- "RPC",
28
- "RSS",
29
- "SLA",
30
- "SMTP",
31
- "SQL",
32
- "SSH",
33
- "SSL",
34
- "TCP",
35
- "TLS",
36
- "TTL",
37
- "UDP",
38
- "UI",
39
- "UID",
40
- "UUID",
41
- "URI",
42
- "URL",
43
- "UTF",
44
- "VM",
45
- "XML",
46
- "XSS"
47
- ];
48
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
49
- var GLOB_SRC_FILE = `*.${GLOB_SRC_EXT}`;
50
- var GLOB_SRC = `**/${GLOB_SRC_FILE}`;
51
- var GLOB_JS_EXT = "?([cm])js";
52
- var GLOB_JS_FILE = `*.${GLOB_JS_EXT}`;
53
- var GLOB_JS = `**/${GLOB_JS_FILE}`;
54
- var GLOB_JSX_EXT = "?([cm])jsx";
55
- var GLOB_JSX_FILE = `*.${GLOB_JSX_EXT}`;
56
- var GLOB_JSX = `**/${GLOB_JSX_FILE}`;
57
- var GLOB_TS_EXT = "?([cm])ts";
58
- var GLOB_TS_FILE = `*.${GLOB_TS_EXT}`;
59
- var GLOB_TS = `**/${GLOB_TS_FILE}`;
60
- var GLOB_TSX_EXT = "?([cm])tsx";
61
- var GLOB_TSX_FILE = `*.${GLOB_TSX_EXT}`;
62
- var GLOB_TSX = `**/${GLOB_TSX_FILE}`;
63
- var GLOB_STYLE_EXT = "{c,le,sc}ss";
64
- var GLOB_STYLE_FILE = `*.${GLOB_STYLE_EXT}`;
65
- var GLOB_STYLE = `**/${GLOB_STYLE_FILE}`;
66
- var GLOB_CSS_EXT = "css";
67
- var GLOB_CSS_FILE = `*.${GLOB_CSS_EXT}`;
68
- var GLOB_CSS = `**/${GLOB_CSS_FILE}`;
69
- var GLOB_POSTCSS_EXT = "{p,post}css";
70
- var GLOB_POSTCSS_FILE = `*.${GLOB_POSTCSS_EXT}`;
71
- var GLOB_POSTCSS = `**/${GLOB_POSTCSS_FILE}`;
72
- var GLOB_LESS_EXT = "less";
73
- var GLOB_LESS_FILE = `*.${GLOB_LESS_EXT}`;
74
- var GLOB_LESS = `**/${GLOB_LESS_FILE}`;
75
- var GLOB_SCSS_EXT = "scss";
76
- var GLOB_SCSS_FILE = `*.${GLOB_SCSS_EXT}`;
77
- var GLOB_SCSS = `**/${GLOB_SCSS_FILE}`;
78
- var GLOB_JSON_EXT = "json";
79
- var GLOB_JSON_FILE = `*.${GLOB_JSON_EXT}`;
80
- var GLOB_JSON = `**/${GLOB_JSON_FILE}`;
81
- var GLOB_JSON5_EXT = "json5";
82
- var GLOB_JSON5_FILE = `*.${GLOB_JSON5_EXT}`;
83
- var GLOB_JSON5 = `**/${GLOB_JSON5_FILE}`;
84
- var GLOB_JSONC_EXT = "jsonc";
85
- var GLOB_JSONC_FILE = `*.${GLOB_JSONC_EXT}`;
86
- var GLOB_JSONC = `**/${GLOB_JSONC_FILE}`;
87
- var GLOB_MARKDOWN_EXT = "md";
88
- var GLOB_MARKDOWN_FILE = `*.${GLOB_MARKDOWN_EXT}`;
89
- var GLOB_MARKDOWN = `**/${GLOB_MARKDOWN_FILE}`;
90
- var GLOB_MDX_EXT = "mdx";
91
- var GLOB_MDX_FILE = `*.${GLOB_MDX_EXT}`;
92
- var GLOB_MDX = `**/${GLOB_MDX_FILE}`;
93
- var GLOB_MARKDOWN_IN_MARKDOWN = `${GLOB_MARKDOWN}/${GLOB_MARKDOWN_FILE}`;
94
- var GLOB_SVELTE_EXT = "svelte";
95
- var GLOB_SVELTE_FILE = `*.${GLOB_SVELTE_EXT}`;
96
- var GLOB_SVELTE = `**/${GLOB_SVELTE_FILE}`;
97
- var GLOB_VUE_EXT = "vue";
98
- var GLOB_VUE_FILE = `*.${GLOB_VUE_EXT}`;
99
- var GLOB_VUE = `**/${GLOB_VUE_FILE}`;
100
- var GLOB_YAML_EXT = "y?(a)ml";
101
- var GLOB_YAML_FILE = `*.${GLOB_YAML_EXT}`;
102
- var GLOB_YAML = `**/${GLOB_YAML_FILE}`;
103
- var GLOB_TOML_EXT = "toml";
104
- var GLOB_TOML_FILE = `*.${GLOB_TOML_EXT}`;
105
- var GLOB_TOML = `**/${GLOB_TOML_FILE}`;
106
- var GLOB_XML_EXT = "xml";
107
- var GLOB_XML_FILE = `*.${GLOB_XML_EXT}`;
108
- var GLOB_XML = `**/${GLOB_XML_FILE}`;
109
- var GLOB_SVG_EXT = "svg";
110
- var GLOB_SVG_FILE = `*.${GLOB_SVG_EXT}`;
111
- var GLOB_SVG = `**/${GLOB_SVG_FILE}`;
112
- var GLOB_HTML_EXT = "htm?(l)";
113
- var GLOB_HTML_FILE = `*.${GLOB_HTML_EXT}`;
114
- var GLOB_HTML = `**/${GLOB_HTML_FILE}`;
115
- var GLOB_ASTRO_EXT = "astro";
116
- var GLOB_ASTRO_FILE = `*.${GLOB_ASTRO_EXT}`;
117
- var GLOB_ASTRO = `**/${GLOB_ASTRO_FILE}`;
118
- var GLOB_ASTRO_TS = `${GLOB_ASTRO}/*.ts`;
119
- var GLOB_GRAPHQL_EXT = "{g,graph}ql";
120
- var GLOB_GRAPHQL_FILE = `*.${GLOB_GRAPHQL_EXT}`;
121
- var GLOB_GRAPHQL = `**/${GLOB_GRAPHQL_FILE}`;
122
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
123
- var GLOB_TESTS = [
124
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
125
- `**/*.spec.${GLOB_SRC_EXT}`,
126
- `**/*.test.${GLOB_SRC_EXT}`,
127
- `**/*.bench.${GLOB_SRC_EXT}`,
128
- `**/*.benchmark.${GLOB_SRC_EXT}`
129
- ];
130
- var GLOB_ALL_SRC = [
131
- GLOB_SRC,
132
- GLOB_STYLE,
133
- GLOB_JSON,
134
- GLOB_JSON5,
135
- GLOB_MARKDOWN,
136
- GLOB_MDX,
137
- GLOB_SVELTE,
138
- GLOB_VUE,
139
- GLOB_YAML,
140
- GLOB_XML,
141
- GLOB_HTML
142
- ];
143
- var GLOB_EXCLUDE = [
144
- "**/.git",
145
- "**/node_modules",
146
- "**/dist",
147
- "**/tmp",
148
- "**/coverage",
149
- "**/bench",
150
- "**/__snapshots__",
151
- "**/__test__",
152
- "**/__mocks__",
153
- "**/__generated__",
154
- "**/.wrangler",
155
- "**/.rolldown",
156
- "**/.docusaurus",
157
- "**/.tamagui",
158
- "**/tamagui.css",
159
- "**/.nx",
160
- "**/.next",
161
- "**/.storm",
162
- "**/.powerlines",
163
- "**/.shell-shock",
164
- "**/.earthquake",
165
- "**/.aftershock",
166
- "**/workbox*.js",
167
- "**/sw*.js",
168
- "**/service-worker.js",
169
- "**/fallback*.js",
170
- "**/ios",
171
- "**/.android",
172
- "**/.DS_Store",
173
- "**/Thumbs.db",
174
- "**/.cspellcache",
175
- "**/package-lock.*",
176
- "**/npm-lock.*",
177
- "**/pnpm-lock.*",
178
- "**/bun.lockb",
179
- "**/cargo.lock",
180
- "**/next-env.d.ts",
181
- "**/CODEOWNERS",
182
- "**/yarn.lock",
183
- "**/jest.preset.{js,ts,cjs,cts,mjs,mts,json}",
184
- "**/vitest.preset.{js,ts,cjs,cts,mjs,mts,json}",
185
- "**/jest.config.{js,ts,cjs,cts,mjs,mts,json}",
186
- "**/vitest.config.{js,ts,cjs,cts,mjs,mts,json}",
187
- "**/vitest.workspace.{js,ts,cjs,cts,mjs,mts,json}",
188
- "**/*.spec.{ts,tsx}",
189
- "**/*.test.{ts,tsx}",
190
- "**/output",
191
- "**/temp",
192
- "**/.temp",
193
- "**/.history",
194
- "**/.vitepress/cache",
195
- "**/.nuxt",
196
- "**/.svelte-kit",
197
- "**/.vercel",
198
- "**/.changeset",
199
- "**/.idea",
200
- "**/.cache",
201
- "**/.vite-inspect",
202
- "**/.yarn",
203
- "**/*.min.*",
204
- "**/CHANGELOG*.md",
205
- "**/CONTRIBUTING.md",
206
- "**/SECURITY.md",
207
- "**/CODE_OF_CONDUCT.md",
208
- "**/PULL_REQUEST_TEMPLATE.md",
209
- "**/LICENSE*",
210
- "**/auto-import?(s).d.ts",
211
- "**/components.d.ts",
212
- "**/vite.config.*.timestamp-*",
213
- "**/webpack.config.*.timestamp-*",
214
- "**/rollup.config.*.timestamp-*",
215
- "**/nx/**/schema.d.ts",
216
- "**/nx/**/schema.json",
217
- "**/nx/**/schema.md",
218
- "**/nx/**/*.schema.d.ts",
219
- "**/nx/**/*.schema.json",
220
- "**/nx/**/*.schema.md",
221
- "**/nx/**/generators/**/files",
222
- ".agents/**/*",
223
- "**/.agents/**/*",
224
- ".claude/**/*",
225
- "**/.claude/**/*",
226
- ".codex/**/*",
227
- "**/.codex/**/*",
228
- ".cursor/**/*",
229
- "**/.cursor/**/*",
230
- ".opencode/**/*",
231
- "**/.opencode/**/*",
232
- ".nx/**/*",
233
- "**/.nx/**/*"
234
- ];
235
-
236
- export { ACRONYMS_LIST, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_EXT, GLOB_ASTRO_FILE, GLOB_ASTRO_TS, GLOB_CODE_BLOCK, GLOB_CODE_FILE, GLOB_CSS, GLOB_CSS_EXT, GLOB_CSS_FILE, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_GRAPHQL_EXT, GLOB_GRAPHQL_FILE, GLOB_HTML, GLOB_HTML_EXT, GLOB_HTML_FILE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSON5_EXT, GLOB_JSON5_FILE, GLOB_JSONC, GLOB_JSONC_EXT, GLOB_JSONC_FILE, GLOB_JSON_EXT, GLOB_JSON_FILE, GLOB_JSX, GLOB_JSX_EXT, GLOB_JSX_FILE, GLOB_JS_EXT, GLOB_JS_FILE, GLOB_LESS, GLOB_LESS_EXT, GLOB_LESS_FILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_EXT, GLOB_MARKDOWN_FILE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_MDX, GLOB_MDX_EXT, GLOB_MDX_FILE, GLOB_POSTCSS, GLOB_POSTCSS_EXT, GLOB_POSTCSS_FILE, GLOB_SCSS, GLOB_SCSS_EXT, GLOB_SCSS_FILE, GLOB_SRC, GLOB_SRC_EXT, GLOB_SRC_FILE, GLOB_STYLE, GLOB_STYLE_EXT, GLOB_STYLE_FILE, GLOB_SVELTE, GLOB_SVELTE_EXT, GLOB_SVELTE_FILE, GLOB_SVG, GLOB_SVG_EXT, GLOB_SVG_FILE, GLOB_TESTS, GLOB_TOML, GLOB_TOML_EXT, GLOB_TOML_FILE, GLOB_TS, GLOB_TSX, GLOB_TSX_EXT, GLOB_TSX_FILE, GLOB_TS_EXT, GLOB_TS_FILE, GLOB_VUE, GLOB_VUE_EXT, GLOB_VUE_FILE, GLOB_XML, GLOB_XML_EXT, GLOB_XML_FILE, GLOB_YAML, GLOB_YAML_EXT, GLOB_YAML_FILE };
@@ -1,458 +0,0 @@
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_EXT = "?([cm])[jt]s?(x)";
55
- var GLOB_SRC_FILE = `*.${GLOB_SRC_EXT}`;
56
- var GLOB_SRC = `**/${GLOB_SRC_FILE}`;
57
-
58
- // src/utils/get-file-banner.ts
59
- var getFileBanner = (name = "", workspaceConfig) => {
60
- if (!name) {
61
- name = process.env.STORM_NAME || "";
62
- }
63
- let padding = " ";
64
- for (let i = 0; i < name.length + 2 && padding.length > 4; i++) {
65
- padding = padding.slice(0, -1);
66
- }
67
- let titleName = name || workspaceConfig?.name;
68
- if (titleName) {
69
- if (titleName?.startsWith("@")) {
70
- titleName = titleName.slice(1);
71
- }
72
- titleName = (titleName.charAt(0).toUpperCase() + titleName.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
73
- if (ACRONYMS_LIST.includes(word.toUpperCase())) {
74
- return word.toUpperCase();
75
- }
76
- return word.charAt(0).toUpperCase() + word.slice(1);
77
- }).join(" ");
78
- }
79
- const license = (process.env.STORM_LICENSE || workspaceConfig?.license || "Apache-2.0").split(" ").filter((word) => word && word.toLowerCase() !== "license").join(" ");
80
- const organization = process.env.STORM_ORG_NAME || process.env.STORM_ORGANIZATION_NAME || process.env.STORM_ORG || process.env.STORM_ORGANIZATION || (void 0) || "storm-software";
81
- return ` -------------------------------------------------------------------
82
-
83
- ${padding}\u26A1 ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
84
- if (ACRONYMS_LIST.includes(word.toUpperCase())) {
85
- return word.toUpperCase();
86
- }
87
- return word.charAt(0).toUpperCase() + word.slice(1);
88
- }).join(" ")} ${titleName ? `- ${titleName}` : ""}
89
-
90
- 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) => {
91
- if (ACRONYMS_LIST.includes(word.toUpperCase())) {
92
- return word.toUpperCase();
93
- }
94
- return word.charAt(0).toUpperCase() + word.slice(1);
95
- }).join(" ")}`} project. ${titleName ? titleName : "The project"}
96
- is maintained by ${(organization.charAt(0).toUpperCase() + organization.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
97
- if (ACRONYMS_LIST.includes(word.toUpperCase())) {
98
- return word.toUpperCase();
99
- }
100
- return word.charAt(0).toUpperCase() + word.slice(1);
101
- }).join(" ")} under the ${license} license, and is
102
- free for commercial and private use. For more information, please visit
103
- our licensing page at ${process.env.STORM_LICENSING?.replace(/\/$/, "") || workspaceConfig?.licensing?.replace(/\/$/, "") || "https://stormsoftware.com/licenses"}/${name ? `projects/${name}` : ""}.
104
-
105
- Website: ${process.env.STORM_HOMEPAGE || workspaceConfig?.homepage || "https://stormsoftware.com"}
106
- Repository: ${process.env.STORM_REPOSITORY || workspaceConfig?.repository || `https://github.com/${organization}${name ? `/${name}` : ""}`}
107
- Documentation: ${process.env.STORM_DOCS || workspaceConfig?.docs || `https://docs.stormsoftware.com${name ? `/projects/${name}` : ""}`}
108
- 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
109
-
110
- SPDX-License-Identifier: ${license}
111
-
112
- ------------------------------------------------------------------- `;
113
- };
114
-
115
- // src/utils/banner-plugin.ts
116
- function match(actual, expected) {
117
- if (expected.test) {
118
- return expected.test(actual);
119
- } else {
120
- return expected === actual;
121
- }
122
- }
123
- function excludeShebangs(comments) {
124
- return comments.filter((comment) => {
125
- return comment.type !== "Shebang";
126
- });
127
- }
128
- function getLeadingComments(context, node) {
129
- const all = excludeShebangs(
130
- context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node)
131
- );
132
- if (all[0].type.toLowerCase() === "block") {
133
- return [all[0]];
134
- }
135
- let i = 1;
136
- for (i = 1; i < all.length; ++i) {
137
- const txt = context.getSourceCode().getText().slice(all[i - 1].range[1], all[i].range[0]);
138
- if (!txt.match(/^(\r\n|\r|\n)$/)) {
139
- break;
140
- }
141
- }
142
- return all.slice(0, i);
143
- }
144
- function genCommentBody(commentType, textArray, eol, numNewlines) {
145
- const eols = eol.repeat(numNewlines);
146
- if (commentType === "block") {
147
- return "/*" + textArray.join(eol) + "*/" + eols;
148
- } else {
149
- return "//" + textArray.join(eol + "//") + eols;
150
- }
151
- }
152
- function genCommentsRange(context, comments, eol) {
153
- const start = comments[0].range[0];
154
- let end = comments.slice(-1)[0].range[1];
155
- if (context.getSourceCode().text[end] === eol) {
156
- end += eol.length;
157
- }
158
- return [start, end];
159
- }
160
- function genPrependFixer(commentType, node, bannerLines, eol, numNewlines) {
161
- return function(fixer) {
162
- return fixer.insertTextBefore(
163
- node,
164
- genCommentBody(commentType, bannerLines, eol, numNewlines)
165
- );
166
- };
167
- }
168
- function genReplaceFixer(commentType, context, leadingComments, bannerLines, eol, numNewlines) {
169
- return function(fixer) {
170
- return fixer.replaceTextRange(
171
- genCommentsRange(context, leadingComments, eol),
172
- genCommentBody(commentType, bannerLines, eol, numNewlines)
173
- );
174
- };
175
- }
176
- function getEOL(options) {
177
- if (options.lineEndings === "unix") {
178
- return "\n";
179
- }
180
- if (options.lineEndings === "windows") {
181
- return "\r\n";
182
- }
183
- return os__default.default.EOL;
184
- }
185
- function hasBanner(commentType = "block", src, eol) {
186
- if (src.startsWith("#!")) {
187
- const bannerLines = src.split(eol);
188
- if (bannerLines && bannerLines.length > 1) {
189
- bannerLines.shift();
190
- while (bannerLines.length && bannerLines[0] && !bannerLines[0].trim()) {
191
- bannerLines.shift();
192
- }
193
- if (bannerLines.length) {
194
- src = bannerLines.join(eol);
195
- } else {
196
- return false;
197
- }
198
- }
199
- }
200
- return commentType === "block" && src.startsWith("/*") || commentType === "line" && src.startsWith("//") || commentType !== "block" && commentType !== "line" && commentType && src.startsWith(commentType);
201
- }
202
- function matchesLineEndings(src, num) {
203
- for (let j = 0; j < num; ++j) {
204
- const m = src.match(/^(\r\n|\r|\n)/);
205
- if (m) {
206
- src = src.slice(m.index + m[0].length);
207
- } else {
208
- return false;
209
- }
210
- }
211
- return true;
212
- }
213
- var bannerRule = utils.ESLintUtils.RuleCreator(
214
- () => `https://developer.stormsoftware.com/eslint/rules/banner`
215
- )({
216
- name: "banner",
217
- meta: {
218
- docs: {
219
- description: "Ensures the file has a organization specific banner at the top of source code files"
220
- },
221
- schema: [
222
- {
223
- type: "object",
224
- properties: {
225
- banner: {
226
- type: "string",
227
- 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"
228
- },
229
- name: {
230
- type: "string",
231
- description: "The name of the repository to use when reading the banner from a file."
232
- },
233
- commentType: {
234
- type: "string",
235
- description: "The comment token to use for the banner. Defaults to block ('/* <banner> */')"
236
- },
237
- numNewlines: {
238
- type: "number",
239
- description: "The number of newlines to use after the banner. Defaults to 1"
240
- },
241
- lineEndings: {
242
- type: "string",
243
- enum: ["unix", "windows"],
244
- description: "The type of line endings to use. Defaults to the system default"
245
- }
246
- },
247
- additionalProperties: false
248
- }
249
- ],
250
- type: "layout",
251
- messages: {
252
- missingBanner: "Missing banner",
253
- incorrectComment: "Banner should use the {{commentType}} comment type",
254
- incorrectBanner: "Incorrect banner",
255
- noNewlineAfterBanner: "No newline after banner"
256
- },
257
- fixable: "whitespace"
258
- },
259
- defaultOptions: [
260
- {
261
- name: "",
262
- commentType: "block",
263
- numNewlines: 2,
264
- lineEndings: "unix"
265
- }
266
- ],
267
- create(context, [
268
- {
269
- banner,
270
- name = "",
271
- commentType = "block",
272
- numNewlines = 2,
273
- lineEndings = "unix"
274
- }
275
- ]) {
276
- if (!banner) {
277
- banner = getFileBanner(name);
278
- }
279
- const options = context.options;
280
- const eol = getEOL({ lineEndings, ...options });
281
- const bannerLines = banner.split(/\r?\n/);
282
- let fixLines = bannerLines;
283
- return {
284
- Program: function(node) {
285
- if (!hasBanner(commentType, context.sourceCode.getText(), eol)) {
286
- context.report({
287
- loc: node.loc,
288
- messageId: "missingBanner",
289
- fix: genPrependFixer(commentType, node, fixLines, eol, numNewlines)
290
- });
291
- } else {
292
- const leadingComments = getLeadingComments(context, node);
293
- if (!leadingComments.length) {
294
- context.report({
295
- loc: node.loc,
296
- messageId: "missingBanner",
297
- fix: genPrependFixer(commentType, node, fixLines, eol, numNewlines)
298
- });
299
- } else if (leadingComments[0].type.toLowerCase() !== commentType) {
300
- context.report({
301
- loc: node.loc,
302
- messageId: "incorrectComment",
303
- data: {
304
- commentType
305
- },
306
- fix: genReplaceFixer(
307
- commentType,
308
- context,
309
- leadingComments,
310
- fixLines,
311
- eol,
312
- numNewlines
313
- )
314
- });
315
- } else {
316
- if (commentType === "line") {
317
- if (leadingComments.length < bannerLines.length) {
318
- context.report({
319
- loc: node.loc,
320
- messageId: "missingBanner",
321
- fix: genReplaceFixer(
322
- commentType,
323
- context,
324
- leadingComments,
325
- fixLines,
326
- eol,
327
- numNewlines
328
- )
329
- });
330
- return;
331
- }
332
- for (let i = 0; i < bannerLines.length; i++) {
333
- if (!match(leadingComments[i].value, bannerLines[i])) {
334
- context.report({
335
- loc: node.loc,
336
- messageId: "incorrectBanner",
337
- fix: genReplaceFixer(
338
- commentType,
339
- context,
340
- leadingComments,
341
- fixLines,
342
- eol,
343
- numNewlines
344
- )
345
- });
346
- return;
347
- }
348
- }
349
- const postLineBanner = context.getSourceCode().text.substr(
350
- leadingComments[bannerLines.length - 1].range[1],
351
- (numNewlines ?? 1) * 2
352
- );
353
- if (!matchesLineEndings(postLineBanner, numNewlines)) {
354
- context.report({
355
- loc: node.loc,
356
- messageId: "noNewlineAfterBanner",
357
- fix: genReplaceFixer(
358
- commentType,
359
- context,
360
- leadingComments,
361
- fixLines,
362
- eol,
363
- numNewlines
364
- )
365
- });
366
- }
367
- } else {
368
- let leadingLines = [leadingComments[0].value];
369
- if (bannerLines.length > 1) {
370
- leadingLines = leadingComments[0].value.split(/\r?\n/);
371
- }
372
- let hasError = false;
373
- if (leadingLines.length > bannerLines.length) {
374
- hasError = true;
375
- }
376
- for (let i = 0; !hasError && i < bannerLines.length; i++) {
377
- if (!match(leadingLines[i], bannerLines[i])) {
378
- hasError = true;
379
- }
380
- }
381
- if (hasError) {
382
- if (bannerLines.length > 1) {
383
- fixLines = [fixLines.join(eol)];
384
- }
385
- context.report({
386
- loc: node.loc,
387
- messageId: "incorrectBanner",
388
- fix: genReplaceFixer(
389
- commentType,
390
- context,
391
- leadingComments,
392
- fixLines,
393
- eol,
394
- numNewlines
395
- )
396
- });
397
- } else {
398
- const postBlockBanner = context.getSourceCode().text.substr(
399
- leadingComments[0].range[1],
400
- (numNewlines ?? 1) * 2
401
- );
402
- if (!matchesLineEndings(postBlockBanner, numNewlines)) {
403
- context.report({
404
- loc: node.loc,
405
- messageId: "noNewlineAfterBanner",
406
- fix: genReplaceFixer(
407
- commentType,
408
- context,
409
- leadingComments,
410
- fixLines,
411
- eol,
412
- numNewlines
413
- )
414
- });
415
- }
416
- }
417
- }
418
- }
419
- }
420
- }
421
- };
422
- }
423
- });
424
- var plugin = {
425
- meta: {
426
- name: "eslint-plugin-banner",
427
- version: "0.0.1"
428
- },
429
- configs: {},
430
- rules: {
431
- banner: bannerRule
432
- },
433
- processors: {}
434
- };
435
- plugin.configs && (plugin.configs.recommended = {
436
- name: "banner/recommended",
437
- plugins: { banner: plugin },
438
- files: [GLOB_SRC],
439
- ignores: [
440
- "!**/docs/**/*",
441
- "!**/crates/**/*",
442
- "!**/tmp/**/*",
443
- "!**/dist/**/*",
444
- "!**/coverage/**/*",
445
- "!**/node_modules/**/*",
446
- "!**/.cache/**/*",
447
- "!**/.nx/**/*",
448
- "!**/.storm/**/*"
449
- ],
450
- rules: {
451
- "banner/banner": ["error", { commentType: "block", numNewlines: 2 }]
452
- }
453
- });
454
- var banner_plugin_default = plugin;
455
-
456
- module.exports = banner_plugin_default;
457
-
458
- module.exports = exports.default;
@@ -1,6 +0,0 @@
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 };