https://github.com/andreaspitzer/my-xo
An opinionated xo config
https://github.com/andreaspitzer/my-xo
Last synced: 8 months ago
JSON representation
An opinionated xo config
- Host: GitHub
- URL: https://github.com/andreaspitzer/my-xo
- Owner: andreaspitzer
- Created: 2018-11-27T18:47:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-05T16:44:17.000Z (over 4 years ago)
- Last Synced: 2025-06-12T18:16:31.917Z (about 1 year ago)
- Language: JavaScript
- Size: 272 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# An opinionated `xo` config

  
## Install
```sh
npm add -D @andreaspizsa/eslint-config-xo
```
Automatically adds the package to `xo.extends` using [postinstaller](https://github.com/postinstaller/postinstaller).
## Settings
```json
{
"semicolon": false,
"space": true,
"func-names": "off",
"no-negated-condition": "warn",
"operator-linebreak": [
"error",
"before",
{
"overrides": {
"x?": "ignore",
"x:": "ignore"
}
}
]
}
```
#### Allows Named Functions
```js
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**
```js
function a(b) {
if(!b) {
log('b is empty')
} else {
// do
// something
// more complicated
// in a longer
// block
}
}
```
By default, xo favors this:
**Bad**
```js
function a(b) {
if(b) {
// do
// something
// more complicated
// in a longer
// block
} else {
log('b is empty')
}
}
```
#### Operator Line Break
I prefer
**Good**
```js
const result = isThisConditionActuallyTrue()
? doThisOperation()
: elseThisOperation()
```
over
**Bad**
```js
const result = isThisConditionActuallyTrue() ?
doThisOperation() :
elseThisOperation()
```