@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.cjs
CHANGED
|
@@ -41,7 +41,8 @@ var import_utils = require("@typescript-eslint/utils");
|
|
|
41
41
|
// src/rules/_paths.ts
|
|
42
42
|
var SCRIPT_FILE_RE = /([\\/]scripts[\\/])|(\.mjs$)/;
|
|
43
43
|
var STORY_FILE_RE = /\.stories\.[cm]?[jt]sx?$/i;
|
|
44
|
-
var GENERATED_FILE_RE = /([\\/]generated[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)/;
|
|
44
|
+
var GENERATED_FILE_RE = /([\\/](?:generated|openapi-gen|graphql[\\/]types)[\\/])|(\.gen\.[cm]?[jt]sx?$)|(\.generated\.[cm]?[jt]sx?$)|(\.d\.[cm]?ts$)|(\.types\.[cm]?ts$)/;
|
|
45
|
+
var GENERATED_MARKER_RE = /(?:@generated\b|generated (?:with|by)|generated (?:graphql )?types|do not edit(?: directly| manually)?)/i;
|
|
45
46
|
function isTestFile(filename) {
|
|
46
47
|
const normalized = filename.replaceAll("\\", "/");
|
|
47
48
|
const base = normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
@@ -54,7 +55,7 @@ function isStoryFile(filename) {
|
|
|
54
55
|
return STORY_FILE_RE.test(filename);
|
|
55
56
|
}
|
|
56
57
|
function isGeneratedFile(filename, sourceText = "") {
|
|
57
|
-
return GENERATED_FILE_RE.test(filename.replaceAll("\\", "/")) ||
|
|
58
|
+
return GENERATED_FILE_RE.test(filename.replaceAll("\\", "/")) || GENERATED_MARKER_RE.test(sourceText.slice(0, 2048));
|
|
58
59
|
}
|
|
59
60
|
function isScriptFile(filename) {
|
|
60
61
|
return SCRIPT_FILE_RE.test(filename);
|
|
@@ -97,7 +98,7 @@ var enforce_file_structure_default = import_utils.ESLintUtils.RuleCreator(
|
|
|
97
98
|
},
|
|
98
99
|
defaultOptions: [],
|
|
99
100
|
create(context) {
|
|
100
|
-
if (isTestFile(context.filename)) {
|
|
101
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
101
102
|
return {};
|
|
102
103
|
}
|
|
103
104
|
return {
|
|
@@ -486,6 +487,9 @@ var no_comment_cruft_default = import_utils3.ESLintUtils.RuleCreator(
|
|
|
486
487
|
},
|
|
487
488
|
defaultOptions: [],
|
|
488
489
|
create(context) {
|
|
490
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
491
|
+
return {};
|
|
492
|
+
}
|
|
489
493
|
const sourceCode = context.sourceCode;
|
|
490
494
|
function isStandalone(comment) {
|
|
491
495
|
const before = sourceCode.getTokenBefore(comment, {
|
|
@@ -558,6 +562,7 @@ var no_comment_cruft_default = import_utils3.ESLintUtils.RuleCreator(
|
|
|
558
562
|
var import_utils4 = require("@typescript-eslint/utils");
|
|
559
563
|
var DEFAULT_IGNORE_PATTERNS = [
|
|
560
564
|
/[\\/]generated[\\/]/,
|
|
565
|
+
/[\\/]openapi-gen[\\/]/,
|
|
561
566
|
/\.gen\.tsx?$/,
|
|
562
567
|
/\.generated\.tsx?$/
|
|
563
568
|
];
|
|
@@ -609,7 +614,7 @@ var no_enum_default = import_utils4.ESLintUtils.RuleCreator(
|
|
|
609
614
|
(re) => re.test(filename)
|
|
610
615
|
);
|
|
611
616
|
const isIgnoredByOption = ignoreFiles.length > 0 && matchesAnyPattern(filename, ignoreFiles);
|
|
612
|
-
const isGenerated = hasGeneratedMarker(sourceText);
|
|
617
|
+
const isGenerated = hasGeneratedMarker(sourceText) || isGeneratedFile(filename, sourceText);
|
|
613
618
|
if (isIgnoredByDefault || isIgnoredByOption || isGenerated) {
|
|
614
619
|
return {};
|
|
615
620
|
}
|
|
@@ -1564,6 +1569,9 @@ var no_sentinel_return_on_catch_default = import_utils10.ESLintUtils.RuleCreator
|
|
|
1564
1569
|
},
|
|
1565
1570
|
defaultOptions: [{}],
|
|
1566
1571
|
create(context, [loggingOptions]) {
|
|
1572
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
1573
|
+
return {};
|
|
1574
|
+
}
|
|
1567
1575
|
const matcher = createLogMatcher(loggingOptions);
|
|
1568
1576
|
function logsOrReportsError(catchBody, caughtName) {
|
|
1569
1577
|
return walkWithinScope(catchBody, (current) => {
|
|
@@ -1970,6 +1978,9 @@ var no_string_concat_in_loop_default = import_utils12.ESLintUtils.RuleCreator(
|
|
|
1970
1978
|
},
|
|
1971
1979
|
defaultOptions: [],
|
|
1972
1980
|
create(context) {
|
|
1981
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
1982
|
+
return {};
|
|
1983
|
+
}
|
|
1973
1984
|
const reported = /* @__PURE__ */ new WeakMap();
|
|
1974
1985
|
return {
|
|
1975
1986
|
AssignmentExpression(node) {
|
|
@@ -2434,7 +2445,7 @@ var prefer_schema_for_api_payload_default = import_utils16.ESLintUtils.RuleCreat
|
|
|
2434
2445
|
},
|
|
2435
2446
|
defaultOptions: [],
|
|
2436
2447
|
create(context) {
|
|
2437
|
-
if (isTestFile(context.filename)) {
|
|
2448
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
2438
2449
|
return {};
|
|
2439
2450
|
}
|
|
2440
2451
|
const unvalidatedVariables = /* @__PURE__ */ new Set();
|
|
@@ -2604,10 +2615,32 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
2604
2615
|
"currentcolor",
|
|
2605
2616
|
"inherit"
|
|
2606
2617
|
]);
|
|
2618
|
+
function jsxElementName(node) {
|
|
2619
|
+
const name = node.openingElement.name;
|
|
2620
|
+
if (name.type === import_utils17.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
2621
|
+
if (name.type === import_utils17.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils17.AST_NODE_TYPES.JSXIdentifier) {
|
|
2622
|
+
return name.property.name;
|
|
2623
|
+
}
|
|
2624
|
+
return null;
|
|
2625
|
+
}
|
|
2626
|
+
function isSvgLikeElementName(name) {
|
|
2627
|
+
return name === "svg" || SVG_DEFS_CONTAINERS.has(name) || /svg$/i.test(name);
|
|
2628
|
+
}
|
|
2607
2629
|
var isInsideSvg = (node) => {
|
|
2608
2630
|
let current = node.parent;
|
|
2609
2631
|
while (current !== void 0 && current !== null) {
|
|
2610
|
-
if (current.type === import_utils17.AST_NODE_TYPES.JSXElement
|
|
2632
|
+
if (current.type === import_utils17.AST_NODE_TYPES.JSXElement) {
|
|
2633
|
+
const name = jsxElementName(current);
|
|
2634
|
+
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
2635
|
+
}
|
|
2636
|
+
current = current.parent;
|
|
2637
|
+
}
|
|
2638
|
+
return false;
|
|
2639
|
+
};
|
|
2640
|
+
var isInsideIconFactoryPath = (node) => {
|
|
2641
|
+
let current = node.parent;
|
|
2642
|
+
while (current !== void 0 && current !== null) {
|
|
2643
|
+
if (current.type === import_utils17.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils17.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils17.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils17.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
2611
2644
|
return true;
|
|
2612
2645
|
}
|
|
2613
2646
|
current = current.parent;
|
|
@@ -2756,7 +2789,7 @@ var prefer_semantic_colors_default = import_utils17.ESLintUtils.RuleCreator(
|
|
|
2756
2789
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
2757
2790
|
return;
|
|
2758
2791
|
}
|
|
2759
|
-
if (isInsideSvg(node)) return;
|
|
2792
|
+
if (isInsideSvg(node) || isInsideIconFactoryPath(node)) return;
|
|
2760
2793
|
checkColorValueNode(node.value);
|
|
2761
2794
|
},
|
|
2762
2795
|
// Inline style objects: style={{ color: "#111827", backgroundColor: "#fff" }}
|
|
@@ -4044,6 +4077,9 @@ var no_fat_try_blocks_default = import_utils27.ESLintUtils.RuleCreator(
|
|
|
4044
4077
|
},
|
|
4045
4078
|
defaultOptions: [],
|
|
4046
4079
|
create(context) {
|
|
4080
|
+
if (isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4081
|
+
return {};
|
|
4082
|
+
}
|
|
4047
4083
|
const sourceCode = context.sourceCode;
|
|
4048
4084
|
return {
|
|
4049
4085
|
TryStatement(node) {
|
|
@@ -4433,7 +4469,7 @@ var no_unsafe_cast_default = import_utils29.ESLintUtils.RuleCreator(
|
|
|
4433
4469
|
},
|
|
4434
4470
|
defaultOptions: [],
|
|
4435
4471
|
create(context) {
|
|
4436
|
-
if (isTestFile(context.filename)) {
|
|
4472
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, context.sourceCode.text)) {
|
|
4437
4473
|
return {};
|
|
4438
4474
|
}
|
|
4439
4475
|
function checkAssertion(node) {
|
|
@@ -6563,7 +6599,7 @@ var rules = {
|
|
|
6563
6599
|
var plugin = {
|
|
6564
6600
|
meta: {
|
|
6565
6601
|
name: "@sarj/eslint-plugin",
|
|
6566
|
-
version: "2.12.
|
|
6602
|
+
version: "2.12.2"
|
|
6567
6603
|
},
|
|
6568
6604
|
rules,
|
|
6569
6605
|
configs: {
|