Skip to content

Commit 89facb4

Browse files
[Breaking] add “base”, add “rules/prettier”, break index to require prettier
Co-authored-by: Sharmila <tosharmila@gmail.com> Co-authored-by: Jordan Harband <ljharb@gmail.com>
1 parent cb9707f commit 89facb4

File tree

16 files changed

+399
-22
lines changed

16 files changed

+399
-22
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@ script:
1717
sudo: false
1818
env:
1919
matrix:
20+
- 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-prettier'
2021
- 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base'
2122
- 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb'
2223
- 'TEST=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb'
24+
- 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-prettier'
2325
- 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base'
2426
- 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb'
2527
- 'TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb'
2628
matrix:
2729
fast_finish: true
2830
include:
31+
- node_js: "lts/*"
32+
env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-prettier
2933
- node_js: "lts/*"
3034
env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base
3135
- node_js: "lts/*"
3236
env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb
3337
- node_js: "lts/*"
3438
env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb
39+
- node_js: "lts/*"
40+
env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-prettier
3541
- node_js: "lts/*"
3642
env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base
3743
- node_js: "lts/*"
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
{
2+
"root": true,
23
"extends": "./index.js",
3-
"rules": {
4-
// disable requiring trailing commas because it might be nice to revert to
5-
// being JSON at some point, and I don't want to make big changes now.
6-
"comma-dangle": 0,
7-
},
84
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
extends: [
3+
'./rules/best-practices',
4+
'./rules/errors',
5+
'./rules/node',
6+
'./rules/style',
7+
'./rules/variables',
8+
'./rules/es6',
9+
'./rules/imports',
10+
'./rules/strict',
11+
].map(require.resolve),
12+
parserOptions: {
13+
ecmaVersion: 2018,
14+
sourceType: 'module',
15+
},
16+
rules: {},
17+
};
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
11
module.exports = {
2-
extends: [
3-
'./rules/best-practices',
4-
'./rules/errors',
5-
'./rules/node',
6-
'./rules/style',
7-
'./rules/variables',
8-
'./rules/es6',
9-
'./rules/imports',
10-
'./rules/strict',
11-
].map(require.resolve),
12-
parserOptions: {
13-
ecmaVersion: 2018,
14-
sourceType: 'module',
15-
},
16-
rules: {},
2+
extends: ['./base', './rules/prettier'].map(require.resolve),
173
};

