We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We already have this good thing happening with prefer-native-coercion-functions
prefer-native-coercion-functions
// ❌ const example = values.filter((value) => Boolean(value)); // ✅ const example = values.filter(Boolean);
Some times though you can have a situation where there's an unnecessary coercion though, when the callback is more complex.
The standard rule no-extra-boolean-cast stops me doing something like this
no-extra-boolean-cast
// ❌ if (Boolean(example)) // ✅ if (example)
// ❌ const example = records.filter(({ fieldname }) => Boolean(fieldname)); // ✅ const example = records.filter(({ fieldname }) => fieldname);
// ❌ const example = records.every((record) => Boolean(record.fieldname)); // ✅ const example = records.every((record) => record.fieldname);
// ❌ const example = records.some((record) => Boolean(record.fieldname)); // ✅ const example = records.some((record) => record.fieldname);
no-useless-boolean-cast
This might be giving some performance benefits.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
We already have this good thing happening with
prefer-native-coercion-functions
Some times though you can have a situation where there's an unnecessary coercion though, when the callback is more complex.
The standard rule
no-extra-boolean-cast
stops me doing something like thisExamples
Proposed rule name
no-useless-boolean-cast
Additional Info
This might be giving some performance benefits.
The text was updated successfully, but these errors were encountered: