Standard formats as @iarna likes it.
npm install @iarna/standardStandard formats as @iarna likes it.
``console`
$ npm i -D @iarna/standard
$ npx iarna-standard
_In package.json..._
``
"scripts": {
"pretest": "iarna-standard"
}
Sooo, I mostly like Standard, except some of the rules drive me bonkers. So
for my personal projects I worked up a .eslint config that did what I
wanted. This is all that bundled up as an extension to standard. Many many
thanks to @feross and friends for making standard so easy to extend.
It tests for a Node.js environment specifically:
* No ESM, script mode only
* No jsx
It disables some standard rules that produce results I find objectionable:
* indent - I mostly like this, but there are times where it does the wrong thing and it's insufficiently configurableno-return-assign
to correct that w/o patching. Maybe I'll make my own version someday but for today... disabling it is fine. I don't, as rule,
screw up my indentation. =p
* - Assigning in return values is really weird... except when using _ => abc = _ and yes, I could use_ => { abc = _ }
but I don't wanna. And assigning in return otherwise may be weird, but it isn't likely to hide a bug.object-curly-spacing
* - Enabled in standard@12 it sets all my code on fire.
It enables all of the eslint recommended rules. But it disables some those that I find objectionable, specifically:
* no-console - Is not great in primarily cli/server-side code.
It enables some assertions that standard doesn't:
* no-prototype-builtins - Disallow calling Object.prototype methods directlyarray-callback-return
* - Enforce using return in builtin callbacks when neededno-implicit-coercion
* - Disallow implicit conversions, eg !!foo use Boolean(foo) instead.node
* The recommended assertions.
It adds some more plugins:
* security
We use the recommended settings for disbling...
* detect-object-injection - This isn't an issue i node landdependencies
and has too many false positives.
* case-sensitive
* -no-unresolved
Make sure we don't screw ourselves when using Linux.
* -require-json-ext
Deps must exist.
* -unicorn
If you require json, be explicit.
* catch-error-name
* - err
Exceptions should be caught as so other assertions can tell if they're unusedfilename-case
* - explicit-length-check
kebab-case is the only case. camelCase in filename is definitely baad.
* -no-abusive-eslint-disable
no checking truthyness of array.length
* -throw-new-error
stop eslint being disabled for an entire file
* -new
when constructing and throwing built in errors, use number-literal-case
* -0xBADC0FFEE
when constructing hex and other literals, use lowercase for the middle part, caps for the latter part, eg escape-case
* -'\uD834'
same as above, but for string escapes, eg no-array-instanceof
* -Array.isArray
use for array identityno-hex-escape
* -'\x1b'
no use '\u001b' insteadcustom-error-definition
* -prefer-starts-ends-with
some common sense around custom Error classes
* -startsWith
use and endsWith string methods where possible in pref to regexpprefer-type-error
* -TypeError
enforce use of over Error where appropriateregex-shorthand` -
*
enforce use of regexp character classes when available