@storm-software/eslint 0.31.2 → 0.33.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/preset.d.mts +3 -23
- package/dist/preset.d.ts +3 -23
- package/dist/preset.mjs +337 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
package/dist/preset.d.mts
CHANGED
|
@@ -7,12 +7,12 @@ import { Linter } from 'eslint';
|
|
|
7
7
|
interface RuleOptions {
|
|
8
8
|
/**
|
|
9
9
|
* Checks dependencies in project's package.json for version mismatches
|
|
10
|
-
* @see https://github.com/nrwl/nx/blob/19.5.
|
|
10
|
+
* @see https://github.com/nrwl/nx/blob/19.5.3/docs/generated/packages/eslint-plugin/documents/dependency-checks.md
|
|
11
11
|
*/
|
|
12
12
|
'@nx/dependency-checks'?: Linter.RuleEntry<NxDependencyChecks>
|
|
13
13
|
/**
|
|
14
14
|
* Ensure that module boundaries are respected within the monorepo
|
|
15
|
-
* @see https://github.com/nrwl/nx/blob/19.5.
|
|
15
|
+
* @see https://github.com/nrwl/nx/blob/19.5.3/docs/generated/packages/eslint-plugin/documents/enforce-module-boundaries.md
|
|
16
16
|
*/
|
|
17
17
|
'@nx/enforce-module-boundaries'?: Linter.RuleEntry<NxEnforceModuleBoundaries>
|
|
18
18
|
/**
|
|
@@ -780,27 +780,7 @@ interface RuleOptions {
|
|
|
780
780
|
* @see https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
|
|
781
781
|
*/
|
|
782
782
|
'@typescript-eslint/use-unknown-in-catch-callback-variable'?: Linter.RuleEntry<[]>
|
|
783
|
-
'
|
|
784
|
-
'json/colon-expected'?: Linter.RuleEntry<JsonColonExpected>
|
|
785
|
-
'json/comma-expected'?: Linter.RuleEntry<JsonCommaExpected>
|
|
786
|
-
'json/comma-or-close-backet-expected'?: Linter.RuleEntry<JsonCommaOrCloseBacketExpected>
|
|
787
|
-
'json/comma-or-close-brace-expected'?: Linter.RuleEntry<JsonCommaOrCloseBraceExpected>
|
|
788
|
-
'json/comment-not-permitted'?: Linter.RuleEntry<JsonCommentNotPermitted>
|
|
789
|
-
'json/duplicate-key'?: Linter.RuleEntry<JsonDuplicateKey>
|
|
790
|
-
'json/enum-value-mismatch'?: Linter.RuleEntry<JsonEnumValueMismatch>
|
|
791
|
-
'json/invalid-character'?: Linter.RuleEntry<JsonInvalidCharacter>
|
|
792
|
-
'json/invalid-escape-character'?: Linter.RuleEntry<JsonInvalidEscapeCharacter>
|
|
793
|
-
'json/invalid-unicode'?: Linter.RuleEntry<JsonInvalidUnicode>
|
|
794
|
-
'json/json'?: Linter.RuleEntry<JsonJson>
|
|
795
|
-
'json/property-expected'?: Linter.RuleEntry<JsonPropertyExpected>
|
|
796
|
-
'json/schema-resolve-error'?: Linter.RuleEntry<JsonSchemaResolveError>
|
|
797
|
-
'json/trailing-comma'?: Linter.RuleEntry<JsonTrailingComma>
|
|
798
|
-
'json/undefined'?: Linter.RuleEntry<JsonUndefined>
|
|
799
|
-
'json/unexpected-end-of-comment'?: Linter.RuleEntry<JsonUnexpectedEndOfComment>
|
|
800
|
-
'json/unexpected-end-of-number'?: Linter.RuleEntry<JsonUnexpectedEndOfNumber>
|
|
801
|
-
'json/unexpected-end-of-string'?: Linter.RuleEntry<JsonUnexpectedEndOfString>
|
|
802
|
-
'json/unknown'?: Linter.RuleEntry<JsonUnknown>
|
|
803
|
-
'json/value-expected'?: Linter.RuleEntry<JsonValueExpected>
|
|
783
|
+
'banner/banner'?: Linter.RuleEntry<[]>
|
|
804
784
|
/**
|
|
805
785
|
* Enforce emojis are wrapped in `<span>` and provide screenreader access.
|
|
806
786
|
* @see https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/accessible-emoji.md
|
package/dist/preset.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ import { Linter } from 'eslint';
|
|
|
7
7
|
interface RuleOptions {
|
|
8
8
|
/**
|
|
9
9
|
* Checks dependencies in project's package.json for version mismatches
|
|
10
|
-
* @see https://github.com/nrwl/nx/blob/19.5.
|
|
10
|
+
* @see https://github.com/nrwl/nx/blob/19.5.3/docs/generated/packages/eslint-plugin/documents/dependency-checks.md
|
|
11
11
|
*/
|
|
12
12
|
'@nx/dependency-checks'?: Linter.RuleEntry<NxDependencyChecks>
|
|
13
13
|
/**
|
|
14
14
|
* Ensure that module boundaries are respected within the monorepo
|
|
15
|
-
* @see https://github.com/nrwl/nx/blob/19.5.
|
|
15
|
+
* @see https://github.com/nrwl/nx/blob/19.5.3/docs/generated/packages/eslint-plugin/documents/enforce-module-boundaries.md
|
|
16
16
|
*/
|
|
17
17
|
'@nx/enforce-module-boundaries'?: Linter.RuleEntry<NxEnforceModuleBoundaries>
|
|
18
18
|
/**
|
|
@@ -780,27 +780,7 @@ interface RuleOptions {
|
|
|
780
780
|
* @see https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
|
|
781
781
|
*/
|
|
782
782
|
'@typescript-eslint/use-unknown-in-catch-callback-variable'?: Linter.RuleEntry<[]>
|
|
783
|
-
'
|
|
784
|
-
'json/colon-expected'?: Linter.RuleEntry<JsonColonExpected>
|
|
785
|
-
'json/comma-expected'?: Linter.RuleEntry<JsonCommaExpected>
|
|
786
|
-
'json/comma-or-close-backet-expected'?: Linter.RuleEntry<JsonCommaOrCloseBacketExpected>
|
|
787
|
-
'json/comma-or-close-brace-expected'?: Linter.RuleEntry<JsonCommaOrCloseBraceExpected>
|
|
788
|
-
'json/comment-not-permitted'?: Linter.RuleEntry<JsonCommentNotPermitted>
|
|
789
|
-
'json/duplicate-key'?: Linter.RuleEntry<JsonDuplicateKey>
|
|
790
|
-
'json/enum-value-mismatch'?: Linter.RuleEntry<JsonEnumValueMismatch>
|
|
791
|
-
'json/invalid-character'?: Linter.RuleEntry<JsonInvalidCharacter>
|
|
792
|
-
'json/invalid-escape-character'?: Linter.RuleEntry<JsonInvalidEscapeCharacter>
|
|
793
|
-
'json/invalid-unicode'?: Linter.RuleEntry<JsonInvalidUnicode>
|
|
794
|
-
'json/json'?: Linter.RuleEntry<JsonJson>
|
|
795
|
-
'json/property-expected'?: Linter.RuleEntry<JsonPropertyExpected>
|
|
796
|
-
'json/schema-resolve-error'?: Linter.RuleEntry<JsonSchemaResolveError>
|
|
797
|
-
'json/trailing-comma'?: Linter.RuleEntry<JsonTrailingComma>
|
|
798
|
-
'json/undefined'?: Linter.RuleEntry<JsonUndefined>
|
|
799
|
-
'json/unexpected-end-of-comment'?: Linter.RuleEntry<JsonUnexpectedEndOfComment>
|
|
800
|
-
'json/unexpected-end-of-number'?: Linter.RuleEntry<JsonUnexpectedEndOfNumber>
|
|
801
|
-
'json/unexpected-end-of-string'?: Linter.RuleEntry<JsonUnexpectedEndOfString>
|
|
802
|
-
'json/unknown'?: Linter.RuleEntry<JsonUnknown>
|
|
803
|
-
'json/value-expected'?: Linter.RuleEntry<JsonValueExpected>
|
|
783
|
+
'banner/banner'?: Linter.RuleEntry<[]>
|
|
804
784
|
/**
|
|
805
785
|
* Enforce emojis are wrapped in `<span>` and provide screenreader access.
|
|
806
786
|
* @see https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/HEAD/docs/rules/accessible-emoji.md
|
package/dist/preset.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import tsEslint from 'typescript-eslint';
|
|
2
2
|
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
3
3
|
import nxPlugin from '@nx/eslint-plugin';
|
|
4
|
-
import json from 'eslint-plugin-json';
|
|
5
4
|
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
6
5
|
import markdown from 'eslint-plugin-markdown';
|
|
7
6
|
import prettierConfig from 'eslint-plugin-prettier/recommended';
|
|
@@ -11,6 +10,7 @@ import tsdoc from 'eslint-plugin-tsdoc';
|
|
|
11
10
|
import yml from 'eslint-plugin-yml';
|
|
12
11
|
import globals from 'globals';
|
|
13
12
|
import jsoncParser from 'jsonc-eslint-parser';
|
|
13
|
+
import os from 'node:os';
|
|
14
14
|
|
|
15
15
|
function getDefaultExportFromCjs (x) {
|
|
16
16
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -1191,7 +1191,337 @@ const config = {
|
|
|
1191
1191
|
"tsdoc/syntax": "warn"
|
|
1192
1192
|
};
|
|
1193
1193
|
|
|
1194
|
-
const
|
|
1194
|
+
const getFileBanner = (name, commentStart = "//") => {
|
|
1195
|
+
let padding = "";
|
|
1196
|
+
while (name.length + padding.length < 12) {
|
|
1197
|
+
padding += " ";
|
|
1198
|
+
}
|
|
1199
|
+
let titleName = process.env.STORM_NAMESPACE ?? "";
|
|
1200
|
+
if (titleName) {
|
|
1201
|
+
if (titleName?.startsWith("@")) {
|
|
1202
|
+
titleName = titleName.slice(1);
|
|
1203
|
+
}
|
|
1204
|
+
titleName = (titleName.charAt(0).toUpperCase() + titleName.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
1205
|
+
}
|
|
1206
|
+
return `
|
|
1207
|
+
|
|
1208
|
+
${commentStart} -------------------------------------------------------------------
|
|
1209
|
+
${commentStart}
|
|
1210
|
+
${commentStart} ${padding}Storm Software
|
|
1211
|
+
${commentStart} \u26A1 ${titleName ? name ? `${titleName} - ` : titleName : ""}${name && name.length > 0 ? name.charAt(0).toUpperCase() + name.slice(1) : name}
|
|
1212
|
+
${commentStart}
|
|
1213
|
+
${commentStart} This code was released as part of the ${titleName ? `${titleName} ` : ""}project. ${titleName ? titleName : "This project"}
|
|
1214
|
+
${commentStart} is maintained by Storm Software under the ${(process.env.STORM_LICENSE ?? "Apache-2.0")?.toLowerCase()?.includes("license") ? process.env.STORM_LICENSE ?? "Apache-2.0" : `${process.env.STORM_LICENSE ?? "Apache-2.0"} License`}, and is
|
|
1215
|
+
${commentStart} free for commercial and private use. For more information, please visit
|
|
1216
|
+
${commentStart} our licensing page.
|
|
1217
|
+
${commentStart}
|
|
1218
|
+
${commentStart} Website: ${process.env.STORM_HOMEPAGE ?? "https://stormsoftware.com"}
|
|
1219
|
+
${commentStart} Repository: ${process.env.STORM_REPOSITORY ?? "https://github.com/storm-software/storm-stack"}
|
|
1220
|
+
${commentStart} Documentation: https://stormsoftware.com/docs${titleName?.startsWith("@") ? `/${titleName.slice(1)}` : ""}
|
|
1221
|
+
${commentStart} Contact: ${process.env.STORM_HOMEPAGE ? process.env.STORM_HOMEPAGE.endsWith("/") ? process.env.STORM_HOMEPAGE.slice(-1) : process.env.STORM_HOMEPAGE : "https://stormsoftware.com"}/contact
|
|
1222
|
+
${commentStart} Licensing: ${process.env.STORM_HOMEPAGE ? process.env.STORM_HOMEPAGE.endsWith("/") ? process.env.STORM_HOMEPAGE.slice(-1) : process.env.STORM_HOMEPAGE : "https://stormsoftware.com"}/licensing
|
|
1223
|
+
${commentStart}
|
|
1224
|
+
${commentStart} -------------------------------------------------------------------
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
`;
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
function isPattern(object) {
|
|
1231
|
+
return typeof object === "object" && Object.prototype.hasOwnProperty.call(object, "pattern");
|
|
1232
|
+
}
|
|
1233
|
+
function match(actual, expected) {
|
|
1234
|
+
if (expected.test) {
|
|
1235
|
+
return expected.test(actual);
|
|
1236
|
+
} else {
|
|
1237
|
+
return expected === actual;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
function excludeShebangs(comments) {
|
|
1241
|
+
return comments.filter(function(comment) {
|
|
1242
|
+
return comment.type !== "Shebang";
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
function getLeadingComments(context, node) {
|
|
1246
|
+
var all = excludeShebangs(
|
|
1247
|
+
context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node)
|
|
1248
|
+
);
|
|
1249
|
+
if (all[0].type.toLowerCase() === "block") {
|
|
1250
|
+
return [all[0]];
|
|
1251
|
+
}
|
|
1252
|
+
for (var i = 1; i < all.length; ++i) {
|
|
1253
|
+
var txt = context.getSourceCode().getText().slice(all[i - 1].range[1], all[i].range[0]);
|
|
1254
|
+
if (!txt.match(/^(\r\n|\r|\n)$/)) {
|
|
1255
|
+
break;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return all.slice(0, i);
|
|
1259
|
+
}
|
|
1260
|
+
function genCommentBody(commentType, textArray, eol, numNewlines) {
|
|
1261
|
+
var eols = eol.repeat(numNewlines);
|
|
1262
|
+
if (commentType === "block") {
|
|
1263
|
+
return "/*" + textArray.join(eol) + "*/" + eols;
|
|
1264
|
+
} else {
|
|
1265
|
+
return "//" + textArray.join(eol + "//") + eols;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
function genCommentsRange(context, comments, eol) {
|
|
1269
|
+
var start = comments[0].range[0];
|
|
1270
|
+
var end = comments.slice(-1)[0].range[1];
|
|
1271
|
+
if (context.getSourceCode().text[end] === eol) {
|
|
1272
|
+
end += eol.length;
|
|
1273
|
+
}
|
|
1274
|
+
return [start, end];
|
|
1275
|
+
}
|
|
1276
|
+
function genPrependFixer(commentType, node, headerLines, eol, numNewlines) {
|
|
1277
|
+
return function(fixer) {
|
|
1278
|
+
return fixer.insertTextBefore(
|
|
1279
|
+
node,
|
|
1280
|
+
genCommentBody(commentType, headerLines, eol, numNewlines)
|
|
1281
|
+
);
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
function genReplaceFixer(commentType, context, leadingComments, headerLines, eol, numNewlines) {
|
|
1285
|
+
return function(fixer) {
|
|
1286
|
+
return fixer.replaceTextRange(
|
|
1287
|
+
genCommentsRange(context, leadingComments, eol),
|
|
1288
|
+
genCommentBody(commentType, headerLines, eol, numNewlines)
|
|
1289
|
+
);
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
function findSettings(options) {
|
|
1293
|
+
var lastOption = options.length > 0 ? options[options.length - 1] : null;
|
|
1294
|
+
if (typeof lastOption === "object" && !Array.isArray(lastOption) && lastOption !== null && !Object.prototype.hasOwnProperty.call(lastOption, "pattern")) {
|
|
1295
|
+
return lastOption;
|
|
1296
|
+
}
|
|
1297
|
+
return null;
|
|
1298
|
+
}
|
|
1299
|
+
function getEOL(options) {
|
|
1300
|
+
var settings = findSettings(options);
|
|
1301
|
+
if (settings && settings.lineEndings === "unix") {
|
|
1302
|
+
return "\n";
|
|
1303
|
+
}
|
|
1304
|
+
if (settings && settings.lineEndings === "windows") {
|
|
1305
|
+
return "\r\n";
|
|
1306
|
+
}
|
|
1307
|
+
return os.EOL;
|
|
1308
|
+
}
|
|
1309
|
+
function hasHeader(src) {
|
|
1310
|
+
if (src.substr(0, 2) === "#!") {
|
|
1311
|
+
var m = src.match(/(\r\n|\r|\n)/);
|
|
1312
|
+
if (m) {
|
|
1313
|
+
src = src.slice(m.index + m[0].length);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
return src.substr(0, 2) === "/*" || src.substr(0, 2) === "//";
|
|
1317
|
+
}
|
|
1318
|
+
function matchesLineEndings(src, num) {
|
|
1319
|
+
for (var j = 0; j < num; ++j) {
|
|
1320
|
+
var m = src.match(/^(\r\n|\r|\n)/);
|
|
1321
|
+
if (m) {
|
|
1322
|
+
src = src.slice(m.index + m[0].length);
|
|
1323
|
+
} else {
|
|
1324
|
+
return false;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
return true;
|
|
1328
|
+
}
|
|
1329
|
+
const bannerRule = {
|
|
1330
|
+
meta: {
|
|
1331
|
+
type: "layout",
|
|
1332
|
+
fixable: "whitespace"
|
|
1333
|
+
},
|
|
1334
|
+
create: function(context) {
|
|
1335
|
+
var options = context.options;
|
|
1336
|
+
var numNewlines = options.length > 2 ? options[2] : 1;
|
|
1337
|
+
var eol = getEOL(options);
|
|
1338
|
+
var header = options.length <= 1 ? getFileBanner("") : options[1];
|
|
1339
|
+
var commentType = options[0].toLowerCase();
|
|
1340
|
+
var headerLines, fixLines = [];
|
|
1341
|
+
var canFix = false;
|
|
1342
|
+
if (Array.isArray(header)) {
|
|
1343
|
+
canFix = true;
|
|
1344
|
+
headerLines = header.map(function(line2) {
|
|
1345
|
+
var isRegex = isPattern(line2);
|
|
1346
|
+
if (isRegex && !line2.template) {
|
|
1347
|
+
canFix = false;
|
|
1348
|
+
}
|
|
1349
|
+
fixLines.push(line2.template || line2);
|
|
1350
|
+
return isRegex ? new RegExp(line2.pattern) : line2;
|
|
1351
|
+
});
|
|
1352
|
+
} else if (isPattern(header)) {
|
|
1353
|
+
var line = header;
|
|
1354
|
+
headerLines = [new RegExp(line.pattern)];
|
|
1355
|
+
fixLines.push(line.template || line);
|
|
1356
|
+
canFix = !!line.template;
|
|
1357
|
+
} else {
|
|
1358
|
+
canFix = true;
|
|
1359
|
+
headerLines = header.split(/\r?\n/);
|
|
1360
|
+
fixLines = headerLines;
|
|
1361
|
+
}
|
|
1362
|
+
return {
|
|
1363
|
+
Program: function(node) {
|
|
1364
|
+
if (!hasHeader(context.getSourceCode().getText())) {
|
|
1365
|
+
context.report({
|
|
1366
|
+
loc: node.loc,
|
|
1367
|
+
message: "missing header",
|
|
1368
|
+
fix: genPrependFixer(commentType, node, fixLines, eol, numNewlines)
|
|
1369
|
+
});
|
|
1370
|
+
} else {
|
|
1371
|
+
var leadingComments = getLeadingComments(context, node);
|
|
1372
|
+
if (!leadingComments.length) {
|
|
1373
|
+
context.report({
|
|
1374
|
+
loc: node.loc,
|
|
1375
|
+
message: "missing header",
|
|
1376
|
+
fix: canFix ? genPrependFixer(commentType, node, fixLines, eol, numNewlines) : null
|
|
1377
|
+
});
|
|
1378
|
+
} else if (leadingComments[0].type.toLowerCase() !== commentType) {
|
|
1379
|
+
context.report({
|
|
1380
|
+
loc: node.loc,
|
|
1381
|
+
message: "header should be a {{commentType}} comment",
|
|
1382
|
+
data: {
|
|
1383
|
+
commentType
|
|
1384
|
+
},
|
|
1385
|
+
fix: canFix ? genReplaceFixer(
|
|
1386
|
+
commentType,
|
|
1387
|
+
context,
|
|
1388
|
+
leadingComments,
|
|
1389
|
+
fixLines,
|
|
1390
|
+
eol,
|
|
1391
|
+
numNewlines
|
|
1392
|
+
) : null
|
|
1393
|
+
});
|
|
1394
|
+
} else {
|
|
1395
|
+
if (commentType === "line") {
|
|
1396
|
+
if (leadingComments.length < headerLines.length) {
|
|
1397
|
+
context.report({
|
|
1398
|
+
loc: node.loc,
|
|
1399
|
+
message: "incorrect header",
|
|
1400
|
+
fix: canFix ? genReplaceFixer(
|
|
1401
|
+
commentType,
|
|
1402
|
+
context,
|
|
1403
|
+
leadingComments,
|
|
1404
|
+
fixLines,
|
|
1405
|
+
eol,
|
|
1406
|
+
numNewlines
|
|
1407
|
+
) : null
|
|
1408
|
+
});
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
for (var i = 0; i < headerLines.length; i++) {
|
|
1412
|
+
if (!match(leadingComments[i].value, headerLines[i])) {
|
|
1413
|
+
context.report({
|
|
1414
|
+
loc: node.loc,
|
|
1415
|
+
message: "incorrect header",
|
|
1416
|
+
fix: canFix ? genReplaceFixer(
|
|
1417
|
+
commentType,
|
|
1418
|
+
context,
|
|
1419
|
+
leadingComments,
|
|
1420
|
+
fixLines,
|
|
1421
|
+
eol,
|
|
1422
|
+
numNewlines
|
|
1423
|
+
) : null
|
|
1424
|
+
});
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
var postLineHeader = context.getSourceCode().text.substr(
|
|
1429
|
+
leadingComments[headerLines.length - 1].range[1],
|
|
1430
|
+
numNewlines * 2
|
|
1431
|
+
);
|
|
1432
|
+
if (!matchesLineEndings(postLineHeader, numNewlines)) {
|
|
1433
|
+
context.report({
|
|
1434
|
+
loc: node.loc,
|
|
1435
|
+
message: "no newline after header",
|
|
1436
|
+
fix: canFix ? genReplaceFixer(
|
|
1437
|
+
commentType,
|
|
1438
|
+
context,
|
|
1439
|
+
leadingComments,
|
|
1440
|
+
fixLines,
|
|
1441
|
+
eol,
|
|
1442
|
+
numNewlines
|
|
1443
|
+
) : null
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
} else {
|
|
1447
|
+
var leadingLines = [leadingComments[0].value];
|
|
1448
|
+
if (headerLines.length > 1) {
|
|
1449
|
+
leadingLines = leadingComments[0].value.split(/\r?\n/);
|
|
1450
|
+
}
|
|
1451
|
+
var hasError = false;
|
|
1452
|
+
if (leadingLines.length > headerLines.length) {
|
|
1453
|
+
hasError = true;
|
|
1454
|
+
}
|
|
1455
|
+
for (i = 0; !hasError && i < headerLines.length; i++) {
|
|
1456
|
+
if (!match(leadingLines[i], headerLines[i])) {
|
|
1457
|
+
hasError = true;
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (hasError) {
|
|
1461
|
+
if (canFix && headerLines.length > 1) {
|
|
1462
|
+
fixLines = [fixLines.join(eol)];
|
|
1463
|
+
}
|
|
1464
|
+
context.report({
|
|
1465
|
+
loc: node.loc,
|
|
1466
|
+
message: "incorrect header",
|
|
1467
|
+
fix: canFix ? genReplaceFixer(
|
|
1468
|
+
commentType,
|
|
1469
|
+
context,
|
|
1470
|
+
leadingComments,
|
|
1471
|
+
fixLines,
|
|
1472
|
+
eol,
|
|
1473
|
+
numNewlines
|
|
1474
|
+
) : null
|
|
1475
|
+
});
|
|
1476
|
+
} else {
|
|
1477
|
+
var postBlockHeader = context.getSourceCode().text.substr(leadingComments[0].range[1], numNewlines * 2);
|
|
1478
|
+
if (!matchesLineEndings(postBlockHeader, numNewlines)) {
|
|
1479
|
+
context.report({
|
|
1480
|
+
loc: node.loc,
|
|
1481
|
+
message: "no newline after header",
|
|
1482
|
+
fix: canFix ? genReplaceFixer(
|
|
1483
|
+
commentType,
|
|
1484
|
+
context,
|
|
1485
|
+
leadingComments,
|
|
1486
|
+
fixLines,
|
|
1487
|
+
eol,
|
|
1488
|
+
numNewlines
|
|
1489
|
+
) : null
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
const plugin = {
|
|
1501
|
+
meta: {
|
|
1502
|
+
name: "eslint-plugin-banner",
|
|
1503
|
+
version: "0.0.1"
|
|
1504
|
+
},
|
|
1505
|
+
configs: {},
|
|
1506
|
+
rules: {
|
|
1507
|
+
banner: bannerRule
|
|
1508
|
+
},
|
|
1509
|
+
processors: {}
|
|
1510
|
+
};
|
|
1511
|
+
plugin.configs.recommended = {
|
|
1512
|
+
plugins: { banner: plugin },
|
|
1513
|
+
files: [
|
|
1514
|
+
"**/*.{,c,m}{j,t}s{,x}",
|
|
1515
|
+
"!tools/**/*",
|
|
1516
|
+
"!docs/**/*",
|
|
1517
|
+
"!crates/**/*",
|
|
1518
|
+
"!.*/**/*"
|
|
1519
|
+
],
|
|
1520
|
+
rules: {
|
|
1521
|
+
"banner/banner": [2, "block", getFileBanner("")]
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1195
1525
|
const CODE_FILE = "**/*.{,c,m}{j,t}s{,x}";
|
|
1196
1526
|
const TS_FILE = "**/*.{,c,m}ts{,x}";
|
|
1197
1527
|
|
|
@@ -1279,7 +1609,7 @@ function stormPreset(options = {
|
|
|
1279
1609
|
// https://www.npmjs.com/package/eslint-plugin-markdown
|
|
1280
1610
|
options.markdown !== false && { plugins: { markdown } },
|
|
1281
1611
|
options.markdown !== false && {
|
|
1282
|
-
files: [
|
|
1612
|
+
files: [CODE_FILE],
|
|
1283
1613
|
processor: "markdown/markdown"
|
|
1284
1614
|
},
|
|
1285
1615
|
options.markdown !== false && {
|
|
@@ -1316,6 +1646,8 @@ function stormPreset(options = {
|
|
|
1316
1646
|
// files: [CODE_FILE],
|
|
1317
1647
|
// rules: importRules
|
|
1318
1648
|
// },
|
|
1649
|
+
// Banner
|
|
1650
|
+
plugin.configs["recommended"],
|
|
1319
1651
|
// TSDoc
|
|
1320
1652
|
// https://www.npmjs.com/package/eslint-plugin-tsdoc
|
|
1321
1653
|
{ plugins: { tsdoc } },
|
|
@@ -1331,7 +1663,7 @@ function stormPreset(options = {
|
|
|
1331
1663
|
globals: {
|
|
1332
1664
|
...globals.node,
|
|
1333
1665
|
...globals.browser,
|
|
1334
|
-
"
|
|
1666
|
+
"StormProvider": true
|
|
1335
1667
|
}
|
|
1336
1668
|
},
|
|
1337
1669
|
files: [CODE_FILE],
|
|
@@ -1371,7 +1703,7 @@ function stormPreset(options = {
|
|
|
1371
1703
|
},
|
|
1372
1704
|
// Json
|
|
1373
1705
|
// https://www.npmjs.com/package/eslint-plugin-json
|
|
1374
|
-
json.configs["recommended"],
|
|
1706
|
+
// json.configs["recommended-with-comments"],
|
|
1375
1707
|
{
|
|
1376
1708
|
files: ["*.json", "*.jsonc"],
|
|
1377
1709
|
languageOptions: {
|
package/package.json
CHANGED