简体   繁体   English

ESlint 和 typescript 集成问题

[英]ESlint and typescript integration issues

I have the following problem I am trying to integrate typescript with ESlint, I have done it by installing eslint package with some additional packages basing mainly on a tutorial ( tutorial if it turns out to be helpful I can paste a link.Then after using eslint --init command I generated a file .eslintrc , where had all my configurations included. My goal is to have underline in my VScode Editor using Eslint. As a extra info when I use eslint --fix command it returns errors/warnings so its only underlining我有以下问题我正在尝试将 typescript 与 ESlint 集成,我已经通过安装 eslint package 和一些主要基于教程的附加包来完成它(如果它证明有帮助,我可以粘贴链接。然后在使用 eslint --init 命令我生成了一个文件.eslintrc ,其中包含了我的所有配置。我的目标是使用 Eslint 在我的 VScode 编辑器中添加下划线。作为额外信息,当我使用 eslint --fix 命令时,它会返回错误/警告,因此它只下划线

I have typescript installed locally also tried globally, all necessary plugins also, deleting node_modules/checking versions of packages - don't have an idea what's wrong here.我在本地安装了 typescript 也尝试了全局,所有必要的插件也,删除 node_modules/检查包的版本 - 不知道这里有什么问题。 Would be very grateful for even some insights.非常感谢您提供一些见解。 I am using Mac pro with Mojave 10.14.6 Regards!我正在使用 Mac pro 和 Mojave 10.14.6 问候!

.eslintrc.json: .eslintrc.json:

{
    "env": {
        "es6": true,
        "node": true
    },
    "extends": [
        "airbnb-base",
        "plugin:@typescript-eslint/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 2018,
        "sourceType": "module",
        "jsx": true
    },
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {}
}

Unfortunately when Eslint starts still gets this kind of error in terminal output tab:不幸的是,当 Eslint 启动时,终端 output 选项卡中仍然出现这种错误:

[Error - 11:44:47 PM] Failed to load plugin '@typescript-eslint' declared in 'project-name'/.eslintrc.json': Cannot find module 'typescript' Referenced from: /Users/MyUser/Desktop/project-name/project-name-backend/.eslintrc.json [错误 - 晚上 11:44:47] 无法加载在 'project-name'/.eslintrc.json' 中声明的插件 '@typescript-eslint':找不到模块 'typescript' 引用自:/Users/MyUser/Desktop/项目名称/项目名称后端/.eslintrc.json

Have you tried installing the missing module alone?您是否尝试过单独安装缺少的模块? Try re-installing the packages giving the issues as they may have been corrupted.尝试重新安装出现问题的软件包,因为它们可能已损坏。 You could also run npm audit to repair corrupted files.您还可以运行 npm 审计来修复损坏的文件。

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

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