@sarj/eslint-plugin 2.12.1 → 2.12.2
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/dist/index.cjs +45 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,8 @@ import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
|
4
4
|
// src/rules/_paths.ts
|
|
5
5
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
6
6
|
var STORY_FILE_RE = /\.stories\.[cm]?[jt]sx?$/i;
|
|
7
|
-
var GENERATED_FILE_RE = /([\\/]generated[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)/;
|
|
7
|
+
var GENERATED_FILE_RE = /([\\/](?:generated|openapi-gen|graphql[\\/]types)[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)|(\.types\.[cm]?ts$)/;
|
|
8
|
+
var GENERATED_MARKER_RE = /(?:@generated\b|generated (?:with|by)|generated (?:graphql )?types|do not edit(?: directly| manually)?)/i;
|
|
8
9
|
function isTestFile(filename) {
|
|
9
10
|
const normalized = filename.replaceAll("\\", "/");
|
|
10
11
|
const base = normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
@@ -17,7 +18,7 @@ function isStoryFile(filename) {
|
|
|
17
18
|
return STORY_FILE_RE.test(filename);
|
|
18
19
|
}
|
|
19
20
|
function isGeneratedFile(filename, sourceText = "") {
|
|
20
|
-
return GENERATED_FILE_RE.test(filename.replaceAll("\\", "/")) ||
|
|
21
|
+
return GENERATED_FILE_RE.test(filename.replaceAll("\\", "/")) || GENERATED_MARKER_RE.test(sourceText.slice(0, 2048));
|
|
21
22
|
}
|
|
22
23
|
function isScriptFile(filename) {
|
|
23
24
|
return SCRIPT_FILE_RE.test(filename);
|
|
@@ -60,7 +61,7 @@ var enforce_file_structure_default = ESLintUtils.RuleCreator(
|
|
|
60
61
|
},
|
|
61
62
|
defaultOptions: [],
|
|
62
63
|
create(context) {
|
|
63
|
-
if (isTestFile(context.filename)) {
|
|
64
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
64
65
|
return {};
|
|
65
66
|
}
|
|
66
67
|
return {
|
|
@@ -452,6 +453,9 @@ var no_comment_cruft_default = ESLintUtils3.RuleCreator(
|
|
|
452
453
|
},
|
|
453
454
|
defaultOptions: [],
|
|
454
455
|
create(context) {
|
|
456
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
457
|
+
return {};
|
|
458
|
+
}
|
|
455
459
|
const sourceCode = context.sourceCode;
|
|
456
460
|
function isStandalone(comment) {
|
|
457
461
|
const before = sourceCode.getTokenBefore(comment, {
|
|
@@ -524,6 +528,7 @@ var no_comment_cruft_default = ESLintUtils3.RuleCreator(
|
|
|
524
528
|
import { ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
525
529
|
var DEFAULT_IGNORE_PATTERNS = [
|
|
526
530
|
/[\\/]generated[\\/]/,
|
|
531
|
+
/[\\/]openapi-gen[\\/]/,
|
|
527
532
|
/\.gen\.tsx?$/,
|
|
528
533
|
/\.generated\.tsx?$/
|
|
529
534
|
];
|
|
@@ -575,7 +580,7 @@ var no_enum_default = ESLintUtils4.RuleCreator(
|
|
|
575
580
|
(re) => re.test(filename)
|
|
576
581
|
);
|
|
577
582
|
const isIgnoredByOption = ignoreFiles.length > 0 && matchesAnyPattern(filename, ignoreFiles);
|
|
578
|
-
const isGenerated = hasGeneratedMarker(sourceText);
|
|
583
|
+
const isGenerated = hasGeneratedMarker(sourceText) || isGeneratedFile(filename, sourceText);
|
|
579
584
|
if (isIgnoredByDefault || isIgnoredByOption || isGenerated) {
|
|
580
585
|
return {};
|
|
581
586
|
}
|
|
@@ -1533,6 +1538,9 @@ var no_sentinel_return_on_catch_default = ESLintUtils9.RuleCreator(
|
|
|
1533
1538
|
},
|
|
1534
1539
|
defaultOptions: [{}],
|
|
1535
1540
|
create(context, [loggingOptions]) {
|
|
1541
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
1542
|
+
return {};
|
|
1543
|
+
}
|
|
1536
1544
|
const matcher = createLogMatcher(loggingOptions);
|
|
1537
1545
|
function logsOrReportsError(catchBody, caughtName) {
|
|
1538
1546
|
return walkWithinScope(catchBody, (current) => {
|
|
@@ -1939,6 +1947,9 @@ var no_string_concat_in_loop_default = ESLintUtils11.RuleCreator(
|
|
|
1939
1947
|
},
|
|
1940
1948
|
defaultOptions: [],
|
|
1941
1949
|
create(context) {
|
|
1950
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
1951
|
+
return {};
|
|
1952
|
+
}
|
|
1942
1953
|
const reported = /* @__PURE__ */ new WeakMap();
|
|
1943
1954
|
return {
|
|
1944
1955
|
AssignmentExpression(node) {
|
|
@@ -2409,7 +2420,7 @@ var prefer_schema_for_api_payload_default = ESLintUtils14.RuleCreator(
|
|
|
2409
2420
|
},
|
|
2410
2421
|
defaultOptions: [],
|
|
2411
2422
|
create(context) {
|
|
2412
|
-
if (isTestFile(context.filename)) {
|
|
2423
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
2413
2424
|
return {};
|
|
2414
2425
|
}
|
|
2415
2426
|
const unvalidatedVariables = /* @__PURE__ */ new Set();
|
|
@@ -2579,10 +2590,32 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
2579
2590
|
"currentcolor",
|
|
2580
2591
|
"inherit"
|
|
2581
2592
|
]);
|
|
2593
|
+
function jsxElementName(node) {
|
|
2594
|
+
const name = node.openingElement.name;
|
|
2595
|
+
if (name.type === AST_NODE_TYPES8.JSXIdentifier) return name.name;
|
|
2596
|
+
if (name.type === AST_NODE_TYPES8.JSXMemberExpression && name.property.type === AST_NODE_TYPES8.JSXIdentifier) {
|
|
2597
|
+
return name.property.name;
|
|
2598
|
+
}
|
|
2599
|
+
return null;
|
|
2600
|
+
}
|
|
2601
|
+
function isSvgLikeElementName(name) {
|
|
2602
|
+
return name === "svg" || SVG_DEFS_CONTAINERS.has(name) || /svg$/i.test(name);
|
|
2603
|
+
}
|
|
2582
2604
|
var isInsideSvg = (node) => {
|
|
2583
2605
|
let current = node.parent;
|
|
2584
2606
|
while (current !== void 0 && current !== null) {
|
|
2585
|
-
if (current.type === AST_NODE_TYPES8.JSXElement
|
|
2607
|
+
if (current.type === AST_NODE_TYPES8.JSXElement) {
|
|
2608
|
+
const name = jsxElementName(current);
|
|
2609
|
+
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
2610
|
+
}
|
|
2611
|
+
current = current.parent;
|
|
2612
|
+
}
|
|
2613
|
+
return false;
|
|
2614
|
+
};
|
|
2615
|
+
var isInsideIconFactoryPath = (node) => {
|
|
2616
|
+
let current = node.parent;
|
|
2617
|
+
while (current !== void 0 && current !== null) {
|
|
2618
|
+
if (current.type === AST_NODE_TYPES8.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES8.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES8.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES8.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
2586
2619
|
return true;
|
|
2587
2620
|
}
|
|
2588
2621
|
current = current.parent;
|
|
@@ -2731,7 +2764,7 @@ var prefer_semantic_colors_default = ESLintUtils15.RuleCreator(
|
|
|
2731
2764
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
2732
2765
|
return;
|
|
2733
2766
|
}
|
|
2734
|
-
if (isInsideSvg(node)) return;
|
|
2767
|
+
if (isInsideSvg(node) || isInsideIconFactoryPath(node)) return;
|
|
2735
2768
|
checkColorValueNode(node.value);
|
|
2736
2769
|
},
|
|
2737
2770
|
// Inline style objects: style={{ color: "#111827", backgroundColor: "#fff" }}
|
|
@@ -4032,6 +4065,9 @@ var no_fat_try_blocks_default = ESLintUtils25.RuleCreator(
|
|
|
4032
4065
|
},
|
|
4033
4066
|
defaultOptions: [],
|
|
4034
4067
|
create(context) {
|
|
4068
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4069
|
+
return {};
|
|
4070
|
+
}
|
|
4035
4071
|
const sourceCode = context.sourceCode;
|
|
4036
4072
|
return {
|
|
4037
4073
|
TryStatement(node) {
|
|
@@ -4421,7 +4457,7 @@ var no_unsafe_cast_default = ESLintUtils27.RuleCreator(
|
|
|
4421
4457
|
},
|
|
4422
4458
|
defaultOptions: [],
|
|
4423
4459
|
create(context) {
|
|
4424
|
-
if (isTestFile(context.filename)) {
|
|
4460
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4425
4461
|
return {};
|
|
4426
4462
|
}
|
|
4427
4463
|
function checkAssertion(node) {
|
|
@@ -6560,7 +6596,7 @@ var rules = {
|
|
|
6560
6596
|
var plugin = {
|
|
6561
6597
|
meta: {
|
|
6562
6598
|
name: "@sarj/eslint-plugin",
|
|
6563
|
-
version: "2.12.
|
|
6599
|
+
version: "2.12.2"
|
|
6564
6600
|
},
|
|
6565
6601
|
rules,
|
|
6566
6602
|
configs: {
|