From 67e7ab58bcafde43f21f90f61239305f86cbb8e5 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 23 Jul 2022 12:08:23 -0400 Subject: [PATCH] Apply suggestions from code review --- .../src/rules/prefer-nullish-coalescing.ts | 11 +++-------- packages/eslint-plugin/src/util/isNodeEqual.ts | 16 ---------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts index b460eba03bb..b2321fd0757 100644 --- a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts @@ -179,14 +179,9 @@ export default util.createRule({ } const isFixable = ((): boolean => { - // it is fixable if we check for both null and undefined - if (hasUndefinedCheck && hasNullCheck) { - return true; - } - - // it is not fixable if it has neither a null nor undefined check - if (!hasUndefinedCheck && !hasNullCheck) { - return false; + // it is fixable if we check for both null and undefined, or not if neither + if (hasUndefinedCheck === hasNullCheck) { + return hasUndefinedCheck; } // it is fixable if we loosely check for either null or undefined diff --git a/packages/eslint-plugin/src/util/isNodeEqual.ts b/packages/eslint-plugin/src/util/isNodeEqual.ts index 03acc88eb25..ef879163ee4 100644 --- a/packages/eslint-plugin/src/util/isNodeEqual.ts +++ b/packages/eslint-plugin/src/util/isNodeEqual.ts @@ -1,20 +1,4 @@ import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils'; -/* - * Supported: - * Identifier Literal MemberExpression ThisExpression - * TSNamedTupleMember TSNamespaceExportDeclaration TSNeverKeyword - * TSNonNullExpression TSNullKeyword TSNumberKeyword TSObjectKeyword - * TSOptionalType TSParameterProperty TSPrivateKeyword TSPropertySignature - * TSProtectedKeyword TSPublicKeyword TSQualifiedName TSReadonlyKeyword - * TSRestType TSStaticKeyword TSStringKeyword TSSymbolKeyword - * TSTemplateLiteralType TSThisType TSTupleType TSTypeAliasDeclaration - * TSTypeAnnotation TSTypeAssertion TSTypeLiteral TSTypeOperator - * TSTypeParameter TSTypeParameterDeclaration TSTypeParameterInstantiation - * TSTypePredicate TSTypeQuery TSTypeReference TSUndefinedKeyword TSUnionType - * TSUnknownKeyword TSVoidKeyword UnaryExpression UpdateExpression - * VariableDeclaration VariableDeclarator WhileStatement WithStatement - * YieldExpression - */ export function isNodeEqual(a: TSESTree.Node, b: TSESTree.Node): boolean { if (a.type !== b.type) {