简体   繁体   English

一起使用create-react-app和Sublimelinter ESlint

[英]using create-react-app and Sublimelinter ESlint together

I use facebook's create-react-app , which intentionally hide all the configuration setup, and leave us with a lovely simple file structure 我使用了facebook的create-react-app ,它有意隐藏了所有配置设置,并为我们提供了一个可爱的简单文件结构

一个可爱的文件结构

That's great! 那很棒! but there's one really annoying thing that come up: 但是出现了一件非常烦人的事情:

SublimeLinter is no longer works because the .eslintrc configuration file is not longer at the root of the project. SublimeLinter不再起作用,因为.eslintrc配置文件不再位于项目的根目录下。

Key points 关键点

  • I know I can put another .eslintrc file at the root, but I would like to be able to set my rules in one place 我知道我可以在根目录下放置另一个.eslintrc文件,但是我希望能够在一个地方设置规则

  • I know it is possible to npm eject to get the entire project structure out in front, but I would like to keep things simple. 我知道可以通过npm eject整个项目结构,但我想保持简单。 otherwise it becomes just another boilerplate 否则,它将成为另一个样板

  • I noticed that in the package.json 我在package.json中注意到了 package.json内部的线索

What I already tried? 我已经尝试了什么?

a direction I thought about is to change: 我想到的方向是改变:

"eslintConfig": {
   "extends": "./node_modules/react-scripts/config/eslint.js"
}

to: 至:

"eslintConfig": {
   "extends": "./.eslintrc.js"
}

but it seems to require all the eslint-plugins (which are magically hidden from node_modules ) so I'm not sure it's the right way. 但是它似乎需要所有eslint插件(它们从node_modules中神奇地隐藏了),所以我不确定这是正确的方法。

Any insights? 有什么见解吗?

SublimeLinter is no longer works because the .eslintrc configuration file is not longer at the root of the project. SublimeLinter不再起作用,因为.eslintrc配置文件不再位于项目的根目录下。

This is not correct. 这是不正确的。

SublimeLinter will work just fine but you currently have to install a few things globally. SublimeLinter可以正常工作, 但是您当前必须在全局安装一些东西。 The generated project's README includes the instructions to get linter IDE integration working : 生成的项目的README包括使linter IDE集成正常工作的说明

Finally, you will need to install some packages globally: 最后,您将需要全局安装一些软件包:

 npm install -g eslint babel-eslint eslint-plugin-react eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-flowtype 

We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. 我们认识到这是次优的,但是由于我们隐藏ESLint依赖项的方式,当前需要这样做。 The ESLint team is already working on a solution to this so this may become unnecessary in a couple of months. ESLint团队已经在研究此问题的解决方案,因此可能在几个月后就不需要这样做了。

This is, of course, assuming that you're fine with the ESLint configuration we picked for you. 当然,这是假设您对我们为您选择的ESLint配置很好。

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

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