作出反應的Atom編輯我安裝了以下插件如何配置ESLint上的Atom編輯
- 棉短絨
- 棉短絨,eslint
似乎他們不承認JSX大成。
我讓它在命令行上工作,但不得不使用其他插件,如esprima-fb
和eslint-plugin-react
。看起來像Atom Editor沒有這樣的插件,並想知道你們中的任何人是否知道一種方法來解決這個問題。
作出反應的Atom編輯我安裝了以下插件如何配置ESLint上的Atom編輯
似乎他們不承認JSX大成。
我讓它在命令行上工作,但不得不使用其他插件,如esprima-fb
和eslint-plugin-react
。看起來像Atom Editor沒有這樣的插件,並想知道你們中的任何人是否知道一種方法來解決這個問題。
要獲得Eslint與React.js工作很好:
npm install eslint-plugin-react
"plugins": ["react"]
您.eslintrc配置文件"ecmaFeatures": {"jsx": true}
到您的.eslintrc配置文件這裏是一個.eslintrc
配置文件的一個例子:
{
"env": {
"browser": true,
"node": true
},
"globals": {
"React": true
},
"ecmaFeatures": {
"jsx": true
},
"plugins": [
"react"
]
}
我使用Eslint V1.1.0的時刻。
旁註: 我不得不同時安裝eslint和eslint,插件,反應爲項目依賴關係(例如,npm install eslint eslint-plugin-react --save-dev
)。希望這有助於。
我使用Atom,它工作得很好。您只需在項目根目錄中輸入.eslintrc
即可告訴ESLint您正在使用eslint-plugin-react
。
更新答案2016年:只需安裝react
包Atom和項目中的根添加.eslintrc
文件(或在您的家目錄)包含以下內容:
{
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true
}
}
,並重新打開包含的任何文件JSX,它應該工作。
謝謝!它完美地工作 – brunetton
你能在這裏添加更多細節嗎? – SuperUberDuper
包名稱現在就是'react'https://orktes.github.io/atom-react/ – Krishnan
您需要編輯一個項目本地.eslintrc
文件,該文件將由ESLint提取。如果你想與Atom集成,你可以安裝插件linter和linter-eslint。
快速設置ESLint爲陣營的最佳做法,目前最好的辦法是安裝NPM包eslint-plugin-react
並擴大其recommended
配置,而不是手動切換許多規則:
{
"extends": [ "eslint:recommended", "plugin:react/recommended" ],
"plugins": [ "react" ]
}
這將使eslint-plugin-react
和推薦規則從ESLint &反應預設。最新的ESLint user-guide本身有更多有價值的信息。
下面是用於優化ES6解析器選項和的WebPack一個例子:
{
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {
"impliedStrict": true,
"experimentalObjectRestSpread": true,
"jsx": true
}
}
}
對於Mac用戶:轉到原子 - >偏好 - >安裝 - >搜索包棉短絨-eslint - >點擊安裝
對於Ubuntu的用戶:轉到編輯 - >首選項 - >安裝 - >搜索包短絨-eslint - >點擊安裝
去ŧ o命令行---> npm install --save-dev eslint-config-rallycoding
來原子製作新文件.eslintrc並擴展rallycoding。
你有沒有遇到過「ESLint Parsing error:Unexpected token」? – efkan
除了喬恩的名單,我不得不安裝[原子反應插件](http://orktes.github.io/atom-react/) – Dmitry
我得到導入錯誤'導入反應,{組件}從'反應' ;'配置好像你說的那樣。 –