sonarjs/max-union-size
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/max-union-size": "error",
},
},
];let x: MyType1 | MyType2 | MyType3 | MyType4; // Noncompliant
function foo(p1: string, p2: MyType1 | MyType2 | MyType3 | MyType4) { // Noncompliant
// ...
}type MyUnionType = MyType1 | MyType2 | MyType3 | MyType4; // Compliant, "type" statements are ignored
let x: MyUnionType;
function foo(value: string, padding: MyUnionType) {
// ...
}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/max-union-size
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/max-union-size": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Control flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
Function and method names should comply with a naming convention