eslint-plugin-code-style 1.0.8 → 1.0.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/index.js +189 -189
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -445,7 +445,7 @@ const arrowFunctionBlockBody = {
|
|
|
445
445
|
create(context) {
|
|
446
446
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
447
447
|
|
|
448
|
-
const
|
|
448
|
+
const isJsxAttributeArrowHandler = (node) => {
|
|
449
449
|
let parent = node.parent;
|
|
450
450
|
|
|
451
451
|
if (parent && parent.type === "JSXExpressionContainer") {
|
|
@@ -457,8 +457,8 @@ const arrowFunctionBlockBody = {
|
|
|
457
457
|
return false;
|
|
458
458
|
};
|
|
459
459
|
|
|
460
|
-
const
|
|
461
|
-
if (!
|
|
460
|
+
const checkArrowFunctionHandler = (node) => {
|
|
461
|
+
if (!isJsxAttributeArrowHandler(node)) return;
|
|
462
462
|
|
|
463
463
|
// Only check expression bodies (not block bodies)
|
|
464
464
|
if (node.body.type === "BlockStatement") return;
|
|
@@ -535,7 +535,7 @@ const arrowFunctionBlockBody = {
|
|
|
535
535
|
}
|
|
536
536
|
};
|
|
537
537
|
|
|
538
|
-
return { ArrowFunctionExpression:
|
|
538
|
+
return { ArrowFunctionExpression: checkArrowFunctionHandler };
|
|
539
539
|
},
|
|
540
540
|
meta: {
|
|
541
541
|
docs: { description: "Enforce parentheses for arrow functions in JSX props with multiline expressions (preserves implicit return)" },
|
|
@@ -567,7 +567,7 @@ const arrowFunctionSimpleJsx = {
|
|
|
567
567
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
568
568
|
|
|
569
569
|
// Check if JSX is simple enough to be on one line
|
|
570
|
-
const
|
|
570
|
+
const isSimpleJsxHandler = (jsxNode) => {
|
|
571
571
|
if (jsxNode.type !== "JSXElement" && jsxNode.type !== "JSXFragment") return false;
|
|
572
572
|
|
|
573
573
|
// Check if JSX has no attributes or only simple attributes
|
|
@@ -632,7 +632,7 @@ const arrowFunctionSimpleJsx = {
|
|
|
632
632
|
};
|
|
633
633
|
|
|
634
634
|
// Get simplified JSX text (without extra whitespace)
|
|
635
|
-
const
|
|
635
|
+
const getSimplifiedJsxTextHandler = (jsxNode) => {
|
|
636
636
|
const text = sourceCode.getText(jsxNode);
|
|
637
637
|
|
|
638
638
|
// Remove extra whitespace between tags
|
|
@@ -655,10 +655,10 @@ const arrowFunctionSimpleJsx = {
|
|
|
655
655
|
if (node.loc.start.line === node.loc.end.line) return;
|
|
656
656
|
|
|
657
657
|
// Check if JSX is simple
|
|
658
|
-
if (!
|
|
658
|
+
if (!isSimpleJsxHandler(body)) return;
|
|
659
659
|
|
|
660
660
|
// Get the simplified JSX text
|
|
661
|
-
const jsxText =
|
|
661
|
+
const jsxText = getSimplifiedJsxTextHandler(body);
|
|
662
662
|
|
|
663
663
|
// Check if result would be reasonably short (< 120 chars)
|
|
664
664
|
const arrowStart = sourceCode.getText(node).split("=>")[0] + "=> ";
|
|
@@ -729,7 +729,7 @@ const arrowFunctionSimplify = {
|
|
|
729
729
|
create(context) {
|
|
730
730
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
731
731
|
|
|
732
|
-
const
|
|
732
|
+
const isJsxAttributeArrowHandler = (node) => {
|
|
733
733
|
let parent = node.parent;
|
|
734
734
|
|
|
735
735
|
if (parent && parent.type === "JSXExpressionContainer") {
|
|
@@ -743,7 +743,7 @@ const arrowFunctionSimplify = {
|
|
|
743
743
|
|
|
744
744
|
// Check if a call expression can be simplified to a single line
|
|
745
745
|
// e.g., dispatch(downloadEventPhoto(overlayImage)) or handler(value)
|
|
746
|
-
const
|
|
746
|
+
const canSimplifyToOneLineHandler = (expr) => {
|
|
747
747
|
if (expr.type !== "CallExpression") return false;
|
|
748
748
|
|
|
749
749
|
const { arguments: args, callee } = expr;
|
|
@@ -765,7 +765,7 @@ const arrowFunctionSimplify = {
|
|
|
765
765
|
if (arg.type === "Literal") return true;
|
|
766
766
|
|
|
767
767
|
// Nested call with simple args: dispatch(downloadPhoto(id))
|
|
768
|
-
if (arg.type === "CallExpression") return
|
|
768
|
+
if (arg.type === "CallExpression") return canSimplifyToOneLineHandler(arg);
|
|
769
769
|
|
|
770
770
|
// Member expression: dispatch(actions.doSomething)
|
|
771
771
|
if (arg.type === "MemberExpression") return true;
|
|
@@ -775,12 +775,12 @@ const arrowFunctionSimplify = {
|
|
|
775
775
|
};
|
|
776
776
|
|
|
777
777
|
// Build simplified text for a call expression
|
|
778
|
-
const
|
|
778
|
+
const buildSimplifiedTextHandler = (expr) => {
|
|
779
779
|
if (expr.type !== "CallExpression") return sourceCode.getText(expr);
|
|
780
780
|
|
|
781
781
|
const calleeName = sourceCode.getText(expr.callee);
|
|
782
782
|
const argsText = expr.arguments.map((arg) => {
|
|
783
|
-
if (arg.type === "CallExpression") return
|
|
783
|
+
if (arg.type === "CallExpression") return buildSimplifiedTextHandler(arg);
|
|
784
784
|
|
|
785
785
|
return sourceCode.getText(arg);
|
|
786
786
|
}).join(", ");
|
|
@@ -788,8 +788,8 @@ const arrowFunctionSimplify = {
|
|
|
788
788
|
return `${calleeName}(${argsText})`;
|
|
789
789
|
};
|
|
790
790
|
|
|
791
|
-
const
|
|
792
|
-
if (!
|
|
791
|
+
const checkArrowFunctionHandler = (node) => {
|
|
792
|
+
if (!isJsxAttributeArrowHandler(node)) return;
|
|
793
793
|
|
|
794
794
|
if (node.body.type !== "BlockStatement") return;
|
|
795
795
|
|
|
@@ -820,8 +820,8 @@ const arrowFunctionSimplify = {
|
|
|
820
820
|
}
|
|
821
821
|
|
|
822
822
|
// Check if multi-line expression can be simplified
|
|
823
|
-
if (
|
|
824
|
-
const simplifiedText =
|
|
823
|
+
if (canSimplifyToOneLineHandler(expression)) {
|
|
824
|
+
const simplifiedText = buildSimplifiedTextHandler(expression);
|
|
825
825
|
|
|
826
826
|
context.report({
|
|
827
827
|
fix: (fixer) => fixer.replaceText(
|
|
@@ -834,7 +834,7 @@ const arrowFunctionSimplify = {
|
|
|
834
834
|
}
|
|
835
835
|
};
|
|
836
836
|
|
|
837
|
-
return { ArrowFunctionExpression:
|
|
837
|
+
return { ArrowFunctionExpression: checkArrowFunctionHandler };
|
|
838
838
|
},
|
|
839
839
|
meta: {
|
|
840
840
|
docs: { description: "Simplify arrow functions in JSX props with single statement block body" },
|
|
@@ -938,7 +938,7 @@ const assignmentValueSameLine = {
|
|
|
938
938
|
create(context) {
|
|
939
939
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
940
940
|
|
|
941
|
-
const
|
|
941
|
+
const checkVariableDeclarationHandler = (node) => {
|
|
942
942
|
const kindToken = sourceCode.getFirstToken(node); // const, let, var
|
|
943
943
|
|
|
944
944
|
if (!kindToken) return;
|
|
@@ -1023,7 +1023,7 @@ const assignmentValueSameLine = {
|
|
|
1023
1023
|
});
|
|
1024
1024
|
};
|
|
1025
1025
|
|
|
1026
|
-
return { VariableDeclaration:
|
|
1026
|
+
return { VariableDeclaration: checkVariableDeclarationHandler };
|
|
1027
1027
|
},
|
|
1028
1028
|
meta: {
|
|
1029
1029
|
docs: { description: "Enforce assignment value on same line as equals sign" },
|
|
@@ -1055,7 +1055,7 @@ const blockStatementNewlines = {
|
|
|
1055
1055
|
create(context) {
|
|
1056
1056
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
1057
1057
|
|
|
1058
|
-
const
|
|
1058
|
+
const checkBlockStatementHandler = (node) => {
|
|
1059
1059
|
const { body } = node;
|
|
1060
1060
|
|
|
1061
1061
|
if (body.length === 0) return;
|
|
@@ -1092,7 +1092,7 @@ const blockStatementNewlines = {
|
|
|
1092
1092
|
}
|
|
1093
1093
|
};
|
|
1094
1094
|
|
|
1095
|
-
return { BlockStatement:
|
|
1095
|
+
return { BlockStatement: checkBlockStatementHandler };
|
|
1096
1096
|
},
|
|
1097
1097
|
meta: {
|
|
1098
1098
|
docs: { description: "Enforce newlines after opening brace and before closing brace in blocks" },
|
|
@@ -1472,11 +1472,11 @@ const functionNamingConvention = {
|
|
|
1472
1472
|
"handle", "on", "click", "change", "input", "submit", "press", "drag", "drop",
|
|
1473
1473
|
];
|
|
1474
1474
|
|
|
1475
|
-
const
|
|
1475
|
+
const startsWithVerbHandler = (name) => verbPrefixes.some((verb) => name.startsWith(verb));
|
|
1476
1476
|
|
|
1477
1477
|
const endsWithHandler = (name) => handlerRegex.test(name);
|
|
1478
1478
|
|
|
1479
|
-
const
|
|
1479
|
+
const checkFunctionHandler = (node) => {
|
|
1480
1480
|
let name = null;
|
|
1481
1481
|
|
|
1482
1482
|
if (node.type === "FunctionDeclaration" && node.id) {
|
|
@@ -1495,7 +1495,7 @@ const functionNamingConvention = {
|
|
|
1495
1495
|
// Skip hooks
|
|
1496
1496
|
if (/^use[A-Z]/.test(name)) return;
|
|
1497
1497
|
|
|
1498
|
-
const hasVerbPrefix =
|
|
1498
|
+
const hasVerbPrefix = startsWithVerbHandler(name);
|
|
1499
1499
|
const hasHandlerSuffix = endsWithHandler(name);
|
|
1500
1500
|
|
|
1501
1501
|
if (!hasVerbPrefix && !hasHandlerSuffix) {
|
|
@@ -1517,9 +1517,9 @@ const functionNamingConvention = {
|
|
|
1517
1517
|
};
|
|
1518
1518
|
|
|
1519
1519
|
return {
|
|
1520
|
-
ArrowFunctionExpression:
|
|
1521
|
-
FunctionDeclaration:
|
|
1522
|
-
FunctionExpression:
|
|
1520
|
+
ArrowFunctionExpression: checkFunctionHandler,
|
|
1521
|
+
FunctionDeclaration: checkFunctionHandler,
|
|
1522
|
+
FunctionExpression: checkFunctionHandler,
|
|
1523
1523
|
};
|
|
1524
1524
|
},
|
|
1525
1525
|
meta: {
|
|
@@ -1553,7 +1553,7 @@ const functionParamsPerLine = {
|
|
|
1553
1553
|
create(context) {
|
|
1554
1554
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
1555
1555
|
|
|
1556
|
-
const
|
|
1556
|
+
const getCleanParamTextHandler = (param) => {
|
|
1557
1557
|
if (param.type === "ObjectPattern") {
|
|
1558
1558
|
const props = param.properties.map((prop) => {
|
|
1559
1559
|
if (prop.type === "RestElement") {
|
|
@@ -1573,14 +1573,14 @@ const functionParamsPerLine = {
|
|
|
1573
1573
|
const elems = param.elements.map((el) => {
|
|
1574
1574
|
if (el === null) return "";
|
|
1575
1575
|
|
|
1576
|
-
return
|
|
1576
|
+
return getCleanParamTextHandler(el);
|
|
1577
1577
|
});
|
|
1578
1578
|
|
|
1579
1579
|
return `[${elems.join(", ")}]`;
|
|
1580
1580
|
}
|
|
1581
1581
|
|
|
1582
1582
|
if (param.type === "AssignmentPattern") {
|
|
1583
|
-
const leftText =
|
|
1583
|
+
const leftText = getCleanParamTextHandler(param.left);
|
|
1584
1584
|
const rightText = sourceCode.getText(param.right);
|
|
1585
1585
|
|
|
1586
1586
|
return `${leftText} = ${rightText}`;
|
|
@@ -1594,7 +1594,7 @@ const functionParamsPerLine = {
|
|
|
1594
1594
|
};
|
|
1595
1595
|
|
|
1596
1596
|
// Returns true only if any param has 2+ destructured properties
|
|
1597
|
-
const
|
|
1597
|
+
const hasComplexDestructuredParamHandler = (params) => params.some((param) => {
|
|
1598
1598
|
let pattern = param;
|
|
1599
1599
|
|
|
1600
1600
|
if (param.type === "AssignmentPattern") {
|
|
@@ -1614,7 +1614,7 @@ const functionParamsPerLine = {
|
|
|
1614
1614
|
return false;
|
|
1615
1615
|
});
|
|
1616
1616
|
|
|
1617
|
-
const
|
|
1617
|
+
const checkDestructuredParamHandler = (param, baseIndent) => {
|
|
1618
1618
|
let pattern = param;
|
|
1619
1619
|
|
|
1620
1620
|
if (param.type === "AssignmentPattern") {
|
|
@@ -1734,7 +1734,7 @@ const functionParamsPerLine = {
|
|
|
1734
1734
|
};
|
|
1735
1735
|
|
|
1736
1736
|
// Check if arrow function is a callback argument
|
|
1737
|
-
const
|
|
1737
|
+
const isCallbackArrowHandler = (node) => {
|
|
1738
1738
|
if (node.type !== "ArrowFunctionExpression") return false;
|
|
1739
1739
|
|
|
1740
1740
|
const { parent } = node;
|
|
@@ -1742,12 +1742,12 @@ const functionParamsPerLine = {
|
|
|
1742
1742
|
return parent && parent.type === "CallExpression" && parent.arguments.includes(node);
|
|
1743
1743
|
};
|
|
1744
1744
|
|
|
1745
|
-
const
|
|
1745
|
+
const checkFunctionHandler = (node) => {
|
|
1746
1746
|
const params = node.params;
|
|
1747
1747
|
|
|
1748
1748
|
if (params.length === 0) return;
|
|
1749
1749
|
|
|
1750
|
-
const isCallback =
|
|
1750
|
+
const isCallback = isCallbackArrowHandler(node);
|
|
1751
1751
|
|
|
1752
1752
|
// Find opening paren
|
|
1753
1753
|
let openParen = sourceCode.getFirstToken(node);
|
|
@@ -1765,14 +1765,14 @@ const functionParamsPerLine = {
|
|
|
1765
1765
|
|
|
1766
1766
|
const firstParam = params[0];
|
|
1767
1767
|
const isMultiLine = openParen.loc.end.line !== closeParen.loc.start.line;
|
|
1768
|
-
const paramsText = params.map((p) =>
|
|
1768
|
+
const paramsText = params.map((p) => getCleanParamTextHandler(p)).join(", ");
|
|
1769
1769
|
const currentText = sourceCode.text.slice(
|
|
1770
1770
|
openParen.range[1],
|
|
1771
1771
|
closeParen.range[0],
|
|
1772
1772
|
);
|
|
1773
1773
|
|
|
1774
1774
|
// Callback arrow functions with 2+ simple params: each param on its own line
|
|
1775
|
-
if (isCallback && params.length >= 2 && !
|
|
1775
|
+
if (isCallback && params.length >= 2 && !hasComplexDestructuredParamHandler(params)) {
|
|
1776
1776
|
// Check if all params are simple identifiers (not destructuring)
|
|
1777
1777
|
const allSimpleParams = params.every((p) => p.type === "Identifier");
|
|
1778
1778
|
|
|
@@ -1835,7 +1835,7 @@ const functionParamsPerLine = {
|
|
|
1835
1835
|
if (isCallback) return;
|
|
1836
1836
|
|
|
1837
1837
|
// 1-2 simple params without complex destructuring: keep on same line
|
|
1838
|
-
if (params.length <= 2 && !
|
|
1838
|
+
if (params.length <= 2 && !hasComplexDestructuredParamHandler(params)) {
|
|
1839
1839
|
const needsSpacingFix = !isMultiLine && params.length > 1 && currentText !== paramsText;
|
|
1840
1840
|
|
|
1841
1841
|
if (isMultiLine || needsSpacingFix) {
|
|
@@ -1907,9 +1907,9 @@ const functionParamsPerLine = {
|
|
|
1907
1907
|
};
|
|
1908
1908
|
|
|
1909
1909
|
return {
|
|
1910
|
-
ArrowFunctionExpression:
|
|
1911
|
-
FunctionDeclaration:
|
|
1912
|
-
FunctionExpression:
|
|
1910
|
+
ArrowFunctionExpression: checkFunctionHandler,
|
|
1911
|
+
FunctionDeclaration: checkFunctionHandler,
|
|
1912
|
+
FunctionExpression: checkFunctionHandler,
|
|
1913
1913
|
};
|
|
1914
1914
|
},
|
|
1915
1915
|
meta: {
|
|
@@ -2082,7 +2082,7 @@ const hookDepsPerLine = {
|
|
|
2082
2082
|
"useImperativeHandle",
|
|
2083
2083
|
];
|
|
2084
2084
|
|
|
2085
|
-
const
|
|
2085
|
+
const checkHookCallHandler = (node) => {
|
|
2086
2086
|
// Skip non-hook calls
|
|
2087
2087
|
if (node.callee.type !== "Identifier" || !hookNames.includes(node.callee.name)) {
|
|
2088
2088
|
return;
|
|
@@ -2170,7 +2170,7 @@ const hookDepsPerLine = {
|
|
|
2170
2170
|
}
|
|
2171
2171
|
};
|
|
2172
2172
|
|
|
2173
|
-
return { CallExpression:
|
|
2173
|
+
return { CallExpression: checkHookCallHandler };
|
|
2174
2174
|
},
|
|
2175
2175
|
meta: {
|
|
2176
2176
|
docs: { description: "Enforce each hook dependency on its own line when more than 2 dependencies" },
|
|
@@ -2212,7 +2212,7 @@ const ifStatementFormat = {
|
|
|
2212
2212
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
2213
2213
|
|
|
2214
2214
|
// Simple conditions that should be on single line (no logical expressions)
|
|
2215
|
-
const
|
|
2215
|
+
const isSimpleConditionHandler = (testNode) => {
|
|
2216
2216
|
const simpleTypes = [
|
|
2217
2217
|
"Identifier",
|
|
2218
2218
|
"MemberExpression",
|
|
@@ -2276,7 +2276,7 @@ const ifStatementFormat = {
|
|
|
2276
2276
|
// Check for simple conditions that span multiple lines - collapse to single line
|
|
2277
2277
|
const conditionSpansMultipleLines = openParen.loc.end.line !== closeParen.loc.start.line;
|
|
2278
2278
|
|
|
2279
|
-
if (conditionSpansMultipleLines &&
|
|
2279
|
+
if (conditionSpansMultipleLines && isSimpleConditionHandler(test)) {
|
|
2280
2280
|
const testText = sourceCode.getText(test);
|
|
2281
2281
|
|
|
2282
2282
|
context.report({
|
|
@@ -2383,16 +2383,16 @@ const multilineIfConditions = {
|
|
|
2383
2383
|
const collectOperandsHandler = (node) => {
|
|
2384
2384
|
const operands = [];
|
|
2385
2385
|
|
|
2386
|
-
const
|
|
2386
|
+
const collectHelperHandler = (n) => {
|
|
2387
2387
|
if (n.type === "LogicalExpression" && !isParenthesizedHandler(n)) {
|
|
2388
|
-
|
|
2389
|
-
|
|
2388
|
+
collectHelperHandler(n.left);
|
|
2389
|
+
collectHelperHandler(n.right);
|
|
2390
2390
|
} else {
|
|
2391
2391
|
operands.push(n);
|
|
2392
2392
|
}
|
|
2393
2393
|
};
|
|
2394
2394
|
|
|
2395
|
-
|
|
2395
|
+
collectHelperHandler(node);
|
|
2396
2396
|
|
|
2397
2397
|
return operands;
|
|
2398
2398
|
};
|
|
@@ -2711,7 +2711,7 @@ const exportFormat = {
|
|
|
2711
2711
|
create(context) {
|
|
2712
2712
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
2713
2713
|
|
|
2714
|
-
const
|
|
2714
|
+
const checkExportHandler = (node) => {
|
|
2715
2715
|
const specifiers = node.specifiers;
|
|
2716
2716
|
|
|
2717
2717
|
if (specifiers.length === 0) return;
|
|
@@ -2812,7 +2812,7 @@ const exportFormat = {
|
|
|
2812
2812
|
}
|
|
2813
2813
|
};
|
|
2814
2814
|
|
|
2815
|
-
return { ExportNamedDeclaration:
|
|
2815
|
+
return { ExportNamedDeclaration: checkExportHandler };
|
|
2816
2816
|
},
|
|
2817
2817
|
meta: {
|
|
2818
2818
|
docs: { description: "Format exports: export { on same line, collapse 1-3 specifiers, multiline for 4+" },
|
|
@@ -2849,7 +2849,7 @@ const importFormat = {
|
|
|
2849
2849
|
create(context) {
|
|
2850
2850
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
2851
2851
|
|
|
2852
|
-
const
|
|
2852
|
+
const checkImportHandler = (node) => {
|
|
2853
2853
|
const importToken = sourceCode.getFirstToken(node);
|
|
2854
2854
|
const namedSpecifiers = node.specifiers.filter((s) => s.type === "ImportSpecifier");
|
|
2855
2855
|
const defaultSpecifier = node.specifiers.find((s) => s.type === "ImportDefaultSpecifier");
|
|
@@ -2931,7 +2931,7 @@ const importFormat = {
|
|
|
2931
2931
|
}
|
|
2932
2932
|
};
|
|
2933
2933
|
|
|
2934
|
-
return { ImportDeclaration:
|
|
2934
|
+
return { ImportDeclaration: checkImportHandler };
|
|
2935
2935
|
},
|
|
2936
2936
|
meta: {
|
|
2937
2937
|
docs: { description: "Format imports: import { on same line, } from on same line, collapse 1-3 specifiers" },
|
|
@@ -3052,7 +3052,7 @@ const moduleIndexExports = {
|
|
|
3052
3052
|
"*.spec.jsx",
|
|
3053
3053
|
];
|
|
3054
3054
|
|
|
3055
|
-
const
|
|
3055
|
+
const shouldIgnoreHandler = (name) => ignorePatterns.some((pattern) => {
|
|
3056
3056
|
if (pattern.includes("*")) {
|
|
3057
3057
|
const regex = new RegExp("^" + pattern.replace(/\*/g, ".*") + "$");
|
|
3058
3058
|
|
|
@@ -3062,7 +3062,7 @@ const moduleIndexExports = {
|
|
|
3062
3062
|
return name === pattern;
|
|
3063
3063
|
});
|
|
3064
3064
|
|
|
3065
|
-
const
|
|
3065
|
+
const getExportedSourcesHandler = (node) => {
|
|
3066
3066
|
const exportedSources = new Set();
|
|
3067
3067
|
const importedNames = new Map();
|
|
3068
3068
|
|
|
@@ -3118,7 +3118,7 @@ const moduleIndexExports = {
|
|
|
3118
3118
|
return exportedSources;
|
|
3119
3119
|
};
|
|
3120
3120
|
|
|
3121
|
-
const
|
|
3121
|
+
const normalizeModuleNameHandler = (name) => {
|
|
3122
3122
|
// Remove file extension
|
|
3123
3123
|
let normalized = name.replace(/\.(js|jsx|ts|tsx)$/, "");
|
|
3124
3124
|
|
|
@@ -3126,7 +3126,7 @@ const moduleIndexExports = {
|
|
|
3126
3126
|
return normalized;
|
|
3127
3127
|
};
|
|
3128
3128
|
|
|
3129
|
-
const
|
|
3129
|
+
const checkIndexFileExportsHandler = (programNode, dirPath, folderName) => {
|
|
3130
3130
|
// Get all items in the directory
|
|
3131
3131
|
let items;
|
|
3132
3132
|
|
|
@@ -3138,7 +3138,7 @@ const moduleIndexExports = {
|
|
|
3138
3138
|
|
|
3139
3139
|
// Filter out ignored items
|
|
3140
3140
|
const moduleItems = items.filter((item) => {
|
|
3141
|
-
if (
|
|
3141
|
+
if (shouldIgnoreHandler(item)) return false;
|
|
3142
3142
|
|
|
3143
3143
|
const itemPath = nodePath.join(dirPath, item);
|
|
3144
3144
|
|
|
@@ -3158,11 +3158,11 @@ const moduleIndexExports = {
|
|
|
3158
3158
|
if (moduleItems.length === 0) return;
|
|
3159
3159
|
|
|
3160
3160
|
// Get all sources that are being exported
|
|
3161
|
-
const exportedSources =
|
|
3161
|
+
const exportedSources = getExportedSourcesHandler(programNode);
|
|
3162
3162
|
|
|
3163
3163
|
// Check each module item
|
|
3164
3164
|
moduleItems.forEach((item) => {
|
|
3165
|
-
const itemName =
|
|
3165
|
+
const itemName = normalizeModuleNameHandler(item);
|
|
3166
3166
|
const itemPath = nodePath.join(dirPath, item);
|
|
3167
3167
|
const isDirectory = fs.statSync(itemPath).isDirectory();
|
|
3168
3168
|
|
|
@@ -3212,7 +3212,7 @@ const moduleIndexExports = {
|
|
|
3212
3212
|
if (moduleFolders.includes(folderName)) {
|
|
3213
3213
|
const dirPath = nodePath.dirname(filename);
|
|
3214
3214
|
|
|
3215
|
-
|
|
3215
|
+
checkIndexFileExportsHandler(
|
|
3216
3216
|
node,
|
|
3217
3217
|
dirPath,
|
|
3218
3218
|
folderName,
|
|
@@ -3255,7 +3255,7 @@ const moduleIndexExports = {
|
|
|
3255
3255
|
if (moduleFolders.includes(parentFolder)) {
|
|
3256
3256
|
const dirPath = nodePath.dirname(filename);
|
|
3257
3257
|
|
|
3258
|
-
|
|
3258
|
+
checkIndexFileExportsHandler(
|
|
3259
3259
|
node,
|
|
3260
3260
|
dirPath,
|
|
3261
3261
|
`${parentFolder}/${subFolder}`,
|
|
@@ -3312,7 +3312,7 @@ const jsxChildrenOnNewLine = {
|
|
|
3312
3312
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
3313
3313
|
|
|
3314
3314
|
// Check if expression is simple (identifier, literal, or simple member expression)
|
|
3315
|
-
const
|
|
3315
|
+
const isSimpleExpressionHandler = (expr) => {
|
|
3316
3316
|
if (!expr) return true;
|
|
3317
3317
|
|
|
3318
3318
|
if (expr.type === "Identifier") return true;
|
|
@@ -3325,16 +3325,16 @@ const jsxChildrenOnNewLine = {
|
|
|
3325
3325
|
};
|
|
3326
3326
|
|
|
3327
3327
|
// Check if child is simple (text or simple expression like {variable})
|
|
3328
|
-
const
|
|
3328
|
+
const isSimpleChildHandler = (child) => {
|
|
3329
3329
|
if (child.type === "JSXText") return true;
|
|
3330
3330
|
if (child.type === "JSXExpressionContainer") {
|
|
3331
|
-
return
|
|
3331
|
+
return isSimpleExpressionHandler(child.expression);
|
|
3332
3332
|
}
|
|
3333
3333
|
|
|
3334
3334
|
return false;
|
|
3335
3335
|
};
|
|
3336
3336
|
|
|
3337
|
-
const
|
|
3337
|
+
const checkJSXChildrenHandler = (node, openingTag, closingTag) => {
|
|
3338
3338
|
const { children } = node;
|
|
3339
3339
|
|
|
3340
3340
|
// Skip self-closing elements
|
|
@@ -3353,7 +3353,7 @@ const jsxChildrenOnNewLine = {
|
|
|
3353
3353
|
|
|
3354
3354
|
// Allow elements that are entirely on a single line with only simple children (text or {variable})
|
|
3355
3355
|
const elementIsOnSingleLine = openingTag.loc.start.line === closingTag.loc.end.line;
|
|
3356
|
-
const hasOnlySimpleChildren = significantChildren.every(
|
|
3356
|
+
const hasOnlySimpleChildren = significantChildren.every(isSimpleChildHandler);
|
|
3357
3357
|
|
|
3358
3358
|
if (elementIsOnSingleLine && hasOnlySimpleChildren) {
|
|
3359
3359
|
// Entire element on one line with only simple children - OK
|
|
@@ -3361,7 +3361,7 @@ const jsxChildrenOnNewLine = {
|
|
|
3361
3361
|
}
|
|
3362
3362
|
|
|
3363
3363
|
// Allow simple inline elements with single simple child
|
|
3364
|
-
const hasSingleSimpleChild = significantChildren.length === 1 &&
|
|
3364
|
+
const hasSingleSimpleChild = significantChildren.length === 1 && isSimpleChildHandler(significantChildren[0]);
|
|
3365
3365
|
|
|
3366
3366
|
if (hasSingleSimpleChild) {
|
|
3367
3367
|
// This is a simple inline element - don't require new lines
|
|
@@ -3420,17 +3420,17 @@ const jsxChildrenOnNewLine = {
|
|
|
3420
3420
|
}
|
|
3421
3421
|
};
|
|
3422
3422
|
|
|
3423
|
-
const
|
|
3424
|
-
|
|
3423
|
+
const checkJSXElementHandler = (node) => {
|
|
3424
|
+
checkJSXChildrenHandler(node, node.openingElement, node.closingElement);
|
|
3425
3425
|
};
|
|
3426
3426
|
|
|
3427
|
-
const
|
|
3428
|
-
|
|
3427
|
+
const checkJSXFragmentHandler = (node) => {
|
|
3428
|
+
checkJSXChildrenHandler(node, node.openingFragment, node.closingFragment);
|
|
3429
3429
|
};
|
|
3430
3430
|
|
|
3431
3431
|
return {
|
|
3432
|
-
JSXElement:
|
|
3433
|
-
JSXFragment:
|
|
3432
|
+
JSXElement: checkJSXElementHandler,
|
|
3433
|
+
JSXFragment: checkJSXFragmentHandler,
|
|
3434
3434
|
};
|
|
3435
3435
|
},
|
|
3436
3436
|
meta: {
|
|
@@ -3462,7 +3462,7 @@ const jsxClosingBracketSpacing = {
|
|
|
3462
3462
|
create(context) {
|
|
3463
3463
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
3464
3464
|
|
|
3465
|
-
const
|
|
3465
|
+
const checkOpeningElementHandler = (node) => {
|
|
3466
3466
|
const lastToken = sourceCode.getLastToken(node);
|
|
3467
3467
|
|
|
3468
3468
|
if (!lastToken) return;
|
|
@@ -3495,8 +3495,8 @@ const jsxClosingBracketSpacing = {
|
|
|
3495
3495
|
};
|
|
3496
3496
|
|
|
3497
3497
|
return {
|
|
3498
|
-
JSXOpeningElement:
|
|
3499
|
-
JSXClosingElement:
|
|
3498
|
+
JSXOpeningElement: checkOpeningElementHandler,
|
|
3499
|
+
JSXClosingElement: checkOpeningElementHandler,
|
|
3500
3500
|
};
|
|
3501
3501
|
},
|
|
3502
3502
|
meta: {
|
|
@@ -3529,7 +3529,7 @@ const jsxElementChildNewLine = {
|
|
|
3529
3529
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
3530
3530
|
|
|
3531
3531
|
// Check if expression is simple (identifier, literal, or simple member expression)
|
|
3532
|
-
const
|
|
3532
|
+
const isSimpleExpressionHandler = (expr) => {
|
|
3533
3533
|
if (!expr) return true;
|
|
3534
3534
|
|
|
3535
3535
|
if (expr.type === "Identifier") return true;
|
|
@@ -3542,14 +3542,14 @@ const jsxElementChildNewLine = {
|
|
|
3542
3542
|
};
|
|
3543
3543
|
|
|
3544
3544
|
// Check if child is a complex JSX child (not simple text or expression)
|
|
3545
|
-
const
|
|
3545
|
+
const isComplexJsxChildHandler = (child) => {
|
|
3546
3546
|
if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
3547
3547
|
return true;
|
|
3548
3548
|
}
|
|
3549
3549
|
|
|
3550
3550
|
// JSXExpressionContainer with complex expression (not simple variable)
|
|
3551
3551
|
if (child.type === "JSXExpressionContainer") {
|
|
3552
|
-
return !
|
|
3552
|
+
return !isSimpleExpressionHandler(child.expression);
|
|
3553
3553
|
}
|
|
3554
3554
|
|
|
3555
3555
|
return false;
|
|
@@ -3566,7 +3566,7 @@ const jsxElementChildNewLine = {
|
|
|
3566
3566
|
const { children } = node;
|
|
3567
3567
|
|
|
3568
3568
|
// Find complex JSX element children (not text, not simple expressions)
|
|
3569
|
-
const jsxChildren = children.filter(
|
|
3569
|
+
const jsxChildren = children.filter(isComplexJsxChildHandler);
|
|
3570
3570
|
|
|
3571
3571
|
if (jsxChildren.length === 0) return;
|
|
3572
3572
|
|
|
@@ -3633,7 +3633,7 @@ const jsxLogicalExpressionSimplify = {
|
|
|
3633
3633
|
create(context) {
|
|
3634
3634
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
3635
3635
|
|
|
3636
|
-
const
|
|
3636
|
+
const checkLogicalExpressionHandler = (node) => {
|
|
3637
3637
|
if (node.operator !== "&&" && node.operator !== "||") return;
|
|
3638
3638
|
|
|
3639
3639
|
const {
|
|
@@ -3662,7 +3662,7 @@ const jsxLogicalExpressionSimplify = {
|
|
|
3662
3662
|
});
|
|
3663
3663
|
};
|
|
3664
3664
|
|
|
3665
|
-
return { LogicalExpression:
|
|
3665
|
+
return { LogicalExpression: checkLogicalExpressionHandler };
|
|
3666
3666
|
},
|
|
3667
3667
|
meta: {
|
|
3668
3668
|
docs: { description: "Simplify logical expressions in JSX when right side is single-line" },
|
|
@@ -3703,7 +3703,7 @@ const jsxParenthesesPosition = {
|
|
|
3703
3703
|
create(context) {
|
|
3704
3704
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
3705
3705
|
|
|
3706
|
-
const
|
|
3706
|
+
const checkArrowFunctionHandler = (node) => {
|
|
3707
3707
|
// Only check arrow functions that return JSX wrapped in parentheses
|
|
3708
3708
|
if (node.body.type !== "JSXElement" && node.body.type !== "JSXFragment") return;
|
|
3709
3709
|
|
|
@@ -3794,7 +3794,7 @@ const jsxParenthesesPosition = {
|
|
|
3794
3794
|
}
|
|
3795
3795
|
};
|
|
3796
3796
|
|
|
3797
|
-
const
|
|
3797
|
+
const checkPropertyHandler = (node) => {
|
|
3798
3798
|
if (!node.value) return;
|
|
3799
3799
|
if (node.value.type !== "JSXElement" && node.value.type !== "JSXFragment") return;
|
|
3800
3800
|
|
|
@@ -3863,8 +3863,8 @@ const jsxParenthesesPosition = {
|
|
|
3863
3863
|
};
|
|
3864
3864
|
|
|
3865
3865
|
return {
|
|
3866
|
-
ArrowFunctionExpression:
|
|
3867
|
-
Property:
|
|
3866
|
+
ArrowFunctionExpression: checkArrowFunctionHandler,
|
|
3867
|
+
Property: checkPropertyHandler,
|
|
3868
3868
|
};
|
|
3869
3869
|
},
|
|
3870
3870
|
meta: {
|
|
@@ -3988,7 +3988,7 @@ const jsxSimpleElementOneLine = {
|
|
|
3988
3988
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
3989
3989
|
|
|
3990
3990
|
// Check if an expression is simple (just an identifier or literal)
|
|
3991
|
-
const
|
|
3991
|
+
const isSimpleExpressionHandler = (node) => {
|
|
3992
3992
|
if (!node) return false;
|
|
3993
3993
|
|
|
3994
3994
|
if (node.type === "Identifier") return true;
|
|
@@ -4002,13 +4002,13 @@ const jsxSimpleElementOneLine = {
|
|
|
4002
4002
|
};
|
|
4003
4003
|
|
|
4004
4004
|
// Check if child is simple (text or simple expression)
|
|
4005
|
-
const
|
|
4005
|
+
const isSimpleChildHandler = (child) => {
|
|
4006
4006
|
if (child.type === "JSXText") {
|
|
4007
4007
|
return child.value.trim().length > 0;
|
|
4008
4008
|
}
|
|
4009
4009
|
|
|
4010
4010
|
if (child.type === "JSXExpressionContainer") {
|
|
4011
|
-
return
|
|
4011
|
+
return isSimpleExpressionHandler(child.expression);
|
|
4012
4012
|
}
|
|
4013
4013
|
|
|
4014
4014
|
return false;
|
|
@@ -4041,7 +4041,7 @@ const jsxSimpleElementOneLine = {
|
|
|
4041
4041
|
|
|
4042
4042
|
const child = significantChildren[0];
|
|
4043
4043
|
|
|
4044
|
-
if (!
|
|
4044
|
+
if (!isSimpleChildHandler(child)) return;
|
|
4045
4045
|
|
|
4046
4046
|
// Check if opening tag itself is simple (single line, not too many attributes)
|
|
4047
4047
|
if (openingTag.loc.start.line !== openingTag.loc.end.line) return;
|
|
@@ -4091,7 +4091,7 @@ const jsxStringValueTrim = {
|
|
|
4091
4091
|
create(context) {
|
|
4092
4092
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
4093
4093
|
|
|
4094
|
-
const
|
|
4094
|
+
const checkJSXAttributeHandler = (node) => {
|
|
4095
4095
|
if (!node.value || node.value.type !== "Literal" || typeof node.value.value !== "string") return;
|
|
4096
4096
|
|
|
4097
4097
|
const value = node.value.value;
|
|
@@ -4112,7 +4112,7 @@ const jsxStringValueTrim = {
|
|
|
4112
4112
|
}
|
|
4113
4113
|
};
|
|
4114
4114
|
|
|
4115
|
-
return { JSXAttribute:
|
|
4115
|
+
return { JSXAttribute: checkJSXAttributeHandler };
|
|
4116
4116
|
},
|
|
4117
4117
|
meta: {
|
|
4118
4118
|
docs: { description: "Disallow leading/trailing whitespace in JSX string values" },
|
|
@@ -4150,7 +4150,7 @@ const jsxTernaryFormat = {
|
|
|
4150
4150
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
4151
4151
|
|
|
4152
4152
|
// Helper to get indentation of a line
|
|
4153
|
-
const
|
|
4153
|
+
const getIndentHandler = (node) => {
|
|
4154
4154
|
const line = sourceCode.lines[node.loc.start.line - 1];
|
|
4155
4155
|
const match = line.match(/^(\s*)/);
|
|
4156
4156
|
|
|
@@ -4158,14 +4158,14 @@ const jsxTernaryFormat = {
|
|
|
4158
4158
|
};
|
|
4159
4159
|
|
|
4160
4160
|
// Check if JSX element is simple (single line)
|
|
4161
|
-
const
|
|
4161
|
+
const isSimpleJsxHandler = (jsxNode) => {
|
|
4162
4162
|
if (jsxNode.type !== "JSXElement" && jsxNode.type !== "JSXFragment") return false;
|
|
4163
4163
|
|
|
4164
4164
|
return jsxNode.loc.start.line === jsxNode.loc.end.line;
|
|
4165
4165
|
};
|
|
4166
4166
|
|
|
4167
4167
|
// Check if a node is wrapped in unnecessary parentheses
|
|
4168
|
-
const
|
|
4168
|
+
const hasUnnecessaryParensHandler = (jsxNode) => {
|
|
4169
4169
|
const tokenBefore = sourceCode.getTokenBefore(jsxNode);
|
|
4170
4170
|
const tokenAfter = sourceCode.getTokenAfter(jsxNode);
|
|
4171
4171
|
|
|
@@ -4190,10 +4190,10 @@ const jsxTernaryFormat = {
|
|
|
4190
4190
|
|
|
4191
4191
|
if (!isConsequentJsx && !isAlternateJsx) return;
|
|
4192
4192
|
|
|
4193
|
-
const consequentSimple =
|
|
4194
|
-
const alternateSimple =
|
|
4193
|
+
const consequentSimple = isSimpleJsxHandler(consequent);
|
|
4194
|
+
const alternateSimple = isSimpleJsxHandler(alternate);
|
|
4195
4195
|
|
|
4196
|
-
const baseIndent =
|
|
4196
|
+
const baseIndent = getIndentHandler(node);
|
|
4197
4197
|
const contentIndent = baseIndent + " ";
|
|
4198
4198
|
|
|
4199
4199
|
// Check 0: Condition should be on same line as opening {
|
|
@@ -4232,7 +4232,7 @@ const jsxTernaryFormat = {
|
|
|
4232
4232
|
const closeBrace = sourceCode.getLastToken(parent);
|
|
4233
4233
|
|
|
4234
4234
|
// Check for unnecessary parentheses around simple JSX
|
|
4235
|
-
if (consequentSimple &&
|
|
4235
|
+
if (consequentSimple && hasUnnecessaryParensHandler(consequent)) {
|
|
4236
4236
|
const openParen = sourceCode.getTokenBefore(consequent);
|
|
4237
4237
|
const closeParen = sourceCode.getTokenAfter(consequent);
|
|
4238
4238
|
|
|
@@ -4246,7 +4246,7 @@ const jsxTernaryFormat = {
|
|
|
4246
4246
|
});
|
|
4247
4247
|
}
|
|
4248
4248
|
|
|
4249
|
-
if (alternateSimple &&
|
|
4249
|
+
if (alternateSimple && hasUnnecessaryParensHandler(alternate)) {
|
|
4250
4250
|
const openParen = sourceCode.getTokenBefore(alternate);
|
|
4251
4251
|
const closeParen = sourceCode.getTokenAfter(alternate);
|
|
4252
4252
|
|
|
@@ -4852,7 +4852,7 @@ const multilineArgumentNewline = {
|
|
|
4852
4852
|
"useInsertionEffect",
|
|
4853
4853
|
];
|
|
4854
4854
|
|
|
4855
|
-
const
|
|
4855
|
+
const isReactHookHandler = (node) => {
|
|
4856
4856
|
if (node.callee.type === "Identifier") {
|
|
4857
4857
|
return reactHooks.includes(node.callee.name);
|
|
4858
4858
|
}
|
|
@@ -4860,11 +4860,11 @@ const multilineArgumentNewline = {
|
|
|
4860
4860
|
return false;
|
|
4861
4861
|
};
|
|
4862
4862
|
|
|
4863
|
-
const
|
|
4863
|
+
const hasMultilineArgHandler = (args) => args.some((arg) => arg.loc.start.line !== arg.loc.end.line);
|
|
4864
4864
|
|
|
4865
|
-
const
|
|
4865
|
+
const checkCallExpressionHandler = (node) => {
|
|
4866
4866
|
// Skip React hooks
|
|
4867
|
-
if (
|
|
4867
|
+
if (isReactHookHandler(node)) return;
|
|
4868
4868
|
|
|
4869
4869
|
const args = node.arguments;
|
|
4870
4870
|
|
|
@@ -4886,7 +4886,7 @@ const multilineArgumentNewline = {
|
|
|
4886
4886
|
&& args[0].body.type === "ObjectExpression") return;
|
|
4887
4887
|
|
|
4888
4888
|
// Check if any argument is multiline
|
|
4889
|
-
if (!
|
|
4889
|
+
if (!hasMultilineArgHandler(args)) return;
|
|
4890
4890
|
|
|
4891
4891
|
const openParen = sourceCode.getTokenAfter(
|
|
4892
4892
|
node.callee,
|
|
@@ -4951,7 +4951,7 @@ const multilineArgumentNewline = {
|
|
|
4951
4951
|
}
|
|
4952
4952
|
};
|
|
4953
4953
|
|
|
4954
|
-
return { CallExpression:
|
|
4954
|
+
return { CallExpression: checkCallExpressionHandler };
|
|
4955
4955
|
},
|
|
4956
4956
|
meta: {
|
|
4957
4957
|
docs: { description: "Enforce newlines for function calls with multiline arguments" },
|
|
@@ -5202,18 +5202,18 @@ const noEmptyLinesInFunctionCalls = {
|
|
|
5202
5202
|
create(context) {
|
|
5203
5203
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
5204
5204
|
|
|
5205
|
-
const
|
|
5205
|
+
const isSimpleArgHandler = (arg) => [
|
|
5206
5206
|
"Literal",
|
|
5207
5207
|
"Identifier",
|
|
5208
5208
|
"MemberExpression",
|
|
5209
5209
|
"TemplateLiteral",
|
|
5210
5210
|
].includes(arg.type);
|
|
5211
5211
|
|
|
5212
|
-
const
|
|
5212
|
+
const isSingleLineArgHandler = (arg) => arg.loc.start.line === arg.loc.end.line;
|
|
5213
5213
|
|
|
5214
|
-
const
|
|
5214
|
+
const isSinglePropertyObjectHandler = (arg) => arg.type === "ObjectExpression" && arg.properties.length === 1;
|
|
5215
5215
|
|
|
5216
|
-
const
|
|
5216
|
+
const getCleanObjectTextHandler = (arg) => {
|
|
5217
5217
|
const prop = arg.properties[0];
|
|
5218
5218
|
|
|
5219
5219
|
if (prop.type === "SpreadElement") return sourceCode.getText(arg);
|
|
@@ -5224,7 +5224,7 @@ const noEmptyLinesInFunctionCalls = {
|
|
|
5224
5224
|
return `{ ${keyText}: ${valueText} }`;
|
|
5225
5225
|
};
|
|
5226
5226
|
|
|
5227
|
-
const
|
|
5227
|
+
const checkCallExpressionHandler = (node) => {
|
|
5228
5228
|
const args = node.arguments;
|
|
5229
5229
|
|
|
5230
5230
|
if (args.length === 0) return;
|
|
@@ -5241,10 +5241,10 @@ const noEmptyLinesInFunctionCalls = {
|
|
|
5241
5241
|
const lastArg = args[args.length - 1];
|
|
5242
5242
|
|
|
5243
5243
|
// Single simple argument on different line should be collapsed
|
|
5244
|
-
if (args.length === 1 && (
|
|
5244
|
+
if (args.length === 1 && (isSimpleArgHandler(firstArg) || isSinglePropertyObjectHandler(firstArg)) && isSingleLineArgHandler(firstArg)) {
|
|
5245
5245
|
if (firstArg.loc.start.line !== openParen.loc.end.line) {
|
|
5246
|
-
const argText =
|
|
5247
|
-
?
|
|
5246
|
+
const argText = isSinglePropertyObjectHandler(firstArg)
|
|
5247
|
+
? getCleanObjectTextHandler(firstArg)
|
|
5248
5248
|
: sourceCode.getText(firstArg);
|
|
5249
5249
|
|
|
5250
5250
|
context.report({
|
|
@@ -5304,7 +5304,7 @@ const noEmptyLinesInFunctionCalls = {
|
|
|
5304
5304
|
}
|
|
5305
5305
|
};
|
|
5306
5306
|
|
|
5307
|
-
return { CallExpression:
|
|
5307
|
+
return { CallExpression: checkCallExpressionHandler };
|
|
5308
5308
|
},
|
|
5309
5309
|
meta: {
|
|
5310
5310
|
docs: { description: "Disallow empty lines in function calls and enforce single simple argument on same line" },
|
|
@@ -5340,7 +5340,7 @@ const noEmptyLinesInFunctionParams = {
|
|
|
5340
5340
|
create(context) {
|
|
5341
5341
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
5342
5342
|
|
|
5343
|
-
const
|
|
5343
|
+
const checkFunctionHandler = (node) => {
|
|
5344
5344
|
const params = node.params;
|
|
5345
5345
|
|
|
5346
5346
|
if (params.length === 0) return;
|
|
@@ -5406,9 +5406,9 @@ const noEmptyLinesInFunctionParams = {
|
|
|
5406
5406
|
};
|
|
5407
5407
|
|
|
5408
5408
|
return {
|
|
5409
|
-
ArrowFunctionExpression:
|
|
5410
|
-
FunctionDeclaration:
|
|
5411
|
-
FunctionExpression:
|
|
5409
|
+
ArrowFunctionExpression: checkFunctionHandler,
|
|
5410
|
+
FunctionDeclaration: checkFunctionHandler,
|
|
5411
|
+
FunctionExpression: checkFunctionHandler,
|
|
5412
5412
|
};
|
|
5413
5413
|
},
|
|
5414
5414
|
meta: {
|
|
@@ -5447,7 +5447,7 @@ const noEmptyLinesInJsx = {
|
|
|
5447
5447
|
create(context) {
|
|
5448
5448
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
5449
5449
|
|
|
5450
|
-
const
|
|
5450
|
+
const checkJSXElementHandler = (node) => {
|
|
5451
5451
|
const {
|
|
5452
5452
|
children,
|
|
5453
5453
|
closingElement,
|
|
@@ -5489,9 +5489,9 @@ const noEmptyLinesInJsx = {
|
|
|
5489
5489
|
}
|
|
5490
5490
|
};
|
|
5491
5491
|
|
|
5492
|
-
const
|
|
5492
|
+
const isSingleLineAttrHandler = (attr) => attr.loc.start.line === attr.loc.end.line;
|
|
5493
5493
|
|
|
5494
|
-
const
|
|
5494
|
+
const checkJSXOpeningElementHandler = (node) => {
|
|
5495
5495
|
const {
|
|
5496
5496
|
attributes,
|
|
5497
5497
|
name,
|
|
@@ -5505,7 +5505,7 @@ const noEmptyLinesInJsx = {
|
|
|
5505
5505
|
const firstAttr = attributes[0];
|
|
5506
5506
|
const lastAttr = attributes[attributes.length - 1];
|
|
5507
5507
|
const isSingleLineElement = elementName.loc.start.line === closingBracket.loc.end.line;
|
|
5508
|
-
const hasSimpleProps = attributes.length === 1 &&
|
|
5508
|
+
const hasSimpleProps = attributes.length === 1 && isSingleLineAttrHandler(firstAttr);
|
|
5509
5509
|
|
|
5510
5510
|
// Check for no space before closing bracket in non-self-closing element
|
|
5511
5511
|
if (!node.selfClosing && hasSimpleProps && isSingleLineElement) {
|
|
@@ -5531,7 +5531,7 @@ const noEmptyLinesInJsx = {
|
|
|
5531
5531
|
}
|
|
5532
5532
|
|
|
5533
5533
|
// Single simple prop on different line should be collapsed
|
|
5534
|
-
if (attributes.length === 1 &&
|
|
5534
|
+
if (attributes.length === 1 && isSingleLineAttrHandler(firstAttr)) {
|
|
5535
5535
|
if (firstAttr.loc.start.line !== elementName.loc.end.line) {
|
|
5536
5536
|
const attrText = sourceCode.getText(firstAttr);
|
|
5537
5537
|
const isSelfClosing = node.selfClosing;
|
|
@@ -5614,7 +5614,7 @@ const noEmptyLinesInJsx = {
|
|
|
5614
5614
|
}
|
|
5615
5615
|
};
|
|
5616
5616
|
|
|
5617
|
-
const
|
|
5617
|
+
const checkReturnStatementHandler = (node) => {
|
|
5618
5618
|
const arg = node.argument;
|
|
5619
5619
|
|
|
5620
5620
|
if (!arg) return;
|
|
@@ -5675,7 +5675,7 @@ const noEmptyLinesInJsx = {
|
|
|
5675
5675
|
}
|
|
5676
5676
|
};
|
|
5677
5677
|
|
|
5678
|
-
const
|
|
5678
|
+
const checkArrowFunctionHandler = (node) => {
|
|
5679
5679
|
if (!node.body || node.body.type === "BlockStatement") return;
|
|
5680
5680
|
|
|
5681
5681
|
const body = node.body;
|
|
@@ -5715,10 +5715,10 @@ const noEmptyLinesInJsx = {
|
|
|
5715
5715
|
};
|
|
5716
5716
|
|
|
5717
5717
|
return {
|
|
5718
|
-
ArrowFunctionExpression:
|
|
5719
|
-
JSXElement:
|
|
5720
|
-
JSXOpeningElement:
|
|
5721
|
-
ReturnStatement:
|
|
5718
|
+
ArrowFunctionExpression: checkArrowFunctionHandler,
|
|
5719
|
+
JSXElement: checkJSXElementHandler,
|
|
5720
|
+
JSXOpeningElement: checkJSXOpeningElementHandler,
|
|
5721
|
+
ReturnStatement: checkReturnStatementHandler,
|
|
5722
5722
|
};
|
|
5723
5723
|
},
|
|
5724
5724
|
meta: {
|
|
@@ -5755,7 +5755,7 @@ const noEmptyLinesInObjects = {
|
|
|
5755
5755
|
create(context) {
|
|
5756
5756
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
5757
5757
|
|
|
5758
|
-
const
|
|
5758
|
+
const checkObjectHandler = (node) => {
|
|
5759
5759
|
const { properties } = node;
|
|
5760
5760
|
|
|
5761
5761
|
if (properties.length === 0) return;
|
|
@@ -5814,8 +5814,8 @@ const noEmptyLinesInObjects = {
|
|
|
5814
5814
|
};
|
|
5815
5815
|
|
|
5816
5816
|
return {
|
|
5817
|
-
ObjectExpression:
|
|
5818
|
-
ObjectPattern:
|
|
5817
|
+
ObjectExpression: checkObjectHandler,
|
|
5818
|
+
ObjectPattern: checkObjectHandler,
|
|
5819
5819
|
};
|
|
5820
5820
|
},
|
|
5821
5821
|
meta: {
|
|
@@ -5964,7 +5964,7 @@ const objectPropertyPerLine = {
|
|
|
5964
5964
|
create(context) {
|
|
5965
5965
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
5966
5966
|
|
|
5967
|
-
const
|
|
5967
|
+
const checkObjectHandler = (node) => {
|
|
5968
5968
|
const { properties } = node;
|
|
5969
5969
|
|
|
5970
5970
|
if (properties.length < 2) return;
|
|
@@ -5993,8 +5993,8 @@ const objectPropertyPerLine = {
|
|
|
5993
5993
|
};
|
|
5994
5994
|
|
|
5995
5995
|
return {
|
|
5996
|
-
ObjectExpression:
|
|
5997
|
-
ObjectPattern:
|
|
5996
|
+
ObjectExpression: checkObjectHandler,
|
|
5997
|
+
ObjectPattern: checkObjectHandler,
|
|
5998
5998
|
};
|
|
5999
5999
|
},
|
|
6000
6000
|
meta: {
|
|
@@ -6091,7 +6091,7 @@ const objectPropertyValueFormat = {
|
|
|
6091
6091
|
create(context) {
|
|
6092
6092
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
6093
6093
|
|
|
6094
|
-
const
|
|
6094
|
+
const checkPropertyHandler = (node) => {
|
|
6095
6095
|
// Skip shorthand properties (no colon)
|
|
6096
6096
|
if (node.shorthand) return;
|
|
6097
6097
|
|
|
@@ -6139,7 +6139,7 @@ const objectPropertyValueFormat = {
|
|
|
6139
6139
|
const isWrappedInParens = tokenAfterColon && tokenAfterColon.value === "(";
|
|
6140
6140
|
|
|
6141
6141
|
// Check if JSX is simple (single element with only text/whitespace children, no attributes)
|
|
6142
|
-
const
|
|
6142
|
+
const isSimpleJsxHandler = (jsxNode) => {
|
|
6143
6143
|
if (jsxNode.type === "JSXFragment") return false;
|
|
6144
6144
|
|
|
6145
6145
|
// Has attributes - not simple
|
|
@@ -6167,7 +6167,7 @@ const objectPropertyValueFormat = {
|
|
|
6167
6167
|
};
|
|
6168
6168
|
|
|
6169
6169
|
// Build collapsed JSX string for simple elements
|
|
6170
|
-
const
|
|
6170
|
+
const getCollapsedJsxHandler = (jsxNode) => {
|
|
6171
6171
|
const tagName = jsxNode.openingElement.name.name;
|
|
6172
6172
|
const children = jsxNode.children || [];
|
|
6173
6173
|
const textContent = children
|
|
@@ -6183,10 +6183,10 @@ const objectPropertyValueFormat = {
|
|
|
6183
6183
|
return `<${tagName} />`;
|
|
6184
6184
|
};
|
|
6185
6185
|
|
|
6186
|
-
const jsxIsSimple =
|
|
6186
|
+
const jsxIsSimple = isSimpleJsxHandler(valueNode);
|
|
6187
6187
|
|
|
6188
6188
|
if (jsxIsSimple) {
|
|
6189
|
-
const collapsedJsx =
|
|
6189
|
+
const collapsedJsx = getCollapsedJsxHandler(valueNode);
|
|
6190
6190
|
const currentText = sourceCode.getText(valueNode);
|
|
6191
6191
|
|
|
6192
6192
|
// Check if already correctly formatted (inline, no parens, collapsed)
|
|
@@ -6272,7 +6272,7 @@ const objectPropertyValueFormat = {
|
|
|
6272
6272
|
}
|
|
6273
6273
|
};
|
|
6274
6274
|
|
|
6275
|
-
return { Property:
|
|
6275
|
+
return { Property: checkPropertyHandler };
|
|
6276
6276
|
},
|
|
6277
6277
|
meta: {
|
|
6278
6278
|
docs: { description: "Enforce property value on same line as colon with proper spacing" },
|
|
@@ -6308,7 +6308,7 @@ const openingBracketsSameLine = {
|
|
|
6308
6308
|
create(context) {
|
|
6309
6309
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
6310
6310
|
|
|
6311
|
-
const
|
|
6311
|
+
const checkCallExpressionHandler = (node) => {
|
|
6312
6312
|
const { callee } = node;
|
|
6313
6313
|
|
|
6314
6314
|
// Case 0: Function call with opening paren on different line - fn\n( should be fn(
|
|
@@ -6572,7 +6572,7 @@ const openingBracketsSameLine = {
|
|
|
6572
6572
|
}
|
|
6573
6573
|
};
|
|
6574
6574
|
|
|
6575
|
-
const
|
|
6575
|
+
const checkJSXExpressionContainerHandler = (node) => {
|
|
6576
6576
|
const expression = node.expression;
|
|
6577
6577
|
|
|
6578
6578
|
// Skip empty expressions
|
|
@@ -6863,7 +6863,7 @@ const openingBracketsSameLine = {
|
|
|
6863
6863
|
}
|
|
6864
6864
|
};
|
|
6865
6865
|
|
|
6866
|
-
const
|
|
6866
|
+
const checkArrowFunctionHandler = (node) => {
|
|
6867
6867
|
// Check 1: Arrow function with block body - ensure => { are on same line
|
|
6868
6868
|
if (node.body.type === "BlockStatement") {
|
|
6869
6869
|
const arrowToken = sourceCode.getTokenBefore(
|
|
@@ -7051,7 +7051,7 @@ const openingBracketsSameLine = {
|
|
|
7051
7051
|
}
|
|
7052
7052
|
};
|
|
7053
7053
|
|
|
7054
|
-
const
|
|
7054
|
+
const checkJSXSpreadAttributeHandler = (node) => {
|
|
7055
7055
|
// Handle simple spread attributes: {...formMethods} should be on single line
|
|
7056
7056
|
const { argument } = node;
|
|
7057
7057
|
|
|
@@ -7080,10 +7080,10 @@ const openingBracketsSameLine = {
|
|
|
7080
7080
|
};
|
|
7081
7081
|
|
|
7082
7082
|
return {
|
|
7083
|
-
ArrowFunctionExpression:
|
|
7084
|
-
CallExpression:
|
|
7085
|
-
JSXExpressionContainer:
|
|
7086
|
-
JSXSpreadAttribute:
|
|
7083
|
+
ArrowFunctionExpression: checkArrowFunctionHandler,
|
|
7084
|
+
CallExpression: checkCallExpressionHandler,
|
|
7085
|
+
JSXExpressionContainer: checkJSXExpressionContainerHandler,
|
|
7086
|
+
JSXSpreadAttribute: checkJSXSpreadAttributeHandler,
|
|
7087
7087
|
};
|
|
7088
7088
|
},
|
|
7089
7089
|
meta: {
|
|
@@ -7117,7 +7117,7 @@ const simpleCallSingleLine = {
|
|
|
7117
7117
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
7118
7118
|
|
|
7119
7119
|
// Check if a node is simple enough to be on one line
|
|
7120
|
-
const
|
|
7120
|
+
const isSimpleArgHandler = (argNode) => {
|
|
7121
7121
|
if (!argNode) return false;
|
|
7122
7122
|
|
|
7123
7123
|
// Simple literals (strings, numbers, booleans)
|
|
@@ -7132,10 +7132,10 @@ const simpleCallSingleLine = {
|
|
|
7132
7132
|
return false;
|
|
7133
7133
|
};
|
|
7134
7134
|
|
|
7135
|
-
const
|
|
7135
|
+
const isSimpleBodyHandler = (bodyNode) => {
|
|
7136
7136
|
// Handle ImportExpression (dynamic import)
|
|
7137
7137
|
if (bodyNode.type === "ImportExpression") {
|
|
7138
|
-
return
|
|
7138
|
+
return isSimpleArgHandler(bodyNode.source);
|
|
7139
7139
|
}
|
|
7140
7140
|
|
|
7141
7141
|
// Handle CallExpression
|
|
@@ -7150,7 +7150,7 @@ const simpleCallSingleLine = {
|
|
|
7150
7150
|
// Must have simple arguments (0-2 args, all simple)
|
|
7151
7151
|
if (bodyNode.arguments.length > 2) return false;
|
|
7152
7152
|
|
|
7153
|
-
return bodyNode.arguments.every(
|
|
7153
|
+
return bodyNode.arguments.every(isSimpleArgHandler);
|
|
7154
7154
|
}
|
|
7155
7155
|
|
|
7156
7156
|
return false;
|
|
@@ -7177,7 +7177,7 @@ const simpleCallSingleLine = {
|
|
|
7177
7177
|
const { body } = arg;
|
|
7178
7178
|
|
|
7179
7179
|
// Body must be a simple call expression or import
|
|
7180
|
-
if (!
|
|
7180
|
+
if (!isSimpleBodyHandler(body)) return;
|
|
7181
7181
|
|
|
7182
7182
|
// Check if the call spans multiple lines
|
|
7183
7183
|
if (node.loc.start.line === node.loc.end.line) return;
|
|
@@ -7229,7 +7229,7 @@ const singleArgumentOnOneLine = {
|
|
|
7229
7229
|
create(context) {
|
|
7230
7230
|
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
7231
7231
|
|
|
7232
|
-
const
|
|
7232
|
+
const isSimpleArgHandler = (argNode) => {
|
|
7233
7233
|
if (!argNode) return false;
|
|
7234
7234
|
|
|
7235
7235
|
// Simple literals (strings, numbers, booleans, null)
|
|
@@ -7250,7 +7250,7 @@ const singleArgumentOnOneLine = {
|
|
|
7250
7250
|
|
|
7251
7251
|
// Unary expressions like !flag, -1
|
|
7252
7252
|
if (argNode.type === "UnaryExpression") {
|
|
7253
|
-
return
|
|
7253
|
+
return isSimpleArgHandler(argNode.argument);
|
|
7254
7254
|
}
|
|
7255
7255
|
|
|
7256
7256
|
return false;
|
|
@@ -7266,7 +7266,7 @@ const singleArgumentOnOneLine = {
|
|
|
7266
7266
|
const arg = args[0];
|
|
7267
7267
|
|
|
7268
7268
|
// Only handle simple arguments
|
|
7269
|
-
if (!
|
|
7269
|
+
if (!isSimpleArgHandler(arg)) return;
|
|
7270
7270
|
|
|
7271
7271
|
// Check if the call spans multiple lines
|
|
7272
7272
|
if (node.loc.start.line === node.loc.end.line) return;
|
|
@@ -7401,7 +7401,7 @@ const variableNamingConvention = {
|
|
|
7401
7401
|
];
|
|
7402
7402
|
|
|
7403
7403
|
// Check if this is a MUI styled component: styled(Component)(...)
|
|
7404
|
-
const
|
|
7404
|
+
const isStyledComponentHandler = (init) => {
|
|
7405
7405
|
if (!init || init.type !== "CallExpression") return false;
|
|
7406
7406
|
|
|
7407
7407
|
const { callee } = init;
|
|
@@ -7425,7 +7425,7 @@ const variableNamingConvention = {
|
|
|
7425
7425
|
};
|
|
7426
7426
|
|
|
7427
7427
|
// Check if this CallExpression is a styled() call
|
|
7428
|
-
const
|
|
7428
|
+
const isStyledCallHandler = (node) => {
|
|
7429
7429
|
if (node.type !== "CallExpression") return false;
|
|
7430
7430
|
|
|
7431
7431
|
const { callee } = node;
|
|
@@ -7438,7 +7438,7 @@ const variableNamingConvention = {
|
|
|
7438
7438
|
return false;
|
|
7439
7439
|
};
|
|
7440
7440
|
|
|
7441
|
-
const
|
|
7441
|
+
const isFunctionTypeHandler = (init) => {
|
|
7442
7442
|
if (!init) return false;
|
|
7443
7443
|
|
|
7444
7444
|
if (init.type === "ArrowFunctionExpression" || init.type === "FunctionExpression") {
|
|
@@ -7455,25 +7455,25 @@ const variableNamingConvention = {
|
|
|
7455
7455
|
return false;
|
|
7456
7456
|
};
|
|
7457
7457
|
|
|
7458
|
-
const
|
|
7458
|
+
const isComponentByNamingHandler = (node) => {
|
|
7459
7459
|
if (!node.init) return false;
|
|
7460
7460
|
|
|
7461
7461
|
const name = node.id.name;
|
|
7462
7462
|
|
|
7463
7463
|
// PascalCase naming indicates a component
|
|
7464
|
-
if (/^[A-Z]/.test(name) &&
|
|
7464
|
+
if (/^[A-Z]/.test(name) && isFunctionTypeHandler(node.init)) {
|
|
7465
7465
|
return true;
|
|
7466
7466
|
}
|
|
7467
7467
|
|
|
7468
7468
|
return false;
|
|
7469
7469
|
};
|
|
7470
7470
|
|
|
7471
|
-
const
|
|
7471
|
+
const isHookFunctionHandler = (node) => {
|
|
7472
7472
|
if (!node.init) return false;
|
|
7473
7473
|
|
|
7474
7474
|
const name = node.id.name;
|
|
7475
7475
|
|
|
7476
|
-
return name.startsWith("use") && /^use[A-Z]/.test(name) &&
|
|
7476
|
+
return name.startsWith("use") && /^use[A-Z]/.test(name) && isFunctionTypeHandler(node.init);
|
|
7477
7477
|
};
|
|
7478
7478
|
|
|
7479
7479
|
// Common component property names that should allow PascalCase
|
|
@@ -7487,7 +7487,7 @@ const variableNamingConvention = {
|
|
|
7487
7487
|
"Provider",
|
|
7488
7488
|
];
|
|
7489
7489
|
|
|
7490
|
-
const
|
|
7490
|
+
const checkPatternHandler = (node, typeLabel) => {
|
|
7491
7491
|
if (node.type === "Identifier") {
|
|
7492
7492
|
const name = node.name;
|
|
7493
7493
|
|
|
@@ -7505,13 +7505,13 @@ const variableNamingConvention = {
|
|
|
7505
7505
|
} else if (node.type === "ObjectPattern") {
|
|
7506
7506
|
node.properties.forEach((prop) => {
|
|
7507
7507
|
if (prop.type === "Property") {
|
|
7508
|
-
|
|
7508
|
+
checkPatternHandler(
|
|
7509
7509
|
prop.value,
|
|
7510
7510
|
typeLabel,
|
|
7511
7511
|
);
|
|
7512
7512
|
}
|
|
7513
7513
|
else if (prop.type === "RestElement") {
|
|
7514
|
-
|
|
7514
|
+
checkPatternHandler(
|
|
7515
7515
|
prop.argument,
|
|
7516
7516
|
typeLabel,
|
|
7517
7517
|
);
|
|
@@ -7520,29 +7520,29 @@ const variableNamingConvention = {
|
|
|
7520
7520
|
} else if (node.type === "ArrayPattern") {
|
|
7521
7521
|
node.elements.forEach((elem) => {
|
|
7522
7522
|
if (elem) {
|
|
7523
|
-
|
|
7523
|
+
checkPatternHandler(
|
|
7524
7524
|
elem,
|
|
7525
7525
|
typeLabel,
|
|
7526
7526
|
);
|
|
7527
7527
|
}
|
|
7528
7528
|
});
|
|
7529
7529
|
} else if (node.type === "AssignmentPattern") {
|
|
7530
|
-
|
|
7530
|
+
checkPatternHandler(
|
|
7531
7531
|
node.left,
|
|
7532
7532
|
typeLabel,
|
|
7533
7533
|
);
|
|
7534
7534
|
}
|
|
7535
7535
|
else if (node.type === "RestElement") {
|
|
7536
|
-
|
|
7536
|
+
checkPatternHandler(
|
|
7537
7537
|
node.argument,
|
|
7538
7538
|
typeLabel,
|
|
7539
7539
|
);
|
|
7540
7540
|
}
|
|
7541
7541
|
};
|
|
7542
7542
|
|
|
7543
|
-
const
|
|
7543
|
+
const checkVariableDeclaratorHandler = (node) => {
|
|
7544
7544
|
if (node.id.type !== "Identifier") {
|
|
7545
|
-
|
|
7545
|
+
checkPatternHandler(
|
|
7546
7546
|
node.id,
|
|
7547
7547
|
"Variable",
|
|
7548
7548
|
);
|
|
@@ -7553,7 +7553,7 @@ const variableNamingConvention = {
|
|
|
7553
7553
|
const name = node.id.name;
|
|
7554
7554
|
|
|
7555
7555
|
// Enforce PascalCase for styled components: const StyledCard = styled(Card)(...)
|
|
7556
|
-
if (
|
|
7556
|
+
if (isStyledComponentHandler(node.init)) {
|
|
7557
7557
|
if (!pascalCaseRegex.test(name)) {
|
|
7558
7558
|
context.report({
|
|
7559
7559
|
message: `Styled component "${name}" should be PascalCase (e.g., StyledCard instead of styledCard)`,
|
|
@@ -7564,9 +7564,9 @@ const variableNamingConvention = {
|
|
|
7564
7564
|
return;
|
|
7565
7565
|
}
|
|
7566
7566
|
|
|
7567
|
-
if (name.startsWith("_") || constantRegex.test(name) ||
|
|
7567
|
+
if (name.startsWith("_") || constantRegex.test(name) || isComponentByNamingHandler(node)) return;
|
|
7568
7568
|
|
|
7569
|
-
if (
|
|
7569
|
+
if (isHookFunctionHandler(node)) {
|
|
7570
7570
|
if (!hookRegex.test(name)) {
|
|
7571
7571
|
context.report({
|
|
7572
7572
|
message: `Hook "${name}" should start with "use" followed by PascalCase (e.g., useEventsList)`,
|
|
@@ -7600,7 +7600,7 @@ const variableNamingConvention = {
|
|
|
7600
7600
|
}
|
|
7601
7601
|
};
|
|
7602
7602
|
|
|
7603
|
-
const
|
|
7603
|
+
const checkPropertyHandler = (node) => {
|
|
7604
7604
|
if (node.computed || node.key.type !== "Identifier") return;
|
|
7605
7605
|
|
|
7606
7606
|
const name = node.key.name;
|
|
@@ -7632,16 +7632,16 @@ const variableNamingConvention = {
|
|
|
7632
7632
|
}
|
|
7633
7633
|
};
|
|
7634
7634
|
|
|
7635
|
-
const
|
|
7636
|
-
node.params.forEach((param) =>
|
|
7635
|
+
const checkFunctionHandlerParamsHandler = (node) => {
|
|
7636
|
+
node.params.forEach((param) => checkPatternHandler(
|
|
7637
7637
|
param,
|
|
7638
7638
|
"Parameter",
|
|
7639
7639
|
));
|
|
7640
7640
|
};
|
|
7641
7641
|
|
|
7642
|
-
const
|
|
7642
|
+
const checkCallExpressionHandlerArguments = (node) => {
|
|
7643
7643
|
// Skip argument checking for styled() calls - they accept PascalCase components
|
|
7644
|
-
if (
|
|
7644
|
+
if (isStyledCallHandler(node)) return;
|
|
7645
7645
|
|
|
7646
7646
|
node.arguments.forEach((arg) => {
|
|
7647
7647
|
if (arg.type === "Identifier") {
|
|
@@ -7663,12 +7663,12 @@ const variableNamingConvention = {
|
|
|
7663
7663
|
};
|
|
7664
7664
|
|
|
7665
7665
|
return {
|
|
7666
|
-
ArrowFunctionExpression:
|
|
7667
|
-
CallExpression:
|
|
7668
|
-
FunctionDeclaration:
|
|
7669
|
-
FunctionExpression:
|
|
7670
|
-
Property:
|
|
7671
|
-
VariableDeclarator:
|
|
7666
|
+
ArrowFunctionExpression: checkFunctionHandlerParamsHandler,
|
|
7667
|
+
CallExpression: checkCallExpressionHandlerArguments,
|
|
7668
|
+
FunctionDeclaration: checkFunctionHandlerParamsHandler,
|
|
7669
|
+
FunctionExpression: checkFunctionHandlerParamsHandler,
|
|
7670
|
+
Property: checkPropertyHandler,
|
|
7671
|
+
VariableDeclarator: checkVariableDeclaratorHandler,
|
|
7672
7672
|
};
|
|
7673
7673
|
},
|
|
7674
7674
|
meta: {
|
package/package.json
CHANGED