typescript - TSLint - Preventing error: The key is not sorted alphabetically -
i'm doing test app ionic2 / cordova / typescript / angular. i'm using tslint 5.6.0.
i'm using following module: https://www.npmjs.com/package/tslint
focusing on 1 file...
when linting following file:
import { ngmodule, errorhandler } "@angular/core"; import { browsermodule } "@angular/platform-browser"; import { ionicapp, ionicmodule, ionicerrorhandler } "ionic-angular"; import { myapp } "./app.component"; import { aboutpage } "../pages/about/about"; import { contactpage } "../pages/contact/contact"; import { homepage } "../pages/home/home"; import { tabspage } "../pages/tabs/tabs"; import { statusbar } "@ionic-native/status-bar"; import { splashscreen } "@ionic-native/splash-screen"; @ngmodule( { declarations: [ myapp, aboutpage, contactpage, homepage, tabspage, ], imports: [ browsermodule, ionicmodule.forroot( myapp ), ], bootstrap: [ ionicapp ], entrycomponents: [ myapp, aboutpage, contactpage, homepage, tabspage, ], providers: [ statusbar, splashscreen, { provide: errorhandler, useclass: ionicerrorhandler }, ], }) export class appmodule { }
i get:
the key 'bootstrap' not sorted alphabetically rulefailureposition { position: 790, lineandcharacter: { line: 25, character: 4 } } rulefailureposition { position: 799, lineandcharacter: { line: 25, character: 13 } }
i'm using following options:
{ "extends": "tslint:recommended", "rules": { "no-duplicate-variable": true, "max-line-length": { "options": [120] }, "ordered-imports": false, "new-parens": true, "no-arg": true, "no-bitwise": true, "no-conditional-assignment": true, "no-consecutive-blank-lines": false, "no-console": { "options": [ "debug", "info", "log", "time", "timeend", "trace" ] } }, "jsrules": { "max-line-length": { "options": [120] } } }
what option need configure on tslint prevent showing error?
the rule failing here seems object-literal-sort-keys.
you should able disable in rules section of config file adding:
"object-literal-sort-keys": false
you can find tslint rules here.
Comments
Post a Comment