Skip to content

Instantly share code, notes, and snippets.

@kimniche
Last active December 9, 2016 16:18
Show Gist options
  • Select an option

  • Save kimniche/108d91ae076328ef3134f35fae7b7616 to your computer and use it in GitHub Desktop.

Select an option

Save kimniche/108d91ae076328ef3134f35fae7b7616 to your computer and use it in GitHub Desktop.
// Rules added
// ---
// 1. yoda
// http://eslint.org/docs/rules/yoda
// ---
// a: bad
if ('red' === color) { ... }
// b: good (readability)
if (color === 'red') { ... }
// ---
// 2. no nested ternary
// http://eslint.org/docs/rules/no-nested-ternary
// ---
// a: bad
const foo = bar ? baz : qux === quxx ? bing : bam
// b: good
let thing
if (foo) {
thing = bar
} else if (baz === qux) {
thing = quxx
} else {
thing = foobar
}
// ---
// 3. no unneeded ternary
// http://eslint.org/docs/rules/no-unneeded-ternary
// ---
// a: bad
const isYes = answer === 1 ? true : false
const foo = bar ? bar : 1
// b: good (use existing simpler alternatives)
const isYes = answer === 1
var foo = bar || 1
// ---
// 4. no switch fallthrough
// http://eslint.org/docs/rules/no-fallthrough
// ---
// a: bad
switch (foo) {
case 1:
doSomething()
case 2:
doSomething()
}
// b: good
switch (foo) {
case 1:
doSomething()
break;
case 2:
doSomething()
}
// Airbnb rules removed
// ---
// 1. dangling underscores
// http://eslint.org/docs/rules/no-underscore-dangle
// ---
// airbnb didn't like:
const _getDependencies() { ... }
const a = foo_;
this._b = payload.b;
// ---
// 2. import sort order
// http://eslint.org/docs/rules/sort-imports#rule-details
// ---
// TODO - discuss
// absolute-first-group = "Absolute imports should come before relative imports"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment