Taro: 使用@typescript-eslint/eslint-plugin导致eslint失效

Created on 28 Apr 2019  ·  5Comments  ·  Source: NervJS/taro

问题描述
[问题描述:站在其它人的角度尽可能清晰地、简洁地把问题描述清楚]
在eslint配置中增加@typescript-eslint/eslint-plugin后,eslint检测全失效,即使不符合eslint的规则的代码也不会提示错误

复现步骤
[复现问题的步骤]

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

[或者可以直接贴源代码,能贴文字就不要截图]

yarn add @typescript-eslint/eslint-plugin -D
// .eslintrc.js
module.exports = {
  ...
  plugins: ['@typescript-eslint'],
  extends: ['eslint:recommended', 'airbnb', 'taro', 'plugin:@typescript-eslint/recommended'],
  ...
}


// 这里可以贴代码,不要删除上面和下面的三个 "`"


期望行为
[这里请用简洁清晰的语言描述你期望的行为]
可以正常使用 @typescript-eslint

报错信息
[这里请贴上你的完整报错截图或文字]
不符合eslint的规则的代码不会提示错误

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。

  • 操作系统: [e.g. Windows 10] windows 10
  • Taro 版本 [e.g. v.0.0.64] v1.2.26
  • Node.js 版本 [e.g. v9.0.0] v10.14.1
  • 报错平台 [h5, weapp] all

    • Yarn版本 v1.12.3

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

question

Most helpful comment

升级eslint到5.x版本

All 5 comments

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

这是我的配置

{
  "extends": [
    "taro",
    "plugin:@typescript-eslint/recommended",
    "prettier",
    "prettier/@typescript-eslint"
  ],
  "rules": {
    "no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
  },
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"],
  "parserOptions": {
    "project": "./tsconfig.json"
  }
}

这不是一个和 Taro 相关的问题,运行不了的 ESLint 的原因有很多,你的编辑器可能有问题,编辑器插件可能有问题,ESLint 插件也可能有问题。但最大的可能性是你没有装好 @typescript-eslint 的相关依赖或者没有设置正确。

你可以把你的报错贴到 ESLint 或 @typescript-eslint 的仓库去。

升级eslint到5.x版本

eslint升级到最新版,
vscode-eslint 添加 eslint.validate配置,添加typescript,和typescriptreact

Was this page helpful?
0 / 5 - 0 ratings