Repository: eslint/eslint
File: tests/lib/rules/use-isnan.js (JavaScript)

Code before:
        },
        {
            code: "switch(foo) { case foo.Number.NaN: break }",
            options: [{ enforceForSwitchCase: true }]
        },
        {
            code: "switch((NaN, doStuff(), 1)) {}",
            options: [{ enforceForSwitchCase: true }]
        },
        {
            code: "switch((Number.NaN, doStuff(), 1)) {}",
            options: [{ enforceForSwitchCase: true }]
        },

        //------------------------------------------------------------------------------
        // enforceForIndexOf
        //------------------------------------------------------------------------------

        "foo.indexOf(NaN)",
        "foo.lastIndexOf(NaN)",
        "foo.indexOf(Number.NaN)",
        "foo.lastIndexOf(Number.NaN)",
        "foo.indexOf((NaN, 1))",
        "foo.lastIndexOf((NaN, 1))",
        "foo.indexOf((Number.NaN, 1))",
        "foo.lastIndexOf((Number.NaN, 1))",
        {
            code: "foo.indexOf(NaN)",
            options: [{}]
        },
        {
            code: "foo.lastIndexOf(NaN)",
            options: [{}]
        },
        {
            code: "foo.indexOf(NaN)",
            options: [{ enforceForIndexOf: false }]
        },
        {
            code: "foo.lastIndexOf(NaN)",
            options: [{ enforceForIndexOf: false }]
        },
        {
            code: "indexOf(NaN)",
            options: [{ enforceForIndexOf: true }]
        },
        {
            code: "lastIndexOf(NaN)",
            options: [{ enforceForIndexOf: true }]
        },
        {

Review comment (suggestion):
These tests should probably have `options: [{ enforceForIndexOf: true }]`? Otherwise, they would be valid regardless of the position of NaN, because the rule doesn't check indexOf by default.

Code after:
        },
        {
            code: "switch(foo) { case foo.Number.NaN: break }",
            options: [{ enforceForSwitchCase: true }]
        },
        {
            code: "switch((NaN, doStuff(), 1)) {}",
            options: [{ enforceForSwitchCase: true }]
        },
        {
            code: "switch((Number.NaN, doStuff(), 1)) {}",
            options: [{ enforceForSwitchCase: true }]
        },

        //------------------------------------------------------------------------------
        // enforceForIndexOf
        //------------------------------------------------------------------------------

        "foo.indexOf(NaN)",
        "foo.lastIndexOf(NaN)",
        "foo.indexOf(Number.NaN)",
        "foo.lastIndexOf(Number.NaN)",
        {
            code: "foo.indexOf(NaN)",
            options: [{}]
        },
        {
            code: "foo.lastIndexOf(NaN)",
            options: [{}]
        },
        {
            code: "foo.indexOf(NaN)",
            options: [{ enforceForIndexOf: false }]
        },
        {
            code: "foo.lastIndexOf(NaN)",
            options: [{ enforceForIndexOf: false }]
        },
        {
            code: "indexOf(NaN)",
            options: [{ enforceForIndexOf: true }]
        },
        {
            code: "lastIndexOf(NaN)",
            options: [{ enforceForIndexOf: true }]
        },
        {
            code: "new foo.indexOf(NaN)",
            options: [{ enforceForIndexOf: true }]
        },
        {