Skip to content

Commit

Permalink
chore: enable prefer-nullish-coalescing internally (#7955)
Browse files Browse the repository at this point in the history
* chore: enable prefer-nullish-calescing internally

* A couple complaints

* One last complaint

* Enable ignoreConditionalTests
  • Loading branch information
JoshuaKGoldberg committed Jan 28, 2024
1 parent c232319 commit d0137c8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
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;
}

0 comments on commit d0137c8

Please sign in to comment.