简体   繁体   English

导入的ESLint规则错误

[英]ESLint rule error for import

I am getting the below error by eslint. 我正在通过eslint得到以下错误。

I have added ecmaFeatures: { "modules": true } in the .eslintrc file as well. ecmaFeatures: { "modules": true } .eslintrc文件中添加了ecmaFeatures: { "modules": true }

在此处输入图片说明

Because you're getting that message, it looks like you've upgraded to ESLint 2.0, which is great! 因为您收到该消息,所以看来您已升级到ESLint 2.0,这太好了! I can see two changes that you'll make to your configuration, though if anything else comes up, it's probably covered under the 2.0 migration guide : 我可以看到您将对配置进行两项更改,但是如果有其他问题,可能会在《 2.0迁移指南》中进行介绍

  1. In 2.0, "ecmaFeatures": { "modules": true } has become "parserOptions": { "sourceType": "module" } . 在2.0中, "ecmaFeatures": { "modules": true }已成为"parserOptions": { "sourceType": "module" }
  2. We replaced space-after-keywords with a new rule, keyword-spacing , which was introduced in one of the 2.0 betas. 我们用2.0 Beta之一中引入的新规则keyword-spacing替换了关键字后 空格 If you were using "space-after-keywords: 2 , you can change that to "keyword-spacing": 2 now. 如果您使用的是"space-after-keywords: 2 ,则可以立即将其更改为"keyword-spacing": 2

Putting that all together, your .eslintrc for ESLint 2.0 should include something like this: .eslintrc ,ESLint 2.0的.eslintrc应该包括以下内容:

{
    "parserOptions": {
        "sourceType": "module"
    },
    "env": {
        "es6": true
    },
    "rules": {
        "keyword-spacing": 2
    }
}

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

相关问题 Eslint 规则在 import 中添加新行 - Eslint rule to put a new line inside import 多行函数调用的eslint规则 - eslint rule for multiline function calls Eslint 给出错误:规则“严格”的配置无效:值“错误”是错误的类型 - Eslint gives error: Configuration for rule "strict" is invalid: Value "error" is the wrong type 将属性声明为样式时,Eslint react/no-typos 规则会抛出错误 - Eslint react/no-typos rule throw an error when declare a property as style 无法导入文件,出现 eslint 错误:“import”和“export”可能只出现在“sourceType:module”中 - Cant import files, get eslint error: 'import' and 'export' may appear only with 'sourceType: module' eslint规则来强制在块的顶部声明变量? - eslint rule to enforce that variables are declared at the top of the block? 错误eslint解析:意外的令牌eslint错误 - error eslint parsing: unexpected token eslint error VSCode ESLint 如何修复解析错误:'import' 和 'export' 可能只出现在顶层 - VSCode ESLint howto fix parsing error: 'import' and 'export' may only appear at the top level babel-eslint 不允许动态导入 - babel-eslint does not allow dynamic import 关于React组件的ESLint规则:方法渲染预期没有返回值 - ESLint Rule on React Component: Method Render expected no return value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM