Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: airbnb/javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eslint-config-airbnb-base-v12.0.0
Choose a base ref
...
head repository: airbnb/javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eslint-config-airbnb-base-v12.0.1
Choose a head ref
  • 13 commits
  • 7 files changed
  • 7 contributors

Commits on Jul 5, 2017

  1. [eslint config] [breaking] [deps] Upgrade eslint-plugin-jsx-a11y to…

    … `v6`
    
     - enable more a11y rules
    wyattdanger authored and ljharb committed Jul 5, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    074b2f8 View commit details

Commits on Sep 2, 2017

  1. [eslint config] [breaking] [deps] require eslint v4, update `esli…

    …nt-config-airbnb-base`
    ljharb committed Sep 2, 2017
    Copy the full SHA
    7b30681 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    9dee847 View commit details
  3. [Tests] lint our markdown

    ljharb committed Sep 2, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    5b338e1 View commit details

Commits on Sep 7, 2017

  1. Update CHANGELOG.md

    Typo: prefer-restructuring => prefer-destructuring
    vitalymak authored Sep 7, 2017
    Copy the full SHA
    138aafd View commit details
  2. Merge pull request #1551 from vitalymak/patch-1

    [eslint config] [base] fix typo in changelog
    ljharb authored Sep 7, 2017
    Copy the full SHA
    e86fb14 View commit details

Commits on Sep 14, 2017

  1. Add Grupo Abraxas to In The Wild section

    Carlos Soria committed Sep 14, 2017
    Copy the full SHA
    0aab14c View commit details

Commits on Sep 20, 2017

  1. [guide] require array spread operator or Array.from

    Fixes #1084.
    bl00mber authored and ljharb committed Sep 20, 2017
    Copy the full SHA
    e16b03b View commit details
  2. [guide] Updated example in ternaries.

    cn0047 authored and ljharb committed Sep 20, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    3ad1ad1 View commit details

Commits on Sep 27, 2017

  1. Verified

    This commit was signed with the committer’s verified signature.
    ljharb Jordan Harband
    Copy the full SHA
    2380c0d View commit details
  2. Copy the full SHA
    8e29a16 View commit details
  3. Copy the full SHA
    b7ff33e View commit details
  4. v12.0.1

    ljharb committed Sep 27, 2017
    Copy the full SHA
    cd038fb View commit details
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -9,11 +9,11 @@ before_install:
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g npm@1.3 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi'
- 'if [ "${TRAVIS_NODE_VERSION%${TRAVIS_NODE_VERSION#[0-9]}}" = "0" ] || [ "${TRAVIS_NODE_VERSION:0:4}" = "iojs" ]; then npm install -g npm@4.5 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi'
install:
- 'cd "packages/${PACKAGE}"'
- 'if [ -n "${PACKAGE-}" ]; then cd "packages/${PACKAGE}"; fi'
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
- 'if [ -n "${ESLINT}" ]; then npm install --no-save "eslint@${ESLINT}"; fi'
script:
- 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; else npm run travis; fi'
- 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; elif [ -n "${LINT-}" ]; then npm run lint; else npm run travis; fi'
sudo: false
env:
matrix:
@@ -26,6 +26,8 @@ matrix:
env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb
- node_js: "node"
env: PREPUBLISH=true ESLINT=4 PACKAGE=eslint-config-airbnb-base
- node_js: "node"
env: LINT=true
allow_failures:
- node_js: "7"
- node_js: "5"
44 changes: 31 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

*A mostly reasonable approach to JavaScript*