packages/eslint-config-airbnb-base/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,23 @@
6060
"eslint": "^5.16.0 || ^6.7.2",
6161
"eslint-find-rules": "^3.4.0",
6262
"eslint-plugin-import": "^2.20.1",
63+
"eslint-plugin-prettier": "^3.1.2",
6364
"in-publish": "^2.0.0",
6465
"safe-publish-latest": "^1.1.4",
6566
"tape": "^5.0.0-next.4"
6667
},
6768
"peerDependencies": {
6869
"eslint": "^5.16.0 || ^6.7.2",
69-
"eslint-plugin-import": "^2.20.1"
70+
"eslint-plugin-import": "^2.20.1",
71+
"eslint-plugin-prettier": "^3.1.2"
7072
},
7173
"engines": {
72-
"node": ">= 6"
74+
"node": ">= 8.10"
7375
},
7476
"dependencies": {
7577
"confusing-browser-globals": "^1.0.9",
78+
"eslint-config-prettier": "^6.10.0",
79+
"prettier": "^1.19.1",
7680
"object.assign": "^4.1.0",
7781
"object.entries": "^1.1.1"
7882
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
extends: ['prettier'],
3+
plugins: ['prettier'],
4+
rules: {
5+
// Prettier Rule + Prettier config overrides
6+
'prettier/prettier': [
7+
'error',
8+
{
9+
arrowParens: 'always',
10+
bracketSpacing: true,
11+
jsxBracketSameLine: false,
12+
printWidth: 100,
13+
proseWrap: 'preserve',
14+
requirePragma: false,
15+
semi: true,
16+
singleQuote: true,
17+
tabWidth: 2,
18+
trailingComma: 'all',
19+
useTabs: false,
20+
},
21+
{
22+
usePrettierrc: false,
23+
},
24+
],
25+
},
26+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["airbnb"]
3+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf
10+
# editorconfig-tools is unable to ignore longs strings or urls
11+
max_line_length = null
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./index.js",
3+
"rules": {
4+
// disable requiring trailing commas because it might be nice to revert to
5+
// being JSON at some point, and I don't want to make big changes now.
6+
"comma-dangle": 0,
7+
},
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2012 Airbnb
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# eslint-config-airbnb-base
2+
3+
[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](http://badge.fury.io/js/eslint-config-airbnb-base)
4+
5+
This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config.
6+
7+
## Usage
8+
9+
We export two ESLint configurations for your usage.
10+
11+
### eslint-config-airbnb-base
12+
13+
Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`.
14+
15+
1. Install the correct versions of each package, which are listed by the command:
16+
17+
```sh
18+
npm info "eslint-config-airbnb-base@latest" peerDependencies
19+
```
20+
21+
If using **npm 5+**, use this shortcut
22+
23+
```sh
24+
npx install-peerdeps --dev eslint-config-airbnb-base
25+
```
26+
27+
If using **yarn**, you can also use the shortcut described above if you have npm 5+ installed on your machine, as the command will detect that you are using yarn and will act accordingly.
28+
Otherwise, run `npm info "eslint-config-airbnb-base@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev <dependency>@<version>` for each listed peer dependency.
29+
30+
31+
If using **npm < 5**, Linux/OSX users can run
32+
33+
```sh
34+
(
35+
export PKG=eslint-config-airbnb-base;
36+
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
37+
)
38+
```
39+
40+
Which produces and runs a command like:
41+
42+
```sh
43+
npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
44+
```
45+
46+
If using **npm < 5**, Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool.
47+
48+
```sh
49+
npm install -g install-peerdeps
50+
install-peerdeps --dev eslint-config-airbnb-base
51+
```
52+
53+
The cli will produce and run a command like:
54+
55+
```sh
56+
npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
57+
```
58+
59+
2. Add `"extends": "airbnb-base"` to your .eslintrc.
60+
61+
### eslint-config-airbnb-base/legacy
62+
63+
Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
64+
65+
1. Install the correct versions of each package, which are listed by the command:
66+
67+
```sh
68+
npm info "eslint-config-airbnb-base@latest" peerDependencies
69+
```
70+
71+
Linux/OSX users can run
72+
```sh
73+
(
74+
export PKG=eslint-config-airbnb-base;
75+
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
76+
)
77+
```
78+
79+
Which produces and runs a command like:
80+
81+
```sh
82+
npm install --save-dev eslint-config-airbnb-base eslint@^3.0.1 eslint-plugin-import@^1.10.3
83+
```
84+
85+
2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc
86+
87+
See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's JavaScript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information.
88+
89+
### eslint-config-airbnb-base/whitespace
90+
91+
This entry point only errors on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js).
92+
93+
## Improving this config
94+
95+
Consider adding test cases if you're making complicated rules changes, like anything involving regexes. Perhaps in a distant future, we could use literate programming to structure our README as test cases for our .eslintrc?
96+
97+
You can run tests with `npm test`.
98+
99+
You can make sure this module lints with itself using `npm run lint`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
extends: [
3+
'eslint-config-airbnb-base',
4+
'./rules/prettier',
5+
].map(require.resolve),
6+
rules: {}
7+
};
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"name": "eslint-config-airbnb-prettier",
3+
"version": "13.2.0",
4+
"description": "Airbnb's base JS ESLint config, following our styleguide",
5+
"main": "index.js",
6+
"scripts": {
7+
"prelint": "editorconfig-tools check * rules/* test/*",
8+
"lint": "eslint --report-unused-disable-directives .",
9+
"pretests-only": "node ./test/requires",
10+
"tests-only": "babel-tape-runner ./test/test-*.js",
11+
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest",
12+
"pretest": "npm run --silent lint",
13+
"test": "npm run --silent tests-only",
14+
"pretravis": ":",
15+
"travis": "npm run --silent test",
16+
"posttravis": ":"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/airbnb/javascript"
21+
},
22+
"keywords": [
23+
"eslint",
24+
"eslintconfig",
25+
"config",
26+
"airbnb",
27+
"javascript",
28+
"styleguide",
29+
"es2015",
30+
"es2016",
31+
"es2017",
32+
"es2018"
33+
],
34+
"author": "Sharmila Jesupaul (jesupaul.com)",
35+
"contributors": [
36+
{
37+
"name": "Jordan Harband",
38+
"email": "ljharb@gmail.com",
39+
"url": "http://ljharb.codes"
40+
}
41+
],
42+
"license": "MIT",
43+
"bugs": {
44+
"url": "https://github.com/airbnb/javascript/issues"
45+
},
46+
"homepage": "https://github.com/airbnb/javascript",
47+
"devDependencies": {
48+
"babel-preset-airbnb": "^2.6.0",
49+
"babel-tape-runner": "^2.0.1",
50+
"editorconfig-tools": "^0.1.1",
51+
"eslint": "^4.19.1 || ^5.3.0",
52+
"eslint-config-prettier": "^6.10.0",
53+
"eslint-find-rules": "^3.4.0",
54+
"eslint-plugin-import": "^2.18.0",
55+
"eslint-plugin-prettier": "^3.1.2",
56+
"in-publish": "^2.0.0",
57+
"prettier": "^1.19.1",
58+
"safe-publish-latest": "^1.1.2",
59+
"tape": "^4.11.0"
60+
},
61+
"peerDependencies": {
62+
"eslint": "^5.16.0 || ^6.7.2",
63+
"eslint-config-prettier": "^6.10.0",
64+
"eslint-plugin-import": "^2.20.1",
65+
"eslint-plugin-prettier": "^3.1.2",
66+
"prettier": "^1.19.1"
67+
},
68+
"engines": {
69+
"node": ">= 6"
70+
},
71+
"dependencies": {
72+
"eslint-config-airbnb-base": "^14.0.0",
73+
"confusing-browser-globals": "^1.0.7",
74+
"object.assign": "^4.1.0",
75+
"object.entries": "^1.1.0"
76+
}
77+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eslint-disable no-async-promise-executor, no-useless-catch, no-misleading-character-class */
2+
3+
module.exports = {
4+
extends: ['prettier', 'prettier/react'],
5+
plugins: ['prettier'],
6+
// View link below for react rules documentation
7+
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
8+
rules: {
9+
// Prettier Rule + Prettier config overrides
10+
'prettier/prettier': [
11+
'error',
12+
{
13+
arrowParens: 'always',
14+
bracketSpacing: true,
15+
jsxBracketSameLine: false,
16+
printWidth: 100,
17+
proseWrap: 'preserve',
18+
requirePragma: false,
19+
semi: true,
20+
singleQuote: true,
21+
tabWidth: 2,
22+
trailingComma: 'all',
23+
useTabs: false,
24+
},
25+
{
26+
usePrettierrc: false,
27+
},
28+
],
29+
},

0 commit comments

Comments
 (0)