Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Named imports must be alphabetized - tslint

Tags:

tslint

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"
    ]
}
like image 296
fowulofito Avatar asked Jun 29 '18 14:06

fowulofito


3 Answers

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

"rules": {
  "ordered-imports": false
}
like image 104
Lukas Nespor Avatar answered Oct 18 '22 01:10

Lukas Nespor


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.

like image 28
coderpc Avatar answered Oct 18 '22 01:10

coderpc


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

like image 1
ebhh2001 Avatar answered Oct 18 '22 00:10

ebhh2001