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

Code before:
            }
        },
        {
            code: "({ prop: o.𐌘 } = {});",
            options: [{ min: 1, max: 1 }],
            languageOptions: {
                ecmaVersion: 6
            }
        }
    ],
    invalid: [
        { code: "var x = 1;", errors: [tooShortError] },
        { code: "var x;", errors: [tooShortError] },
        { code: "obj.e = document.body;", errors: [tooShortError] },
        { code: "function x() {};", errors: [tooShortError] },
        { code: "function xyz(a) {};", errors: [tooShortError] },
        { code: "var obj = { a: 1, bc: 2 };", errors: [tooShortError] },
        { code: "try { blah(); } catch (e) { /* pass */ }", errors: [tooShortError] },
        { code: "var handler = function (e) {};", errors: [tooShortError] },
        { code: "for (var i=0; i < 10; i++) { console.log(i); }", errors: [tooShortError] },
        { code: "var j=0; while (j > -10) { console.log(--j); }", errors: [tooShortError] },
        { code: "var [i] = arr;", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        { code: "var [,i,a] = arr;", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError, tooShortError] },
        { code: "function foo([a]) {}", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        { code: "import x from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        { code: "import { x as z } from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        { code: "import * as x from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        {
            code: "import longName from 'module';",
            options: [{ max: 5 }],
            languageOptions: { ecmaVersion: 6 },
            errors: [tooLongError]
        },
        {
            code: "import * as longName from 'module';",
            options: [{ max: 5 }],
            languageOptions: { ecmaVersion: 6 },
            errors: [tooLongError]
        },
        {
            code: "import { foo as longName } from 'module';",
            options: [{ max: 5 }],
            languageOptions: { ecmaVersion: 6 },
            errors: [tooLongError]
        },
        {
            code: "var _$xt_$ = Foo(42)",
            options: [{ min: 2, max: 4 }],
            errors: [
                tooLongError
            ]

Review comment (suggestion):
```suggestion
        { code: "import { x as z } from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [{ ...tooShortError, column: 15 }] },
        { code: "import { foo as z } from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [{ ...tooShortError, column: 17 }] },
        { code: "import { 'foo' as z } from 'module';", languageOptions: { ecmaVersion: 2022 }, errors: [{ ...tooShortError, column: 19 }] },
```

It would be good to check the `column` to verify that the right identifier is reported, and also add a test where the imported name is of a valid length and a test with string literal.

Code after:
                ecmaVersion: 6
            }
        },
        {
            code: "({ prop: o.𐌘 } = {});",
            options: [{ min: 1, max: 1 }],
            languageOptions: {
                ecmaVersion: 6
            }
        }
    ],
    invalid: [
        { code: "var x = 1;", errors: [tooShortError] },
        { code: "var x;", errors: [tooShortError] },
        { code: "obj.e = document.body;", errors: [tooShortError] },
        { code: "function x() {};", errors: [tooShortError] },
        { code: "function xyz(a) {};", errors: [tooShortError] },
        { code: "var obj = { a: 1, bc: 2 };", errors: [tooShortError] },
        { code: "try { blah(); } catch (e) { /* pass */ }", errors: [tooShortError] },
        { code: "var handler = function (e) {};", errors: [tooShortError] },
        { code: "for (var i=0; i < 10; i++) { console.log(i); }", errors: [tooShortError] },
        { code: "var j=0; while (j > -10) { console.log(--j); }", errors: [tooShortError] },
        { code: "var [i] = arr;", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        { code: "var [,i,a] = arr;", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError, tooShortError] },
        { code: "function foo([a]) {}", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        { code: "import x from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        { code: "import { x as z } from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [{ ...tooShortError, column: 15 }] },
        { code: "import { foo as z } from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [{ ...tooShortError, column: 17 }] },
        { code: "import { 'foo' as z } from 'module';", languageOptions: { ecmaVersion: 2022 }, errors: [{ ...tooShortError, column: 19 }] },
        { code: "import * as x from 'module';", languageOptions: { ecmaVersion: 6 }, errors: [tooShortError] },
        {
            code: "import longName from 'module';",
            options: [{ max: 5 }],
            languageOptions: { ecmaVersion: 6 },
            errors: [tooLongError]
        },
        {
            code: "import * as longName from 'module';",
            options: [{ max: 5 }],
            languageOptions: { ecmaVersion: 6 },
            errors: [tooLongError]
        },
        {
            code: "import { foo as longName } from 'module';",
            options: [{ max: 5 }],
            languageOptions: { ecmaVersion: 6 },
            errors: [{ ...tooLongError, column: 17 }]
        },
        {
            code: "var _$xt_$ = Foo(42)",
            options: [{ min: 2, max: 4 }],