Skip to content

chore: enable prefer-nullish-coalescing internally #7955

New issue

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ module.exports = {
// make sure we're not leveraging any deprecated APIs
'deprecation/deprecation': 'error',

// TODO(#7338): Investigate enabling these soon ✨
'@typescript-eslint/prefer-nullish-coalescing': 'off',

// TODO(#7130): Investigate changing these in or removing these from presets
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
Expand Down Expand Up @@ -109,6 +106,13 @@ module.exports = {
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
{
ignoreConditionalTests: true,
ignorePrimitives: true,
},
],

//
// Internal repo rules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function verifyForAlways(
}
return true;
},
}) || nextNode;
}) ?? nextNode;
const insertText = isTokenOnSameLine(prevToken, nextToken)
? '\n\n'
: '\n';
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/unified-signatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export default createRule<Options, MessageIds>({
}

return typeContainsTypeParameter(
(type as Partial<TSESTree.TSTypeAnnotation>).typeAnnotation ||
(type as Partial<TSESTree.TSTypeAnnotation>).typeAnnotation ??
(type as TSESTree.TSArrayType).elementType,
);
}
Expand Down Expand Up @@ -523,7 +523,7 @@ export default createRule<Options, MessageIds>({
key ??= getOverloadKey(signature);
if (
currentScope &&
(containingNode || signature).parent === currentScope.parent
(containingNode ?? signature).parent === currentScope.parent
) {
const overloads = currentScope.overloads.get(key);
if (overloads !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion packages/rule-tester/src/utils/getRuleOptionsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export function getRuleOptionsSchema(
}

// Given a full schema, leave it alone
return schema || null;
return schema ?? null;
}