sonarjs/no-redundant-optional
eslint-plugin-sonarjs
SuggestionRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-redundant-optional": "error",
},
},
];Optional properties should not redundantly include 'undefined'
interface Person {
name: string;
address? : string | undefined; // Noncompliant, "?" should be removed
pet?: Animal | undefined; // Noncompliant, "undefined" should be removed
}interface Person {
name: string;
address: string | undefined;
pet?: Animal;
}Examples from the ESLint documentation.
sonarjs/no-redundant-optional
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-redundant-optional": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
HTTP Referrer-Policy should not be set to an unsafe value
Boolean literals should not be used in comparisons
Regular expressions should not contain multiple spaces
Assertions should not be given twice the same argument