Skip to content

Commit f292989

Browse files
author
Ondrej Machala
committed
chore: forbid !! double negation in eslint
Use Boolean(x) instead of !!x for explicit type coercion.
1 parent 45ee2ee commit f292989

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

eslint.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ export default tseslint.config(
8989
'ArrowFunctionExpression[params.length=1][params.0.type=Identifier][body.type=MemberExpression][body.computed=false]',
9090
message: 'Use destructuring in callback: prefer ({ prop }) => prop over f => f.prop',
9191
},
92+
{
93+
// bans `!!x` - prefer `Boolean(x)` for clarity
94+
selector:
95+
"UnaryExpression[operator='!'][argument.type='UnaryExpression'][argument.operator='!']",
96+
message: 'Use Boolean(x) instead of !!x for explicit type coercion.',
97+
},
9298
],
9399

94100
// Let TypeScript infer return types

src/cli/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export async function shotAction(
140140
return handleDefaultCommand({
141141
configPath,
142142
sessionKey: globalOptions.sessionKey,
143-
hasExplicitConfig: !!globalOptions.config,
143+
hasExplicitConfig: Boolean(globalOptions.config),
144144
clean: options?.clean,
145145
workers: options?.workers,
146146
headed: options?.headed,

0 commit comments

Comments
 (0)