Skip to content

Commit 6f3906b

Browse files
committed
chore: update ESLint rules for stricter boolean expressions and adjust linting command
1 parent 6c80cc5 commit 6f3906b

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

eslint.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,16 @@ const enableTypeCheckedRules = {
7676
"@susisu/safe-typescript/no-unsafe-object-property-check": "off",
7777
"@susisu/safe-typescript/no-unsafe-object-property-overwrite": "off",
7878
"@typescript-eslint/consistent-type-exports": "error",
79-
"@typescript-eslint/strict-boolean-expressions": ["warn", { allowNullableBoolean: true, allowNullableString: true }],
79+
"@typescript-eslint/strict-boolean-expressions": ["warn", {
80+
allowAny: false,
81+
allowNullableBoolean: true,
82+
allowNullableEnum: false,
83+
allowNullableNumber: false,
84+
allowNullableObject: true,
85+
allowNullableString: false,
86+
allowNumber: false,
87+
allowString: false,
88+
}],
8089
} as const;
8190

8291
const disableTypeCheckedRules = Object.fromEntries(Object.keys(enableTypeCheckedRules).map(x => [x, "off"]));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"lint:examples": "pnpm -r -F \"./examples/*\" run --parallel lint",
4343
"lint:publish": "pnpm -r run --parallel lint:publish",
4444
"lint:spell": "cspell lint --relative --no-progress \"**\"",
45-
"lint:ts": "eslint .",
45+
"lint:ts": "eslint . --max-warnings 100",
4646
"lint:type": "pnpm -r run --parallel lint:type",
4747
"lint:website": "pnpm -F \"./website\" run lint",
4848
"prepare": "lefthook install && pnpm run build",

packages/core/src/component/component-collector.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ export function useComponentCollector(
7878
functionEntries.push({ key, node, hookCalls: [], isComponent: false });
7979
};
8080
const onFunctionExit = () => {
81-
const { key, node, isComponent } = functionEntries.at(-1) ?? {};
82-
if (!key || !node || !isComponent) {
81+
const entry = functionEntries.at(-1);
82+
if (!entry?.isComponent) {
8383
return functionEntries.pop();
8484
}
85-
const shouldDrop = AST.getNestedReturnStatements(node.body)
85+
const shouldDrop = AST.getNestedReturnStatements(entry.node.body)
8686
.slice()
8787
.reverse()
8888
.some(r => {
89-
return context.sourceCode.getScope(r).block === node
89+
return context.sourceCode.getScope(r).block === entry.node
9090
&& r.argument !== null
9191
&& !JSX.isJSXValue(r.argument, jsxCtx, hint);
9292
});
9393
if (shouldDrop) {
94-
components.delete(key);
94+
components.delete(entry.key);
9595
}
9696
return functionEntries.pop();
9797
};

0 commit comments

Comments
 (0)