> **Note**: this guide assumes you are using [Babel](https://babeljs.io), and requires that you use [babel-preset-airbnb](https://npmjs.com/babel-preset-airbnb) or the equivalent. It also assumes you are installing shims/polyfills in your app, with [airbnb-browser-shims](https://npmjs.com/airbnb-browser-shims) or the equivalent.
[![Downloads](https://img.shields.io/npm/dm/eslint-config-airbnb.svg)](https://www.npmjs.com/package/eslint-config-airbnb)
[![Downloads](https://img.shields.io/npm/dm/eslint-config-airbnb-base.svg)](https://www.npmjs.com/package/eslint-config-airbnb-base)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
@@ -362,15 +364,31 @@ Other Style Guides
```

<a name="arrays--from"></a><a name="4.4"></a>
- [4.4](#arrays--from) To convert an array-like object to an array, use [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from).
- [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from).

```javascript
const foo = document.querySelectorAll('.foo');
// good
const nodes = Array.from(foo);
// best
const nodes = [...foo];
```

<a name="arrays--mapping"></a>
- [4.5](#arrays--mapping) Use [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array.

```javascript
// bad
const baz = [...foo].map(bar);
// good
const baz = Array.from(foo, bar);
```

<a name="arrays--callback-return"></a><a name="4.5"></a>
- [4.5](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return)
- [4.6](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](http://eslint.org/docs/rules/array-callback-return)

```javascript
// good
@@ -382,18 +400,18 @@ Other Style Guides
// good
[1, 2, 3].map(x => x + 1);

// bad
// bad - no returned value means `memo` becomes undefined after the first iteration
const flat = {};
[[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => {
const flatten = memo.concat(item);
flat[index] = flatten;
memo[index] = flatten;
});

// good
const flat = {};
[[0, 1], [2, 3], [4, 5]].reduce((memo, item, index) => {
const flatten = memo.concat(item);
flat[index] = flatten;
memo[index] = flatten;
return flatten;
});

@@ -418,8 +436,8 @@ Other Style Guides
});
```
<a name="arrays--bracket-newline"></a>
- [4.6](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines
<a name="arrays--bracket-newline"></a>
- [4.7](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines
```javascript
// bad
@@ -1896,16 +1914,15 @@ Other Style Guides
? "bar"
: value1 > value2 ? "baz" : null;
// better
// split into 2 separated ternary expressions
const maybeNull = value1 > value2 ? 'baz' : null;
// better
const foo = maybe1 > maybe2
? 'bar'
: maybeNull;
// best
const maybeNull = value1 > value2 ? 'baz' : null;
const foo = maybe1 > maybe2 ? 'bar' : maybeNull;
```

@@ -2509,7 +2526,7 @@ Other Style Guides
## Commas
<a name="commas--leading-trailing"></a><a name="19.1"></a>
<a name="commas--leading-trailing"></a><a name="19.1"></a>
- [20.1](#commas--leading-trailing) Leading commas: **Nope.** eslint: [`comma-style`](http://eslint.org/docs/rules/comma-style.html) jscs: [`requireCommaBeforeLineBreak`](http://jscs.info/rule/requireCommaBeforeLineBreak)
```javascript
@@ -3167,7 +3184,7 @@ Other Style Guides
eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals)
> Why? The global `isNaN` coerces non-numbers to numbers, returning true for anything that coerces to NaN.
If this behavior is desired, make it explicit.
> If this behavior is desired, make it explicit.
```javascript
// bad
@@ -3184,7 +3201,7 @@ Other Style Guides
eslint: [`no-restricted-globals`](http://eslint.org/docs/rules/no-restricted-globals)
> Why? The global `isFinite` coerces non-numbers to numbers, returning true for anything that coerces to a finite number.
If this behavior is desired, make it explicit.
> If this behavior is desired, make it explicit.
```javascript
// bad
@@ -3353,6 +3370,7 @@ Other Style Guides
- **Generation Tux**: [GenerationTux/javascript](https://github.com/generationtux/styleguide)
- **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style)
- **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript)
- **Grupo-Abraxas**: [Grupo-Abraxas/javascript](https://github.com/Grupo-Abraxas/javascript)
- **Honey**: [honeyscience/javascript](https://github.com/honeyscience/javascript)
- **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript-style-guide)
- **Huballin**: [huballin/javascript](https://github.com/huballin/javascript)
7 changes: 6 additions & 1 deletion packages/eslint-config-airbnb-base/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
12.0.1 / 2017-09-27
==================
- [fix] ensure all JSX elements are ignored by `indent` (#1569)
- [deps] update `eslint`

12.0.0 / 2017-09-02
==================
- [deps] [breaking] require `eslint` v4
- enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-restructuring`
- enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-destructuring`
- improve `indent`, `no-multi-spaces`, `no-trailing-spaces`, `no-underscore-dangle`
- [breaking] move `comma-dangle` to Stylistic Issues (#1514)
- [breaking] Rules prohibiting global isNaN, isFinite (#1477)
6 changes: 3 additions & 3 deletions packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-airbnb-base",
"version": "12.0.0",
"version": "12.0.1",
"description": "Airbnb's base JS ESLint config, following our styleguide",
"main": "index.js",
"scripts": {
@@ -51,15 +51,15 @@
"babel-preset-airbnb": "^2.4.0",
"babel-tape-runner": "^2.0.1",
"editorconfig-tools": "^0.1.1",
"eslint": "^4.6.0",
"eslint": "^4.7.2",
"eslint-find-rules": "^3.1.1",
"eslint-plugin-import": "^2.7.0",
"in-publish": "^2.0.0",
"safe-publish-latest": "^1.1.1",
"tape": "^4.8.0"
},
"peerDependencies": {
"eslint": "^4.6.0",
"eslint": "^4.7.2",
"eslint-plugin-import": "^2.7.0"
},
"engines": {
2 changes: 1 addition & 1 deletion packages/eslint-config-airbnb-base/rules/style.js
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ module.exports = {
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
ignoredNodes: ['JSXElement *']
ignoredNodes: ['JSXElement', 'JSXElement *']
}],

// specify whether double or single quotes should be used in JSX attributes
10 changes: 5 additions & 5 deletions packages/eslint-config-airbnb/package.json
Original file line number Diff line number Diff line change
@@ -48,25 +48,25 @@
},
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^11.3.2"
"eslint-config-airbnb-base": "^12.0.0"
},
"devDependencies": {
"babel-preset-airbnb": "^2.4.0",
"babel-tape-runner": "^2.0.1",
"editorconfig-tools": "^0.1.1",
"eslint": "^3.19.0 || ^4.5.0",
"eslint": "^4.6.0",
"eslint-find-rules": "^3.1.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.3.0",
"in-publish": "^2.0.0",
"react": ">= 0.13.0",
"safe-publish-latest": "^1.1.1",
"tape": "^4.8.0"
},
"peerDependencies": {
"eslint": "^3.19.0 || ^4.5.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint": "^4.6.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-react": "^7.3.0"
},
15 changes: 4 additions & 11 deletions packages/eslint-config-airbnb/rules/react-a11y.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ module.exports = {
rules: {
// Enforce that anchors have content
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
'jsx-a11y/anchor-has-content': ['error', { components: [''] }],
'jsx-a11y/anchor-has-content': ['error', { components: [] }],

// Require ARIA roles to be valid and non-abstract
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
@@ -32,10 +32,6 @@ module.exports = {
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
'jsx-a11y/aria-unsupported-elements': 'error',

// disallow href "#"
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md
'jsx-a11y/href-no-hash': ['error', { components: ['a'] }],

// Enforce that all elements that require alternative text have meaningful information
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
'jsx-a11y/alt-text': ['error', {
@@ -55,9 +51,8 @@ module.exports = {
'jsx-a11y/label-has-for': ['error', { components: ['label'] }],

// require that mouseover/out come with focus/blur, for keyboard-only users
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
'jsx-a11y/mouse-events-have-key-events': 'off',
'jsx-a11y/mouse-events-have-key-events': 'error',

// Prevent use of `accessKey`
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
@@ -109,8 +104,7 @@ module.exports = {

// require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
// TODO: enable?
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/click-events-have-key-events': 'error',

// Enforce that DOM elements without semantic behavior not have interaction handlers
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
@@ -191,8 +185,7 @@ module.exports = {

// ensure <a> tags are valid
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
// TODO: enable, semver-major
'jsx-a11y/anchor-is-valid': ['off', {
'jsx-a11y/anchor-is-valid': ['error', {
components: ['Link'],
specialLink: [],
aspects: ['noHref', 'invalidHref', 'preferButton'],