@storm-software/eslint 0.115.7 → 0.115.9
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-GMT3V67N.cjs → chunk-3GC4AORY.cjs} +4 -2
- package/dist/{chunk-ESFBJFNU.cjs → chunk-3UUB46KX.cjs} +6 -1
- package/dist/{chunk-XMT3QM5B.js → chunk-4RD7EZGD.js} +4 -2
- package/dist/{chunk-JS7W7LMD.cjs → chunk-57YNYDOK.cjs} +6 -1
- package/dist/chunk-65NJ2BNV.js +49 -0
- package/dist/{chunk-RTM5LCEB.js → chunk-6ALJL7BB.js} +5 -0
- package/dist/{chunk-723HQUNP.js → chunk-72MKOVCL.js} +5 -0
- package/dist/{chunk-Y67QTC5U.js → chunk-AIXMWXO2.js} +5 -3
- package/dist/chunk-AZOSQYIH.js +12754 -0
- package/dist/{chunk-HMBBDY5L.cjs → chunk-EFMMB4QR.cjs} +6 -4
- package/dist/{chunk-JUT6UB4M.js → chunk-Q5PXQJ7M.js} +5 -0
- package/dist/chunk-SCFUDB74.cjs +49 -0
- package/dist/{chunk-LUH5W2Z6.cjs → chunk-U47F4DRS.cjs} +6 -1
- package/dist/{chunk-R5BQJYBX.cjs → chunk-U7UR7AIF.cjs} +4 -2
- package/dist/chunk-Y5VOHJ3P.cjs +12754 -0
- package/dist/{chunk-FTXILLLE.js → chunk-YXBOINV5.js} +4 -2
- package/dist/preset.cjs +77071 -164
- package/dist/preset.js +76959 -57
- package/dist/rules/import.cjs +4 -1
- package/dist/rules/import.js +4 -1
- package/dist/rules/jsx-a11y.cjs +4 -1
- package/dist/rules/jsx-a11y.js +4 -1
- package/dist/rules/react-hooks.cjs +4 -1
- package/dist/rules/react-hooks.js +4 -1
- package/dist/rules/react.cjs +4 -1
- package/dist/rules/react.js +4 -1
- 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 +4 -1
- package/dist/utils/create-flat-import-plugin.js +4 -1
- 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 +10 -5
- package/dist/utils/index.js +9 -4
- package/package.json +68 -21
- package/dist/chunk-LFHG33FO.cjs +0 -313
- package/dist/chunk-LSG5T3ZK.js +0 -313
- package/dist/chunk-SHUYVCID.js +0 -6
- package/dist/chunk-USNT2KNT.cjs +0 -6
package/dist/chunk-LFHG33FO.cjs
DELETED
|
@@ -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;
|
package/dist/chunk-LSG5T3ZK.js
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/chunk-SHUYVCID.js
DELETED
package/dist/chunk-USNT2KNT.cjs
DELETED