Skip to content

Commit 9471975

Browse files
committed
Merge remote-tracking branch 'airbnb/master'
2 parents cfe10c1 + 396166b commit 9471975

File tree

18 files changed

+404
-39
lines changed

18 files changed

+404
-39
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,7 @@ Other Style Guides
17011701
const truthyCount = array.filter(Boolean).length;
17021702
```
17031703
1704+
<a name="variables--linebreak"></a>
17041705
- [13.7](#variables--linebreak) Avoid linebreaks before or after `=` in an assignment. If your assignment violates [`max-len`](https://eslint.org/docs/rules/max-len.html), surround the value in parens. eslint [`operator-linebreak`](https://eslint.org/docs/rules/operator-linebreak.html).
17051706
17061707
> Why? Linebreaks surrounding `=` can obfuscate the value of an assignment.
@@ -2162,7 +2163,7 @@ Other Style Guides
21622163
21632164
// good
21642165
if (
2165-
(foo === 123 || bar === "abc")
2166+
(foo === 123 || bar === 'abc')
21662167
&& doesItLookGoodWhenItBecomesThatLong()
21672168
&& isThisReallyHappening()
21682169
) {

packages/eslint-config-airbnb-base/.eslintrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"rules": {
44
// disable requiring trailing commas because it might be nice to revert to
55
// being JSON at some point, and I don't want to make big changes now.
6-
"comma-dangle": 0
6+
"comma-dangle": 0,
7+
// we support node 4
8+
"prefer-destructuring": 0,
79
},
810
}
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.

packages/eslint-config-airbnb-base/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
8484

8585
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.
8686

87+
### eslint-config-airbnb-base/whitespace
88+
89+
This entry point that only warns 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).
90+
8791
## Improving this config
8892

8993
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?

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

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"prelint": "editorconfig-tools check * rules/* test/*",
88
"lint": "eslint --report-unused-disable-directives .",
9+
"pretests-only": "node ./test/requires",
910
"tests-only": "babel-tape-runner ./test/test-*.js",
1011
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest",
1112
"pretest": "npm run --silent lint",
@@ -51,21 +52,23 @@
5152
"babel-preset-airbnb": "^2.4.0",
5253
"babel-tape-runner": "^2.0.1",
5354
"editorconfig-tools": "^0.1.1",
54-
"eslint": "^4.16.0",
55-
"eslint-find-rules": "^3.1.1",
56-
"eslint-plugin-import": "^2.8.0",
55+
"eslint": "^4.18.1",
56+
"eslint-find-rules": "^3.2.0",
57+
"eslint-plugin-import": "^2.9.0",
5758
"in-publish": "^2.0.0",
5859
"safe-publish-latest": "^1.1.1",
59-
"tape": "^4.8.0"
60+
"tape": "^4.9.0"
6061
},
6162
"peerDependencies": {
62-
"eslint": "^4.16.0",
63-
"eslint-plugin-import": "^2.8.0"
63+
"eslint": "^4.18.1",
64+
"eslint-plugin-import": "^2.9.0"
6465
},
6566
"engines": {
6667
"node": ">= 4"
6768
},
6869
"dependencies": {
69-
"eslint-restricted-globals": "^0.1.1"
70+
"eslint-restricted-globals": "^0.1.1",
71+
"object.assign": "^4.1.0",
72+
"object.entries": "^1.0.4"
7073
}
7174
}

packages/eslint-config-airbnb-base/rules/imports.js

+19
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,24 @@ module.exports = {
211211
// https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
212212
// TODO: enable?
213213
'import/exports-last': 'off',
214+
215+
// Reports when named exports are not grouped together in a single export declaration
216+
// or when multiple assignments to CommonJS module.exports or exports object are present
217+
// in a single file.
218+
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
219+
'import/group-exports': 'off',
220+
221+
// forbid default exports. this is a terrible rule, do not use it.
222+
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md
223+
'import/no-default-export': 'off',
224+
225+
// Forbid a module from importing itself
226+
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
227+
// TODO: enable
228+
'import/no-self-import': 'off',
229+
230+
// Ensures that there are no useless path segments
231+
// https://github.com/benmosher/eslint-plugin-import/issues/1032
232+
'import/no-useless-path-segments': 'error',
214233
},
215234
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint
2+
strict: 0,
3+
global-require: 0,
4+
*/
5+
6+
'use strict';
7+
8+
const test = require('tape');
9+
10+
test('all entry points parse', (t) => {
11+
t.doesNotThrow(() => require('..'), 'index does not throw');
12+
t.doesNotThrow(() => require('../legacy'), 'legacy does not throw');
13+
t.doesNotThrow(() => require('../whitespace'), 'whitespace does not throw');
14+
15+
t.end();
16+
});

packages/eslint-config-airbnb-base/test/test-base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs';
22
import path from 'path';
33
import test from 'tape';
44

5-
import index from '../';
5+
import index from '..';
66

77
const files = { ...{ index } }; // object spread is to test parsing
88

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const baseConfig = require('.');
2+
const assign = require('object.assign');
3+
const entries = require('object.entries');
4+
const CLIEngine = require('eslint').CLIEngine;
5+
6+
function onlyErrorOnRules(rulesToError, config) {
7+
const errorsOnly = assign({}, config);
8+
const cli = new CLIEngine({ baseConfig: config, useEslintrc: false });
9+
const baseRules = cli.getConfigForFile('./').rules;
10+
11+
entries(baseRules).forEach((rule) => {
12+
const ruleName = rule[0];
13+
const ruleConfig = rule[1];
14+
15+
if (rulesToError.indexOf(ruleName) === -1) {
16+
if (Array.isArray(ruleConfig)) {
17+
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
18+
} else if (typeof ruleConfig === 'number') {
19+
errorsOnly.rules[ruleName] = 1;
20+
} else {
21+
errorsOnly.rules[ruleName] = 'warn';
22+
}
23+
}
24+
});
25+
26+
return errorsOnly;
27+
}
28+
29+
module.exports = onlyErrorOnRules([
30+
'array-bracket-newline',
31+
'array-bracket-spacing',
32+
'array-element-newline',
33+
'arrow-spacing',
34+
'block-spacing',
35+
'comma-spacing',
36+
'computed-property-spacing',
37+
'dot-location',
38+
'eol-last',
39+
'func-call-spacing',
40+
'function-paren-newline',
41+
'generator-star-spacing',
42+
'implicit-arrow-linebreak',
43+
'indent',
44+
'key-spacing',
45+
'keyword-spacing',
46+
'line-comment-position',
47+
'linebreak-style',
48+
'multiline-ternary',
49+
'newline-per-chained-call',
50+
'no-irregular-whitespace',
51+
'no-mixed-spaces-and-tabs',
52+
'no-multi-spaces',
53+
'no-regex-spaces',
54+
'no-spaced-func',
55+
'no-trailing-spaces',
56+
'no-whitespace-before-property',
57+
'nonblock-statement-body-position',
58+
'object-curly-newline',
59+
'object-curly-spacing',
60+
'object-property-newline',
61+
'one-var-declaration-per-line',
62+
'operator-linebreak',
63+
'padded-blocks',
64+
'padding-line-between-statements',
65+
'rest-spread-spacing',
66+
'semi-spacing',
67+
'semi-style',
68+
'space-before-blocks',
69+
'space-before-function-paren',
70+
'space-in-parens',
71+
'space-infix-ops',
72+
'space-unary-ops',
73+
'spaced-comment',
74+
'switch-colon-spacing',
75+
'template-tag-spacing',
76+
'import/newline-after-import',
77+
], baseConfig);

packages/eslint-config-airbnb/.eslintrc

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"rules": {
44
// disable requiring trailing commas because it might be nice to revert to
55
// being JSON at some point, and I don't want to make big changes now.
6-
"comma-dangle": 0
7-
}
6+
"comma-dangle": 0,
7+
// we support node 4
8+
"prefer-destructuring": 0,
9+
},
810
}
+21
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.

packages/eslint-config-airbnb/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ If you use yarn, run `npm info "eslint-config-airbnb@latest" peerDependencies` t
5555

5656
2. Add `"extends": "airbnb"` to your .eslintrc
5757

58+
### eslint-config-airbnb/whitespace
59+
60+
This entry point that only warns 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/whitespace.js).
61+
5862
### eslint-config-airbnb/base
5963

6064
This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base).

packages/eslint-config-airbnb/package.json

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"prelint": "editorconfig-tools check * rules/* test/*",
88
"lint": "eslint .",
9+
"pretests-only": "node ./test/requires",
910
"tests-only": "babel-tape-runner ./test/test-*.js",
1011
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest",
1112
"pretest": "npm run --silent lint",
@@ -48,27 +49,29 @@
4849
},
4950
"homepage": "https://github.com/airbnb/javascript",
5051
"dependencies": {
51-
"eslint-config-airbnb-base": "^12.1.0"
52+
"eslint-config-airbnb-base": "^12.1.0",
53+
"object.assign": "^4.1.0",
54+
"object.entries": "^1.0.4"
5255
},
5356
"devDependencies": {
5457
"babel-preset-airbnb": "^2.4.0",
5558
"babel-tape-runner": "^2.0.1",
5659
"editorconfig-tools": "^0.1.1",
57-
"eslint": "^4.16.0",
58-
"eslint-find-rules": "^3.1.1",
59-
"eslint-plugin-import": "^2.8.0",
60+
"eslint": "^4.18.1",
61+
"eslint-find-rules": "^3.2.0",
62+
"eslint-plugin-import": "^2.9.0",
6063
"eslint-plugin-jsx-a11y": "^6.0.3",
61-
"eslint-plugin-react": "^7.4.0",
64+
"eslint-plugin-react": "^7.7.0",
6265
"in-publish": "^2.0.0",
6366
"react": ">= 0.13.0",
6467
"safe-publish-latest": "^1.1.1",
65-
"tape": "^4.8.0"
68+
"tape": "^4.9.0"
6669
},
6770
"peerDependencies": {
68-
"eslint": "^4.16.0",
69-
"eslint-plugin-import": "^2.8.0",
71+
"eslint": "^4.18.1",
72+
"eslint-plugin-import": "^2.9.0",
7073
"eslint-plugin-jsx-a11y": "^6.0.3",
71-
"eslint-plugin-react": "^7.4.0"
74+
"eslint-plugin-react": "^7.7.0"
7275
},
7376
"engines": {
7477
"node": ">= 4"

0 commit comments

Comments
 (0)