我在每个文件的“import React”行中都有以下错误。
import React, { Component } from 'react'
错误如下:
Error while running ESlint: Cannot read property file: "path"
我已经尝试过类似问题的解决方案,但在我的情况下不起作用。
这是我的 .eslintrc 文件:
{
"extends": "airbnb",
"parser": "babel-eslint",
"plugins": [
"import",
"jsx-a11y",
"react"
],
"env": {
"jest": true,
"browser": true,
"node": true
},
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"global-require": 0,
"comma-dangle": 0,
"arrow-body-style": 0,
"space-before-function-paren": 0,
"import/no-extraneous-dependencies": 0,
"react/jsx-filename-extension": 1,
"react/forbid-prop-types": 1,
"jsx-a11y/anchor-has-content": 0
}
}
我尝试将此添加到我的文件中,但不起作用:
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": 2
}