javascript - typescript 。 ESLint 不适用于类型

标签 javascript typescript tslint

所以我无法理解如何进行标准化并激活 tslint.json 中的半规则检查选项。因为目前它不会检查 TypeScript 中的 Types 也不会产生任何错误。同样在 Interfaces 中,它正常工作,并且当我使用与 ; 不同的东西时会抛出错误,那么我怎样才能为 Types 制作它呢? ..

export type IProps = {
    active?: boolean, // no error
    title?: string; // no error
    text?: string // no error
}

tslint.json:

{
  "defaultSeverity": "error",
  "extends": [
    "tslint-config-airbnb",
    "tslint-eslint-rules",
    "tslint-react"
  ],
  "jsRules": {},
  "rulesDirectory": [],
  "rules": {
    "arrow-parens": false,
    "whitespace": [
      false,
      "check-branch",
      "check-decl",
      "check-operator",
      "check-separator",
      "check-type"
    ],
  }
}

最佳答案

您正在寻找type-literal-delimiter rule 。只需在 tslint.json 中将其从 false 更改为 true 即可。

关于javascript - typescript 。 ESLint 不适用于类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52761418/

相关文章:

javascript - 如何使用 Angular 显示 "tags"对象的内容?

javascript - Angular:Http 与 fetch api

javascript - 确保导入在 Typescript 中有效?

typescript - 当 tslint 中的 "no-floating-promises"为真时如何忽略 Jasmine promise

javascript - jPlayer 运行轨道名称的 onclick 函数

javascript - 在电子邮件正文中开始一个新段落

angular - 错误 TS2742 : The inferred type of 'username' cannot be named without a reference to '.../node_modules/@angular/forms/forms'

javascript - For 循环不起作用

javascript - 将 CSS 设置为动态创建的类

typescript - 不要使用对象作为类型