Skip to content
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

test: avoid deep comparisons with literals #40634

Commits on Oct 28, 2021

  1. test: avoid deep comparisons with literals

    Comparing any value to any non-RegExp literal or undefined using
    strictEqual (or notStrictEqual) passes if and only if deepStrictEqual
    (or notDeepStrictEqual, respectively) passes.
    
    Unnecessarily using deep comparisons adds confusion.
    
    This patch adds an ESLint rule that forbids the use of deepStrictEqual
    and notDeepStrictEqual when the expected value (i.e., the second
    argument) is a non-RegExp literal or undefined.
    
    For reference, an ESTree literal is defined as follows.
    
        extend interface Literal <: Expression {
            type: "Literal";
            value: string | boolean | null | number | RegExp | bigint;
        }
    
    The value `undefined` is an `Identifier` with `name: 'undefined'`.
    tniessen committed Oct 28, 2021
    Configuration menu
    Copy the full SHA
    17d8a5d View commit details
    Browse the repository at this point in the history