简体   繁体   English

TSLint 不会抱怨缺少导入

[英]TSLint does not complain about missing imports

TSLint does not complain about missing imports (It is not ok with me leaving console.log statements in the code, however). TSLint 不会抱怨缺少导入(但是,我不能在代码中留下console.log语句)。 Linter says there is no problem with my code, but it does not compile. Linter 说我的代码没有问题,但它无法编译。 How to I configure TSLint to complain about missing import issues?如何配置 TSLint 以抱怨缺少导入问题?

This is my TSLint configuration:这是我的 TSLint 配置:

{
  "extends": ["tslint:latest", "tslint-react", "tslint-react-hooks", "tslint-config-prettier"],
  "rulesDirectory": [],
  "rules": {
    "max-line-length": {
      "options": [120]
    },
    "new-parens": true,
    "no-arg": true,
    "no-conditional-assignment": true,
    "no-consecutive-blank-lines": false,
    "no-console": {
      "severity": "warning",
      "options": ["debug", "log", "time", "timeEnd", "trace"]
    },
    "interface-name": false,
    "no-empty-interface": false,
    "object-literal-sort-keys": false,
    "arrow-parens": false,
    "no-namespace": false,
    "no-submodule-imports": false,
    "no-implicit-dependencies": false,
    "variable-name": false,
    "no-conditional-assignment": false,
    "jsx-no-lambda": false,
    "only-arrow-functions": false,
    "object-literal-sort-keys": false,
    "ordered-imports": false,
    "no-string-literal": false,
    "no-bitwise": false,
    "ban-types": {
      "options": []
    },
    "typedef": true,
    "prefer-for-of": false,
    "no-duplicate-imports": false,
    "no-empty": { "severity": "warning" },
    "no-require-imports": { "severity": "warning" },
    "no-var-requires": { "severity": "warning" }
  },
  "jsRules": {
    "max-line-length": {
      "options": [120]
    },
    "no-console": {
      "severity": "warning",
      "options": ["debug", "log", "time", "timeEnd", "trace"]
    }
  }
}

i think the reason is you or the lib declare what your import content in the somewhere like .d.ts .我认为原因是您或 lib 在.d.ts之类的地方declare了您的导入内容。 in this case the typescript type system can not complain about it if you did not import because it maybe the global one.在这种情况下,如果您没有导入 typescript 类型系统,则不会抱怨它,因为它可能是全局系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM