简体   繁体   English

如何让ESLint在Sublime Text 3编辑器中运行React + Babel?

[英]How to get ESLint to work React + Babel in Sublime Text 3 editor?

I am using ReactJS and Babel. 我正在使用ReactJS和Babel。

Here is what I have in my .eslintrc.json: 这是我在.eslintrc.json中的内容:

{
"parser":"babel-eslint",
"env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "node": true
},
"extends": "eslint:recommended",
"parserOptions": {
    "ecmaFeatures": {
        "experimentalObjectRestSpread": true,
        "jsx": true
    },
    "sourceType": "module"
},
"plugins": [
    "react"
],
"rules": {

    "indent": [
        "error",
        "tab"
    ],
    "linebreak-style": [
        "error",
        "unix"
    ],
    "quotes": [
        "error",
        "double"
    ],
    "semi": [
        "error",
        "always"
    ]
}

} }

and in my package.json 在我的package.json中

{
  "name": "testing-site",
  "version": "1.0.0",
  "description": "to test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
"type": "git",
"url": "git+https://github.com/test/testing-site.git"
  },
  "author": "Joe Shmo",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/test/testing-site/issues"
  },
  "homepage": "https://github.com/test/testing-site#readme",
  "dependencies": {
    "express": "^4.13.4",
    "react": "^15.1.0",
    "react-dom": "^15.1.0",
    "react-redux": "^4.4.5",
    "redux": "^3.5.2"
  },
  "devDependencies": {
"babel-core": "^6.9.0",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react-hmre": "^1.1.1",
"eslint": "^2.11.0",
"eslint-plugin-react": "^5.1.1",
"react-hot-loader": "^1.3.0",
"redux-logger": "^2.6.1",
"redux-thunk": "^2.1.0",
"webpack": "^1.13.1",
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.10.0"
  }
}

I followed until 'Plug Installation' on https://github.com/roadhump/SublimeLinter-eslint But can't seem to get it operate still on Sublime Text 3. Also, did globally and save-dev for babel-eslint as well. 我跟着直到https://github.com/roadhump/SublimeLinter-eslint上的'Plug Installation'但似乎无法让它在Sublime Text 3上运行。此外,还为babel-eslint做了全局和save-dev 。

Also followed with the following site: http://jonathancreamer.com/setup-eslint-with-es6-in-sublime-text/ 随后是以下网站: http//jonathancreamer.com/setup-eslint-with-es6-in-sublime-text/

But it is deprecated as 'Sublime Text>Preferences>Package Settings' does not show downloaded Packages anymore. 但由于“Sublime Text> Preferences> Package Settings”不再显示已下载的Packages,因此不推荐使用它。

I am attempting to get the Sublime Text pick up on mainly syntax errors with the red dot showing whenever in such cases on Sublime Text, but still can't seem to figure it out even after many hours. 我试图让Sublime Text主要提到语法错误,红点显示Sublime Text的情况,但即使在很长时间之后仍然无法弄明白。 Any suggestions or guidance will be greatly appreciated. 任何建议或指导将不胜感激。 Thank you in advance. 先感谢您。

If you have installed both jslint and eslint in that case jslint is overriding eslint features. 如果在这种情况下同时安装了jslint和eslint,则jslint将覆盖eslint功能。

Press Command +Shift +P (mac) 按Command + Shift + P(mac)

Type 'disable' and select disable lint and enter 输入'disable'并选择disable lint并输入

You will get all jslint, eslint, json etc lists Click on jslint 您将获得所有jslint,eslint,json等列表单击jslint

Now it's configured to catch eslint syntax errors. 现在它被配置为捕获eslint语法错误。

In case you want to enable jslint again you need to follow same process by typing 'enable' 如果您想再次启用jslint,您需要输入'enable'来执行相同的过程

我有同样的问题,并通过安装反应插件修复它:

npm install eslint-plugin-react -g

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

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