gpt4 book ai didi

reactjs - TSLint - 防止错误 : The key is not sorted alphabetically

转载 作者:搜寻专家 更新时间:2023-10-30 20:33:21 30 4
gpt4 key购买 nike

我正在使用 Ionic2/Cordova/Typescript/Angular 做一个测试应用程序。我正在使用 tslint 5.6.0

我正在使用以下模块: https://www.npmjs.com/package/tslint

只关注一个文件...

当 linting 以下文件时:

import { NgModule, ErrorHandler } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { IonicApp, IonicModule, IonicErrorHandler } from "ionic-angular";
import { MyApp } from "./app.component";

import { AboutPage } from "../pages/about/about";
import { ContactPage } from "../pages/contact/contact";
import { HomePage } from "../pages/home/home";
import { TabsPage } from "../pages/tabs/tabs";

import { StatusBar } from "@ionic-native/status-bar";
import { SplashScreen } from "@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 { }

我得到:

The key 'bootstrap' is not sorted alphabetically
RuleFailurePosition { position: 790, lineAndCharacter: { line: 25, character: 4 } }
RuleFailurePosition { position: 799, lineAndCharacter: { line: 25, character: 13 } }

我正在使用以下选项:

{
"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]
}
}
}

我需要在 TSLint 上配置什么选项来防止显示此错误?

最佳答案

这里失败的规则似乎是object-literal-sort-keys .

您应该能够在配置文件的规则部分通过添加来禁用它:

"object-literal-sort-keys": false

你可以找到所有的tslint规则here .

关于reactjs - TSLint - 防止错误 : The key is not sorted alphabetically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45792683/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com