[英]Can ESLint - Airbnb be installed on Ubuntu 16.04 Sublime Text 3
I don't why I am having such a difficult time trying to install ESLint, and I am starting to think it is because I am on Ubuntu. 我不为什么在安装ESLint时会遇到困难,而我开始认为这是因为我在Ubuntu上。
Basically, I wanted to use the the Airbnb JavaScript and/or Airbnb Ruby style guide for my code because it inconsistent, there is unused variables everywhere, and console.log
/ debugger
's everywhere, so I want to get a hold of that. 基本上,我想对代码使用Airbnb JavaScript和/或Airbnb Ruby样式指南,因为它们不一致,到处都有未使用的变量,而
console.log
/ debugger
到处都有,所以我想了解一下。
So initially I globally installed eslint, and then installed eslint-config-airbnb
using 所以最初我在全球范围内安装了eslint,然后使用以下命令安装了
eslint-config-airbnb
(
export PKG=eslint-config-airbnb;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)
I also installed all of these eslint
, eslint-plugin-import
, eslint-plugin-react
, and eslint-plugin-jsx-a11y.
我还安装了所有这些
eslint
, eslint-plugin-import
, eslint-plugin-react
和eslint-plugin-jsx-a11y.
Next, I created - or I think it was generated - the .eslintrc
file with only 接下来,我创建了-或者我认为它是生成的
.eslintrc
文件,仅
{
"extends": "airbnb"
}
I didn't really know what to do afterwards. 我真的不知道该怎么办。 Like, how do I know if I have the styles installed.
就像,如何知道我是否安装了样式。 I thought the next step would be to some how RUN the
.eslintrc
file so it knows what I want, thus, I did eslint app
and I also created a script in package.json
"lint": "eslint app"
but then it was giving me this issue, that: 我认为下一步应该是如何运行
.eslintrc
文件,以便它知道我想要的内容,因此,我做了eslint app
并且还在package.json
"lint": "eslint app"
创建了一个脚本,但后来给我这个问题,那是:
Error: Cannot find module 'eslint-config-airbnb'
And I was told that I shouldn't install it GLOBALLY. 有人告诉我,我不应该在全球范围内安装它。 Next , I removed it globally, and installed it in app directory in the dev tools, and it was giving me this issue:
接下来 ,我将其全局删除,并将其安装在开发工具的app目录中,这给了我这个问题:
bash: /home/dilraj/.nvm/versions/node/v6.2.1/bin/eslint: No such file or directory
I am starting to think that maybe it's a Ubuntu thing, because every time I google these problems they are from 2013-2015 and it is unclear to me why it is as such :( 我开始认为这可能是Ubuntu的事情,因为每次我搜索这些问题时,它们都是2013-2015年的结果,我不清楚为什么会这样:(
Hold Up!
耽误!
So I decided to install npm install -g eslint-config-airbnb
GLOBALLY, and it's giving me some further instructions. 因此,我决定在全球范围内安装
npm install -g eslint-config-airbnb
,它为我提供了进一步的说明。
Oops! Something went wrong! :(
ESLint couldn't find the plugin "eslint-plugin-jsx-a11y". This can happen for a couple different reasons:
1. If ESLint is installed globally, then make sure eslint-plugin-jsx-a11y is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin.
2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm i eslint-plugin-jsx-a11y@latest --save-dev
If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
You can install eslint-config-airbnb-bundle
globally. 您可以全局安装
eslint-config-airbnb-bundle
。 This is an Airbnb config bundled with ESLint for the sake of convenience and for solving some trouble with the installation. 这是与ESLint捆绑在一起的Airbnb配置 ,以方便使用并解决安装上的一些麻烦。 You'll also find instructions for Sublime Text 3:
您还将找到有关Sublime Text 3的说明:
https://www.npmjs.com/package/eslint-config-airbnb-bundle https://www.npmjs.com/package/eslint-config-airbnb-bundle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.