sonarjs/bool-param-default
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/bool-param-default": "error",
},
},
];function countPositiveNumbers(arr: number[], countZero?: boolean) { // Noncompliant, default value for 'countZero' should be defined
// ...
}
function toggleProperty(property: string, value?: boolean) { // Noncompliant, a new function should be defined
if (value !== undefined) {
setProperty(property, value);
} else {
setProperty(property, calculateProperty());
}
}function countPositiveNumbers(arr: number[], countZero = false) {
// ...
}
function toggleProperty(property: string, value: boolean) {
setProperty(property, value);
}
function togglePropertyToCalculatedValue(property: string) {
setProperty(property, calculateProperty());
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
sonarjs/bool-param-default
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/bool-param-default": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
IAM policies should not grant access to all account resources
Class methods should be used instead of "prototype" assignments
Braces and parentheses should be used consistently with arrow functions