@parkhub/eslint-config-parkhub-base
v1.2.3
Published
Parkhub's Canonical base Javascript eslint rules!
Downloads
20
Maintainers
Keywords
Readme
eslint-config-parkhub-base
Parkhub's very own canonical Javascript style guide. Well, some of it :D. Based off airbnb's style guide with some minor modifications. This are the base rules(non-React)
Install
You must install peerDependencies.
To list them:
npm info @parkhub/eslint-config-parkhub-base peerDependencies
Then install them by running:
npm install -D <dependency:version>
Or, in your OSX/Linux:
(
export PKG=@parkhub/eslint-config-parkhub-base;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install -D "$PKG@latest"
)
Usage
In your .eslintrc
or .eslintrc.js
add:
"extends": "parkhub-base"
Differences
newline-per-chained-call
Reasoning: a depth of 4 is too deep. Much cleaner at two Parkhub's configs:
"newline-per-chained-call": ["error", { ignoreChainWithDepth: 2 }]
These will FAIL(from ESlint docs):
_.chain({}).map(foo).filter(bar).value();
// Or
_.chain({}).map(foo).filter(bar);
// Or
_
.chain({}).map(foo)
.filter(bar);
// Or
obj.method().method2().method3();
These will PASS(from ESlint docs):
_
.chain({})
.map(foo)
.filter(bar)
.value();
// Or
_
.chain({})
.map(foo)
.filter(bar);
// Or
_.chain({})
.map(foo)
.filter(bar);
// Or
obj
.prop
.method().prop;
// Or
obj
.prop.method()
.method2()
.method3().prop;
###comma-dangle Reasoning: Although the benefits of comma-dangles shine in diffs. They don't in looks. Parkhub's configs:
"comma-dangle": ["error", "never"]
These will FAIL(from ESlint docs)
const foo = {
bar: "baz",
qux: "quux",
};
const arr = [1,2,];
foo({
bar: "baz",
qux: "quux",
});
These will PASS(from ESlint docs):
const foo = {
bar: "baz",
qux: "quux"
};
const arr = [1,2];
foo({
bar: "baz",
qux: "quux"
});
###import/no-commonjs Reasoning: This is Airbnb's. We only enforce the rule. Parkhub's configs:
"import/no-commonjs": "error"
Additional Rules
Our chosen test runner of choice is [Jest][jest] due to its compatibility with [React][react]. Therefore, we added some additional rules that apply to tests using eslint-plugin-jest
Parkhub's configs:
"rules": {
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error"
},
"env": {
"jest/globals": true
}
You can read about each rule in the plugin's docs.
Want changes?
These rules were agreed upon once upon a time and can be changed with valid reasoning. They will be updated as newer versions of Javascript features are released. If you want to request a change, create a PR and make the change and include your reasoning.
Tips
USE Prettier! It will fix your code for you. Trust me. Check out this repo to learn how to set it up.
LICENSE
MIT