Environment
Node version: v24.15.0
npm version: v11.12.1
Local ESLint version: v10.4.1
Global ESLint version: Not found
Operating System: win32 10.0.26200
What parser are you using?
Default (Espree)
What did you do?
Configuration
export default [
{ rules: { "no-extra-boolean-cast": "error" } }
];
function validate(Boolean) {
if (Boolean(input)) {
process(input);
}
}
Boolean here is the function parameter, not the global. So Boolean(input) is a call to whatever was passed in, not a redundant cast.
What did you expect to happen?
No error. The Boolean in Boolean(input) resolves to the parameter, so there's nothing redundant about it.
What actually happened?
2:9 error Redundant Boolean call no-extra-boolean-cast
And --fix rewrites it:
function validate(Boolean) {
- if (Boolean(input)) {
+ if (input) {
process(input);
}
}
The call to the parameter is just deleted. Anyone running --fix on save or in CI gets this applied automatically, so the behavior change slips through silently.
Same thing happens with the other ways of shadowing Boolean:
// let binding
let Boolean = v => v != null && v !== "";
while (Boolean(value)) { value = next(); }
// --fix -> while (value) { value = next(); }
// class
class Boolean { static from(v) { return !!v; } }
if (Boolean(x)) { doSomething(); }
// --fix -> if (x) { doSomething(); }
Shadowing Boolean is admittedly an unusual thing to do, but it's valid code and rewriting it is still wrong
Link to Minimal Reproducible Example
https://eslint.org/play/#eyJ0ZXh0IjoiZnVuY3Rpb24gdmFsaWRhdGUoQm9vbGVhbikge1xuICAgIGlmIChCb29sZWFuKGlucHV0KSkge1xuICAgICAgICBwcm9jZXNzKGlucHV0KTtcbiAgICB9XG59Iiwib3B0aW9ucyI6eyJydWxlcyI6eyJuby1leHRyYS1ib29sZWFuLWNhc3QiOlsiZXJyb3IiXX0sImxhbmd1YWdlT3B0aW9ucyI6eyJwYXJzZXJPcHRpb25zIjp7ImVjbWFGZWF0dXJlcyI6e319fX19
Participation
AI acknowledgment
Additional comments
No response
Environment
Node version: v24.15.0
npm version: v11.12.1
Local ESLint version: v10.4.1
Global ESLint version: Not found
Operating System: win32 10.0.26200
What parser are you using?
Default (Espree)
What did you do?
Configuration
Booleanhere is the function parameter, not the global. SoBoolean(input)is a call to whatever was passed in, not a redundant cast.What did you expect to happen?
No error. The
BooleaninBoolean(input)resolves to the parameter, so there's nothing redundant about it.What actually happened?
And
--fixrewrites it:function validate(Boolean) { - if (Boolean(input)) { + if (input) { process(input); } }The call to the parameter is just deleted. Anyone running
--fixon save or in CI gets this applied automatically, so the behavior change slips through silently.Same thing happens with the other ways of shadowing
Boolean:Shadowing
Booleanis admittedly an unusual thing to do, but it's valid code and rewriting it is still wrongLink to Minimal Reproducible Example
https://eslint.org/play/#eyJ0ZXh0IjoiZnVuY3Rpb24gdmFsaWRhdGUoQm9vbGVhbikge1xuICAgIGlmIChCb29sZWFuKGlucHV0KSkge1xuICAgICAgICBwcm9jZXNzKGlucHV0KTtcbiAgICB9XG59Iiwib3B0aW9ucyI6eyJydWxlcyI6eyJuby1leHRyYS1ib29sZWFuLWNhc3QiOlsiZXJyb3IiXX0sImxhbmd1YWdlT3B0aW9ucyI6eyJwYXJzZXJPcHRpb25zIjp7ImVjbWFGZWF0dXJlcyI6e319fX19
Participation
AI acknowledgment
Additional comments
No response