0.2.1 • Published 8 months ago

@andreaspizsa/eslint-config-xo v0.2.1

Weekly downloads
10
License
MIT
Repository
-
Last release
8 months ago

An opinionated xo config

npm.io npm.io npm.io npm.io

Install

npm add -D @andreaspizsa/eslint-config-xo

Automatically adds the package to xo.extends using postinstaller.

Settings

{
  "semicolon": false,
  "space": true,
  "func-names": "off",
  "no-negated-condition": "warn",
  "operator-linebreak": [
    "error",
    "before",
    {
      "overrides": {
        "x?": "ignore",
        "x:": "ignore"
      }
    }
  ]
}

Allows Named Functions

function a() {
  return function namedFunction() { // standard xo would complain here
    return b
  }
}

Allows Negated Conditions

Negated conditions are fine if there’s a rather short block - often a one-liner - followed by a longer block. Getting the "short block" out of the way reduces cognitive load.

Good

function a(b) {
  if(!b) {
    log('b is empty')
  } else {
    // do
    // something
    // more complicated
    // in a longer
    // block
  }
}

By default, xo favors this:

Bad

function a(b) {
  if(b) {
    // do
    // something
    // more complicated
    // in a longer
    // block
  } else {
    log('b is empty')
  }
}

Operator Line Break

I prefer

Good

  const result = isThisConditionActuallyTrue()
    ? doThisOperation()
    : elseThisOperation()

over

Bad

  const result = isThisConditionActuallyTrue() ?
    doThisOperation() :
    elseThisOperation()
0.2.1

8 months ago

0.2.0

3 years ago

0.1.3

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago