Skip to content

Commit 3716e4d

Browse files
committed
Address feedback on TSL rules for React
2 parents 7de0f6f + 5f4fa54 commit 3716e4d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

packages/tsl-rules-of-react/src/rules/rules-of-keys.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,24 @@ export const rulesOfKeys = defineRule(() => {
5555
if (element.kind !== ts.SyntaxKind.JsxOpeningElement && element.kind !== ts.SyntaxKind.JsxSelfClosingElement) {
5656
return;
5757
}
58-
const children: ts.Node[] = [];
59-
ts.forEachChild(element.attributes, (n) => void children.push(n));
58+
let index = -1;
6059
let firstSpreadAttrIndex: null | number = null;
61-
for (const [index, attr] of children.entries()) {
60+
ts.forEachChild(element.attributes, (attr) => {
61+
index++;
6262
if (attr.kind === ts.SyntaxKind.JsxSpreadAttribute) {
6363
firstSpreadAttrIndex ??= index;
64-
continue;
64+
return;
6565
}
6666
if (firstSpreadAttrIndex == null) {
67-
continue;
67+
return;
6868
}
69-
const name = attr.getChildAt(0);
70-
if (name.getText() === "key" && index > firstSpreadAttrIndex) {
69+
if (attr.getChildAt(0).getText() === "key" && index > firstSpreadAttrIndex) {
7170
ctx.report({
7271
message: messages[3],
7372
node: attr,
7473
});
7574
}
76-
}
75+
});
7776
},
7877
},
7978
};

packages/tsl-shared/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"dedent": "^1.7.1",
3737
"tsdown": "^0.20.3",
3838
"tsl": "^1.0.29",
39+
"typescript": "*",
3940
"vitest": "^4.0.18"
4041
},
4142
"peerDependencies": {

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ overrides:
1515
"markdown-it": "^14.1.1"
1616
"tslib": "^2.8.1"
1717
"typescript": "^5.9.3"
18-
"undici": "^7.18.2"
18+
"undici": "^7.22.0"

0 commit comments

Comments
 (0)