相关疑难解决方法(0)

ESLint 不报告 TypeScript 编译器类型检查错误

寻求帮助将 TypeScript 编译器报告的类型错误放入 ESLint 的输出中。库 typescript-eslint ( https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md ) 让我觉得这应该是可能的。

文件结构

src/
  ... source files
  tsconfig.json
test/
  ... testing files
.eslintrc.js
package.json
tsconfig.json (symlink to src/tsconfig.json)
Run Code Online (Sandbox Code Playgroud)

.eslintrc.js

module.exports = {
  'env': {
    'jest': true,
    'node': true,
  },
  'extends': [
    'airbnb-typescript/base',
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
    'plugin:jest/recommended',
  ],
  'parser': '@typescript-eslint/parser',
  'parserOptions': {
    'project': ['./tsconfig.json'],
    'tsconfigRootDir': __dirname,
  },
  'plugins': [
    '@typescript-eslint',
    'jest',
  ],
  'root': true,
};
Run Code Online (Sandbox Code Playgroud)

包.json

{
  "name": "...",
  "version": "...",
  "description": "...",
  "scripts": {},
  "devDependencies": {
    "@types/jest": "^25.1.3",
    "@typescript-eslint/eslint-plugin": "^2.21.0",
    "@typescript-eslint/parser": "^2.21.0", …
Run Code Online (Sandbox Code Playgroud)

typechecking typescript eslint

21
推荐指数
1
解决办法
1万
查看次数

标签 统计

eslint ×1

typechecking ×1

typescript ×1