Skip to content

Commit dd0221a

Browse files
committed
remove files to support ts debug; add force curly after if; minor adjustments to to test case
1 parent b6e7556 commit dd0221a

File tree

7 files changed

+25
-62
lines changed

7 files changed

+25
-62
lines changed

.vscode/launch.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import { baseConfig } from "@schleifner/eslint-config-base/config.mjs";
44

55
export default tseslint.config(
66
{
7-
ignores: [
8-
"dist/**",
9-
"**/*.mjs",
10-
],
7+
ignores: ["dist/**", "**/*.mjs"],
118
},
12-
...baseConfig
9+
...baseConfig,
10+
{
11+
files: ["**/*.ts"],
12+
rules: {
13+
curly: ["error", "all"]
14+
},
15+
}
1316
);

loader.mjs

Lines changed: 0 additions & 13 deletions
This file was deleted.

plugins/rules/memberAccess.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,14 @@ const noRepeatedMemberAccess = createRule({
140140
// Skip nodes that are part of larger member expressions
141141
// Example: In a.b.c, we process the top-level MemberExpression only,
142142
// not the sub-expressions a.b or a
143-
if (node.parent?.type === AST_NODE_TYPES.MemberExpression) return;
143+
if (node.parent?.type === AST_NODE_TYPES.MemberExpression) {
144+
return;
145+
}
144146

145147
const chainInfo = analyzeChain(node);
146-
if (!chainInfo) return;
148+
if (!chainInfo) {
149+
return;
150+
}
147151

148152
const scope = sourceCode.getScope(node);
149153
const chainMap = getChainMap(scope);
@@ -154,13 +158,17 @@ const noRepeatedMemberAccess = createRule({
154158
// Update chain statistics for each part of the hierarchy
155159
for (const chain of chainInfo) {
156160
// Skip single-level chains
157-
if (!chain.includes(".")) continue;
161+
if (!chain.includes(".")) {
162+
continue;
163+
}
158164

159165
const chainInfo = chainMap.get(chain) || {
160166
count: 0,
161167
modified: false,
162168
};
163-
if (chainInfo.modified) break;
169+
if (chainInfo.modified) {
170+
break;
171+
}
164172

165173
chainInfo.count++;
166174
chainMap.set(chain, chainInfo);

plugins/rules/noConcatString.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export default createRule({
101101
// Check for string concatenation with + operator
102102
BinaryExpression(node) {
103103
// Only check inside loops
104-
if (loopDepth === 0) return;
104+
if (loopDepth === 0) {
105+
return;
106+
}
105107

106108
const leftType: ts.Type = parserServices.getTypeAtLocation(node.left);
107109
const rightType: ts.Type = parserServices.getTypeAtLocation(node.right);

tests/rules/noRepeatedMemberAccess.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("Rule: no-spread", () => {
2626
// ignore array access
2727
`
2828
const x = data[0].value;
29-
data[0].count++;
29+
data[0].count=data[0].count+1;
3030
send(data[0].id);
3131
`,
3232
// Dynamic property access (should be ignored)
@@ -100,7 +100,7 @@ describe("Rule: no-spread", () => {
100100
`,
101101
`
102102
const v1 = a.b.c;
103-
a.b++;
103+
a.b = a.b + 1;
104104
const v2 = a.b.c;
105105
const v3 = a.b.c;
106106
`,
@@ -149,7 +149,6 @@ describe("Rule: no-spread", () => {
149149
{
150150
code: `
151151
const a = data.x + data.y;
152-
// data.update();
153152
const b = data.x * 2;
154153
notify(data.x);
155154
`,

0 commit comments

Comments
 (0)