Repository: eslint/eslint
File: tests/lib/rules/id-length.js (JavaScript)

Code before:
        "var query = location.query.q ? location.query.q : ''",
        { code: "let {a: foo} = bar;", languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a]: 1 };", languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a + b]: 1 };", languageOptions: { ecmaVersion: 6 } },
        { code: "var x = Foo(42)", options: [{ min: 1 }] },
        { code: "var x = Foo(42)", options: [{ min: 0 }] },
        { code: "foo.$x = Foo(42)", options: [{ min: 1 }] },
        { code: "var lalala = Foo(42)", options: [{ max: 6 }] },
        { code: "for (var q, h=0; h < 10; h++) { console.log(h); q++; }", options: [{ exceptions: ["h", "q"] }] },
        { code: "(num) => { num * num };", languageOptions: { ecmaVersion: 6 } },
        { code: "function foo(num = 0) { }", languageOptions: { ecmaVersion: 6 } },
        { code: "class MyClass { }", languageOptions: { ecmaVersion: 6 } },
        { code: "class Foo { method() {} }", languageOptions: { ecmaVersion: 6 } },
        { code: "function foo(...args) { }", languageOptions: { ecmaVersion: 6 } },
        { code: "var { prop } = {};", languageOptions: { ecmaVersion: 6 } },
        { code: "var { [a]: prop } = {};", languageOptions: { ecmaVersion: 6 } },
        { code: "var { a: foo } = {};", options: [{ min: 3 }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { prop: foo } = {};", options: [{ max: 3 }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { longName: foo } = {};", options: [{ min: 3, max: 5 }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { foo: a } = {};", options: [{ exceptions: ["a"] }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { a: { b: { c: longName } } } = {};", languageOptions: { ecmaVersion: 6 } },
        { code: "({ a: obj.x.y.z } = {});", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "import something from 'y';", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "export var num = 0;", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "import * as something from 'y';", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "import { something } from 'y';", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "({ prop: obj.x.y.something } = {});", languageOptions: { ecmaVersion: 6 } },
        { code: "({ prop: obj.longName } = {});", languageOptions: { ecmaVersion: 6 } },
        { code: "var obj = { a: 1, bc: 2 };", options: [{ properties: "never" }] },
        { code: "var obj = { [a]: 2 };", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var obj = {}; obj.a = 1; obj.bc = 2;", options: [{ properties: "never" }] },
        { code: "({ prop: obj.x } = {});", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var obj = { aaaaa: 1 };", options: [{ max: 4, properties: "never" }] },
        { code: "var obj = {}; obj.aaaaa = 1;", options: [{ max: 4, properties: "never" }] },
        { code: "({ a: obj.x.y.z } = {});", options: [{ max: 4, properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "({ prop: obj.xxxxx } = {});", options: [{ max: 4, properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var arr = [i,j,f,b]", languageOptions: { ecmaVersion: 6 } },
        { code: "function foo([arr]) {}", languageOptions: { ecmaVersion: 6 } },
        { code: "var {x} = foo;", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var {x, y: {z}} = foo;", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a]: 1 };", options: [{ properties: "always" }], languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a + b]: 1 };", options: [{ properties: "always" }], languageOptions: { ecmaVersion: 6 } },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^BEFORE_"] }] },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^BEFORE_", "send$"] }] },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^BEFORE_", "^A", "^Z"] }] },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^A", "^BEFORE_", "^Z"] }] },
        { code: "var x = 1 ;", options: [{ min: 3, max: 5, exceptionPatterns: ["[x-z]"] }] },

        // Class Fields
        {
            code: "class Foo { #xyz() {} }",

Review comment (suggestion):
```suggestion
        { code: "import { x } from 'y';", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
```

To shows that `ImportSpecifiers` are allowed even with default `2`.

Code after:
        "var query = location.query.q ? location.query.q : ''",
        { code: "let {a: foo} = bar;", languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a]: 1 };", languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a + b]: 1 };", languageOptions: { ecmaVersion: 6 } },
        { code: "var x = Foo(42)", options: [{ min: 1 }] },
        { code: "var x = Foo(42)", options: [{ min: 0 }] },
        { code: "foo.$x = Foo(42)", options: [{ min: 1 }] },
        { code: "var lalala = Foo(42)", options: [{ max: 6 }] },
        { code: "for (var q, h=0; h < 10; h++) { console.log(h); q++; }", options: [{ exceptions: ["h", "q"] }] },
        { code: "(num) => { num * num };", languageOptions: { ecmaVersion: 6 } },
        { code: "function foo(num = 0) { }", languageOptions: { ecmaVersion: 6 } },
        { code: "class MyClass { }", languageOptions: { ecmaVersion: 6 } },
        { code: "class Foo { method() {} }", languageOptions: { ecmaVersion: 6 } },
        { code: "function foo(...args) { }", languageOptions: { ecmaVersion: 6 } },
        { code: "var { prop } = {};", languageOptions: { ecmaVersion: 6 } },
        { code: "var { [a]: prop } = {};", languageOptions: { ecmaVersion: 6 } },
        { code: "var { a: foo } = {};", options: [{ min: 3 }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { prop: foo } = {};", options: [{ max: 3 }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { longName: foo } = {};", options: [{ min: 3, max: 5 }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { foo: a } = {};", options: [{ exceptions: ["a"] }], languageOptions: { ecmaVersion: 6 } },
        { code: "var { a: { b: { c: longName } } } = {};", languageOptions: { ecmaVersion: 6 } },
        { code: "({ a: obj.x.y.z } = {});", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "import something from 'y';", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "export var num = 0;", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "import * as something from 'y';", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "import { x } from 'y';", languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "import { longName } from 'y';", options: [{ max: 5 }], languageOptions: { ecmaVersion: 6, sourceType: "module" } },
        { code: "({ prop: obj.x.y.something } = {});", languageOptions: { ecmaVersion: 6 } },
        { code: "({ prop: obj.longName } = {});", languageOptions: { ecmaVersion: 6 } },
        { code: "var obj = { a: 1, bc: 2 };", options: [{ properties: "never" }] },
        { code: "var obj = { [a]: 2 };", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var obj = {}; obj.a = 1; obj.bc = 2;", options: [{ properties: "never" }] },
        { code: "({ prop: obj.x } = {});", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var obj = { aaaaa: 1 };", options: [{ max: 4, properties: "never" }] },
        { code: "var obj = {}; obj.aaaaa = 1;", options: [{ max: 4, properties: "never" }] },
        { code: "({ a: obj.x.y.z } = {});", options: [{ max: 4, properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "({ prop: obj.xxxxx } = {});", options: [{ max: 4, properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var arr = [i,j,f,b]", languageOptions: { ecmaVersion: 6 } },
        { code: "function foo([arr]) {}", languageOptions: { ecmaVersion: 6 } },
        { code: "var {x} = foo;", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "var {x, y: {z}} = foo;", options: [{ properties: "never" }], languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a]: 1 };", options: [{ properties: "always" }], languageOptions: { ecmaVersion: 6 } },
        { code: "let foo = { [a + b]: 1 };", options: [{ properties: "always" }], languageOptions: { ecmaVersion: 6 } },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^BEFORE_"] }] },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^BEFORE_", "send$"] }] },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^BEFORE_", "^A", "^Z"] }] },
        { code: "function BEFORE_send() {};", options: [{ min: 3, max: 5, exceptionPatterns: ["^A", "^BEFORE_", "^Z"] }] },
        { code: "var x = 1 ;", options: [{ min: 3, max: 5, exceptionPatterns: ["[x-z]"] }] },

        // Class Fields
        {