2.0.2 • Published 6 years ago
@iarna/standard v2.0.2
@iarna/standard
Standard formats as @iarna likes it.
USAGE
$ npm i -D @iarna/standard
$ npx iarna-standardIn package.json...
"scripts": {
"pretest": "iarna-standard"
}WHATSAT?
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.
WHUTSITDO?
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 configurable 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. =pno-return-assign- 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 instandard@12it 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!!foouseBoolean(foo)instead.- The
noderecommended assertions.
It adds some more plugins:
securityWe use the recommended settings for disbling...detect-object-injection- This isn't an issue i node land and has too many false positives.
dependenciescase-sensitive- Make sure we don't screw ourselves when using Linux.no-unresolved- Deps must exist.require-json-ext- If you require json, be explicit.
unicorncatch-error-name- Exceptions should be caught aserrso other assertions can tell if they're unusedfilename-case- kebab-case is the only case. camelCase in filename is definitely baad.explicit-length-check- no checking truthyness of array.lengthno-abusive-eslint-disable- stop eslint being disabled for an entire filethrow-new-error- when constructing and throwing built in errors, usenewnumber-literal-case- when constructing hex and other literals, use lowercase for the middle part, caps for the latter part, eg0xBADC0FFEEescape-case- same as above, but for string escapes, eg'\uD834'no-array-instanceof- useArray.isArrayfor array identityno-hex-escape- no'\x1b'use'\u001b'insteadcustom-error-definition- some common sense around custom Error classesprefer-starts-ends-with- usestartsWithandendsWithstring methods where possible in pref to regexpprefer-type-error- enforce use ofTypeErroroverErrorwhere appropriateregex-shorthand- enforce use of regexp character classes when available