eslint-config-standard-pp v0.0.1
eslint-config-standard-pp
(PROJECT NOT YET PACKAGED FOR DISTRIBUTION)
I favor the idea of using, or at least adapting, a pseudo-"standard" for code styling (though regardless of non-necessity, semi-colons are my way to go! A handful of other deviations below).
However, a good number of rules were missing from ESLint, so standard-pp
aims to offer defaults on these where beneficial for catching errors and bad
practices and hard-to-read patterns (or lack of pattern).
(I'd also like to list all missing rules in source for a frame of reference for purely styling rules, even if I disable them here.)
Strict config
The strict config indicates generally good practice but is less likely to be due to an error and may possibly also require an undue amount of refactoring.
Deprecated rule non-inclusion
The following deprecated items were also not included:
indent-legacy
lines-around-directive
no-catch-shadow
no-native-reassign
prefer-reflect
Rationale for disabled rules
Note: asterisked items refer to features I might enable if the described option could become available (or upon further review). I might also tweak some "standard" rules further which I have not had time to examine (but it would probably be toward the stricter rather than looser as I have been happy with it thus far).
array-element-newline
- While the "consistent" option would be nice, it doesn't work well to keep up with a max width and the desire to avoid excessive height[\n a, b, \n c, d\n]
arrow-body-style
- Withas-needed
andrequireReturnForObjectLiteral
seems reasonable, but too often in debugging, one needs to add brackets to do any logging.func-names
- Too prohibitive, though if applied to methods only, it may be useful (though with object shorthand, less necessary)id-blacklist
- Can be helpful but a little tyrannicalid-length
- Can be helpful (especially a minimum) but a little tyrannicalid-match
- Too project-specificinit-declarations
- Nice with "always" andignoreForLoopInit
, but cumbersome and seemingly wasteful at timesline-comment-position
- Too inflexible to enforce either waylines-around-comment
- Irksome to melines-between-class-members
- Don't feel any need for itmax-classes-per-file
- A bit tyrannicalmax-lines-per-function
- A bit tyrannicalmax-lines
- A bit tyrannicalmax-params
- Can be troublesome when one is forced to abide by some APImax-statements
- A bit tyrannicalmultiline-comment-style
- Would be nice if allowed multiline "starred-block" OR "bare-block" given some one may wish as JSDoc-style and others notnewline-after-var
- Not very flexiblenewline-before-return
- Not very flexibleno-continue
- Can be convenientno-negated-condition
- Is generally simpler, but it can be annoying if one wishes to get a much smaller condition body visible at the top.no-nested-ternary
- Nested ternaries can be helpful to avoid clutter of duplicated assignment codeno-param-reassign
- Can be helpful, but not convenient, including when making defaults against more thanundefined
(e.g.,null
)no-plusplus
- Would be nice if there were an option to allow if not combined inline with other expressionsno-restricted-imports
- Project-specificno-restricted-modules
- Project-specificno-restricted-properties
- Might expand the listno-restricted-syntax
- Project-specific unless some forms exist which should be deprecatedno-ternary
- Not usefulno-undefined
-undefined
is ok for ES6 modules and strict code, so usingno-global-assign
andno-shadow-restricted-names
insteadno-underscore-dangle
- Too restrictiveno-useless-concat
- Too restrictive when one has certain formatting one wishes to draw outobject-curly-newline
- Doesn't allowlet f = {foo () { dosomething(); }};
padding-line-between-statements
- Might revisitprefer-arrow-callback
- Not compellingsort-keys
- Too cumbersomesort-vars
- Too cumbersome
Rationale for warnings
These are good practices, but cumbersome, not as familiar to developers, prohibitive during ongoing debugging or conversion of existing projects, etc. But perhaps useful for a new project which can pay closer attention to standards without the undue burden of having to refactor lots of code (which may not all be under one's control).
class-methods-use-this
-complexity
-max-len
-no-alert
-no-console
-no-empty-function
-no-magic-numbers
-no-warning-comments
-prefer-numeric-literals
-require-jsdoc
-require-unicode-regexp
-sort-imports
-vars-on-top
- Not needed forlet
/const
, and if overriding, this is cumbersome, despite being useful
Rationale for included rules
no-implicit-globals
- Included despite not applying to modules, in case overriding.object-shorthand
- The optionavoidExplicitReturnArrows
does not avoid if the functions havethis
(though doesn't currently document); this is probably good, though use ofthis
may signal an error if within a methodstrict
- Included despite not being needed for modules, in case overriding.
Rationale for changing required rules' configuration away from defaults
func-style
- Declarations are simpler so usingdeclaration
option. Arrow functions are convenient too, however, so enablingallowArrowFunctions
.function-paren-newline
- The default multiline can get too long whereas "consistent" can be clean and short.multiline-ternary
- Inline ternary can be very readable when not spanning linesno-empty
- Empty catches occur frequently enough to justifyno-mixed-requires
- Grouping is more organized, while calls are compellingly convenientno-restricted-globals
- Use example defaults forevent
(andfdescribe
) as convenientno-restricted-properties
- Use example default of restricting__defineGetter__
in favor ofObject.defineProperty
as convenientno-shadow
- It is better practice not to confuse by using globals! I didn't feel the examples for allowing necessitated their useobject-shorthand
- EnablingavoidExplicitReturnArrows
as methods withoutthis
that this rule grabs (which have their own meaning with arrow functions) are more succinctly expressed in shorthand, and shorthand also conduces better to events wherethis
refers to the element (unless one needs the outer scopethis
).prefer-destructuring
- Did not set array to true due to its problems with direct access of large numbers (requiring many commas) and non-iterable ‘array-like’ objects.quote-props
- Changed to "as-needed" as properties more verbose and uglier with quotingvalid-jsdoc
- The specific rules adopted add more checking.
Rationale for adding JSDoc rules
JSDoc, when in use, is, in my view, generally best updated during development.
Rationale for overriding "standard" rules
semi
- Even if not strictly required, semi-colons are conventional in JavaScript and help denote the end of statements (as opposed to the end of a line which may continue)indent
- While it may take some getting used to, 2 spaces does allow more in one's field of vision. However, changed to useouterIIFEBody
for avoiding indents with the IIFE body, as this often minimizes indent level for much or all of the whole file.object-property-newline
- Properties on the same line can be very convenient, including stacking for space to avoid max length (though without stacking the height too high).one-var
- While I normally favor enforcing conventions, this one seems to me to be of little consequence. It also prevents grouping like items together. I might favor an option to require separate lines for variable declarations, but for uninitialized ones, adding to the same line is convenient, especially for single-letter variables. I would like a rule to have declarations as close as possible to being just above any used scopes (forlet
andconst
).object-curly-spacing
- Not sure why "standard" switched from the default here.
Rationale for suppressing some jsdoc plugin rules
- TO-DO
To-dos
- Remove items duplicating eslint:recommended
6 years ago