-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a shareable ESLint configuration package #689
Changes from 8 commits
a4b4fe3
603cff0
2d2e7af
5c9f7ac
8dbfe66
7e55f86
e2dc36e
cfa6880
f2665d8
2db2ebe
0881de1
5c4458c
996bf67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./packages/eslint-config-react-app/index.js" | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# eslint-config-react-app | ||
|
||
This package includes the shareable ESLint configuration used by [Create React App](https://github.com/facebookincubator/create-react-app). | ||
|
||
## Installation | ||
|
||
*The easiest way to use this configuration is with [Create React App](https://github.com/facebookincubator/create-react-app), which includes it by default – you* **don't need to install it separately in Create React App projects.** | ||
|
||
If you want to use this ESLint configuration in a project not built with Create React App, you can install it with following steps. | ||
|
||
1. Install this package, ESLint and the necessary plugins: | ||
|
||
``` | ||
npm install eslint-config-react-app babel-eslint@6.1.2 eslint@3.5.0 eslint-plugin-flowtype@2.18.1 eslint-plugin-import@1.12.0 eslint-plugin-jsx-a11y@2.2.2 eslint-plugin-react@5.2.2 --save-dev | ||
``` | ||
|
||
2. Create a file named `.eslintrc` with following contents in the root folder of your project: | ||
|
||
``` | ||
{ | ||
"extends": "react-app" | ||
} | ||
``` | ||
|
||
That's it! You can override the settings from `eslint-config-react-app` by editing the `.eslintrc` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll also want a readme here, explaining in a few words how to use this package as standalone. |
||
"name": "eslint-config-react-app", | ||
"version": "0.4.3", | ||
"description": "ESLint configuration used by Create React App", | ||
"repository": "facebookincubator/create-react-app", | ||
"license": "BSD-3-Clause", | ||
"bugs": { | ||
"url": "https://github.com/facebookincubator/create-react-app/issues" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"peerDependencies": { | ||
"babel-eslint": "6.1.2", | ||
"eslint": "3.5.0", | ||
"eslint-plugin-flowtype": "2.18.1", | ||
"eslint-plugin-import": "1.12.0", | ||
"eslint-plugin-jsx-a11y": "2.2.2", | ||
"eslint-plugin-react": "5.2.2" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "react-app" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,11 +165,13 @@ module.exports = { | |
} | ||
] | ||
}, | ||
// @remove-on-eject-begin | ||
// Point ESLint to our predefined config. | ||
eslint: { | ||
configFile: path.join(__dirname, 'eslint.js'), | ||
configFile: path.join(__dirname, '../.eslintrc'), | ||
useEslintrc: false | ||
}, | ||
// @remove-on-eject-end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we need this for prod config too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We copy the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't mean ejected, I meant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, great point. I forgot we had ESLint for the build too. Updated now. |
||
// We use PostCSS for autoprefixing only. | ||
postcss: function() { | ||
return [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having to install all the dependencies separately like this is ridiculous, but until ESLint supports plugin dependencies for shareable configs, there isn't anything we can do about it, I'm afraid :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do the same trick as here: https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb#eslint-config-airbnb-1. I'm just not sure what the Windows version would be like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could write it in JS and have a
node -e '<SCRIPT>'
here, so it would be the same for Windows? I assume everyone who is going to use this will havenode
installed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having the command that you can copy paste to your console here is better than that trick, as long as we keep the version numbers up-to-date. It's a bit more work for us, but easier for the users.