@storm-software/eslint 0.115.9 → 0.116.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.
- package/README.md +1 -1
- package/dist/{chunk-72MKOVCL.js → chunk-723HQUNP.js} +0 -5
- package/dist/{chunk-3UUB46KX.cjs → chunk-ESFBJFNU.cjs} +1 -6
- package/dist/{chunk-YXBOINV5.js → chunk-FTXILLLE.js} +2 -4
- package/dist/{chunk-3GC4AORY.cjs → chunk-GMT3V67N.cjs} +2 -4
- package/dist/{chunk-EFMMB4QR.cjs → chunk-HMBBDY5L.cjs} +4 -6
- package/dist/{chunk-57YNYDOK.cjs → chunk-JS7W7LMD.cjs} +1 -6
- package/dist/{chunk-Q5PXQJ7M.js → chunk-JUT6UB4M.js} +0 -5
- package/dist/chunk-LFHG33FO.cjs +313 -0
- package/dist/chunk-LSG5T3ZK.js +313 -0
- package/dist/{chunk-U47F4DRS.cjs → chunk-LUH5W2Z6.cjs} +1 -6
- package/dist/{chunk-U7UR7AIF.cjs → chunk-R5BQJYBX.cjs} +2 -4
- package/dist/{chunk-6ALJL7BB.js → chunk-RTM5LCEB.js} +0 -5
- package/dist/chunk-SHUYVCID.js +6 -0
- package/dist/chunk-USNT2KNT.cjs +6 -0
- package/dist/{chunk-4RD7EZGD.js → chunk-XMT3QM5B.js} +2 -4
- package/dist/{chunk-AIXMWXO2.js → chunk-Y67QTC5U.js} +3 -5
- package/dist/preset.cjs +165 -77072
- package/dist/preset.js +58 -76960
- package/dist/rules/import.cjs +1 -4
- package/dist/rules/import.js +1 -4
- package/dist/rules/jsx-a11y.cjs +1 -4
- package/dist/rules/jsx-a11y.js +1 -4
- package/dist/rules/react-hooks.cjs +1 -4
- package/dist/rules/react-hooks.js +1 -4
- package/dist/rules/react.cjs +1 -4
- package/dist/rules/react.js +1 -4
- package/dist/rules/storm.cjs +3 -3
- package/dist/rules/storm.js +2 -2
- package/dist/rules/ts-docs.cjs +3 -3
- package/dist/rules/ts-docs.js +2 -2
- package/dist/utils/banner-plugin.cjs +5 -5
- package/dist/utils/banner-plugin.js +4 -4
- package/dist/utils/constants.cjs +3 -3
- package/dist/utils/constants.js +2 -2
- package/dist/utils/create-flat-import-plugin.cjs +1 -4
- package/dist/utils/create-flat-import-plugin.js +1 -4
- package/dist/utils/format-config.cjs +3 -3
- package/dist/utils/format-config.js +2 -2
- package/dist/utils/get-file-banner.cjs +4 -4
- package/dist/utils/get-file-banner.js +3 -3
- package/dist/utils/ignores.cjs +3 -3
- package/dist/utils/ignores.js +2 -2
- package/dist/utils/index.cjs +5 -10
- package/dist/utils/index.js +4 -9
- package/package.json +24 -63
- package/dist/chunk-65NJ2BNV.js +0 -49
- package/dist/chunk-AZOSQYIH.js +0 -12754
- package/dist/chunk-SCFUDB74.cjs +0 -49
- package/dist/chunk-Y5VOHJ3P.cjs +0 -12754
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileBanner
|
|
3
|
+
} from "./chunk-Y67QTC5U.js";
|
|
4
|
+
import {
|
|
5
|
+
CODE_FILE
|
|
6
|
+
} from "./chunk-RTM5LCEB.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/utils/banner-plugin.ts
|
|
12
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
13
|
+
import os from "node:os";
|
|
14
|
+
function match(actual, expected) {
|
|
15
|
+
if (expected.test) {
|
|
16
|
+
return expected.test(actual);
|
|
17
|
+
} else {
|
|
18
|
+
return expected === actual;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
__name(match, "match");
|
|
22
|
+
function excludeShebangs(comments) {
|
|
23
|
+
return comments.filter(function(comment) {
|
|
24
|
+
return comment.type !== "Shebang";
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
__name(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
|
+
__name(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
|
+
__name(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
|
+
__name(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
|
+
__name(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
|
+
__name(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 os.EOL;
|
|
86
|
+
}
|
|
87
|
+
__name(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
|
+
__name(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
|
+
__name(matchesLineEndings, "matchesLineEndings");
|
|
118
|
+
var bannerRule = 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 = getFileBanner(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__ */ __name(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], (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], (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
|
+
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
|
+
export {
|
|
312
|
+
banner_plugin_default
|
|
313
|
+
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
|
|
3
|
-
var _chunkSCFUDB74cjs = require('./chunk-SCFUDB74.cjs');
|
|
4
|
-
|
|
5
|
-
// src/utils/ignores.ts
|
|
6
|
-
_chunkSCFUDB74cjs.init_cjs_shims.call(void 0, );
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/ignores.ts
|
|
7
2
|
var DEFAULT_IGNORES = [
|
|
8
3
|
"**/.git/**",
|
|
9
4
|
"**/node_modules/**",
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var _chunkSCFUDB74cjs = require('./chunk-SCFUDB74.cjs');
|
|
3
|
+
var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
|
|
5
4
|
|
|
6
5
|
// src/rules/storm.ts
|
|
7
|
-
|
|
8
|
-
var getStormRulesConfig = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (options) => {
|
|
6
|
+
var getStormRulesConfig = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (options) => {
|
|
9
7
|
let rules = {
|
|
10
8
|
/*************************************************************
|
|
11
9
|
*
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__name
|
|
3
|
-
|
|
4
|
-
} from "./chunk-65NJ2BNV.js";
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-SHUYVCID.js";
|
|
5
4
|
|
|
6
5
|
// src/rules/storm.ts
|
|
7
|
-
init_esm_shims();
|
|
8
6
|
var getStormRulesConfig = /* @__PURE__ */ __name((options) => {
|
|
9
7
|
let rules = {
|
|
10
8
|
/*************************************************************
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ACRONYMS_LIST
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RTM5LCEB.js";
|
|
4
4
|
import {
|
|
5
|
-
__name
|
|
6
|
-
|
|
7
|
-
} from "./chunk-65NJ2BNV.js";
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-SHUYVCID.js";
|
|
8
7
|
|
|
9
8
|
// src/utils/get-file-banner.ts
|
|
10
|
-
init_esm_shims();
|
|
11
9
|
var getFileBanner = /* @__PURE__ */ __name((name = "") => {
|
|
12
10
|
if (!name) {
|
|
13
11
|
name = process.env.STORM_NAMESPACE || "";
|