【问题标题】:Eslint in Atom errors out on valid JSX syntaxAtom 中的 Eslint 在有效的 JSX 语法上出错
【发布时间】:2019-04-17 20:08:39
【问题描述】:

在过去两周的某个时间点,eslint 开始将这些行标记为错误,我无法准确指出造成这种情况的确切原因。

我的操作系统(Arch)更新了好几次,package.json 包也有零星的更新。

我什至不得不强制 Atom 正确识别我的 JSX 文件(使用 JSX 语法),因为默认 Javascript 语法的语法突出显示也被破坏了。

我已经尝试完全删除 atom 包以及配置,但我正在使用 Atom 包sync-settings 来备份和恢复我的配置。

return <InputFloat
  className='inline-block'
         ^^^^^^ Parsing error: Unexpected token = (Fatal)
  name={attribute.name}
  value={attribute.value}
  onChange={this.props.onChange}
/>

解析错误:Unexpected token = (Fatal)

package.json

"devDependencies": {
  "eslint": "^5.9.0",
  "eslint-config-standard": "^11.0.0",
  "eslint-plugin-import": "^2.14.0",
  "eslint-plugin-node": "^6.0.1",
  "eslint-plugin-promise": "^3.8.0",
  "eslint-plugin-react": "^7.11.1",
  "eslint-plugin-standard": "^3.1.0",
}

.eslintrc.json

{
  "env" : {
    "browser": true,
    "node": false
  },
  "globals" : {
    "Module": true
  },
  "plugins": [
    "react"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "standard"
  ],
  "parserOptions": {
        "ecmaVersion": 10,
        "sourceType": "module",
        "ecmaFeatures": {
            "jsx": true
        }
    },
  "rules": {
    "no-console": "warn",
    "no-undef": 0,
    "no-path-concat": 0,
    "react/prop-types": 0,
    "no-new-func": 0,
    "no-debugger": 0,
    "no-template-curly-in-string": "warn"
  }
}

package-lock.json

  "eslint": {
    "version": "5.9.0",
    "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.9.0.tgz",
    "integrity": "sha512-g4KWpPdqN0nth+goDNICNXGfJF7nNnepthp46CAlJoJtC5K/cLu3NgCM3AHu1CkJ5Hzt9V0Y0PBAO6Ay/gGb+w==",....
  }

原子

$ atom --version
原子:1.32.2 电子:2.0.12 铬:61.0.3163.100 节点:8.9.3

Eslint

$ ./node_modules/.bin/eslint --version v5.9.0

Atom / linter-eslint

8.4.1

Atom 配置

gist.github.com

【问题讨论】:

    标签: reactjs atom-editor jsx eslint


    【解决方案1】:

    也许有帮助。尝试安装“babel-eslint”,然后将"parser": "babel-eslint", 添加到您的 .eslintrc.json 文件中

    【讨论】:

      猜你喜欢
      • 2018-12-23
      • 2015-07-24
      • 2016-09-09
      • 2017-06-10
      • 2021-09-05
      • 2018-08-05
      • 1970-01-01
      • 1970-01-01
      • 2020-10-10
      相关资源
      最近更新 更多