Socket
Socket
Sign inDemoInstall

@andreaspizsa/eslint-config-xo

Package Overview
Dependencies
91
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @andreaspizsa/eslint-config-xo

a lightly customized `xo` config


Version published
Weekly downloads
5
increased by400%
Maintainers
1
Install size
29.0 kB
Created
Weekly downloads
 

Readme

Source

An opinionated xo config

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()

Keywords

FAQs

Last updated on 05 Feb 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc