How to disable Named imports must be alphabetized - tslint
Asked Answered
A

3

13

How to disable Named imports must be alphabetized - tslint ?

I am getting error:

Named imports must be alphabetized.

I don't know how to disable this error.

My tsconfig.json configuration is:

{
    "compilerOptions": {
        "baseUrl": ".",
        "outDir": "build/dist",
        "module": "esnext",
        "target": "es5",
        "lib": [
            "es6",
            "dom"
        ],
        "sourceMap": true,
        "allowJs": true,
        "jsx": "react",
        "moduleResolution": "node",
        "rootDir": "src",
        "forceConsistentCasingInFileNames": true,
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "noImplicitAny": false,
        "strictNullChecks": false,
        "suppressImplicitAnyIndexErrors": true,
        "noUnusedLocals": true
    },
    "exclude": [
        "node_modules",
        "build",
        "scripts",
        "acceptance-tests",
        "webpack",
        "jest",
        "src/setupTests.ts"
    ]
}
Armes answered 29/6, 2018 at 14:21 Comment(0)
B
19

Open tslint.json and add ordered-imports to rules and restart the server (npm) if is running.

"rules": {
  "ordered-imports": false
}
Blackman answered 9/10, 2018 at 11:38 Comment(0)
M
2

From this Rule of ordered-imports

Named imports must be alphabetized (i.e. “import {A, B, C} from “foo”;”)

  • The exact ordering can be controlled by the named-imports-order option.
  • “longName as name” imports are ordered by “longName”.

Add this line to your tsconfig file:

"rules": {
    "named-imports-order": "any"
 }

Hope it helps.

Merilee answered 29/6, 2018 at 14:42 Comment(3)
error TS5023: Unknown compiler option 'named-imports-order'.Armes
see if this link helps you. Also, I have updated my answer.Merilee
Unknown compiler option 'ordered-imports'. Any help?Luzon
R
1

"ordered-imports": false, works for me in VS Code.

Rheumatic answered 14/8, 2018 at 19:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.