Currently, the .jschintrc files in most cordova repos have the following settings:
{ "node": true , "bitwise": true , "undef": true , "trailing": true , "quotmark": true , "indent": 4 , "unused": "vars" , "latedef": "nofunc" , "jasmine": true , "esversion": 6 }
This is a proposal to determine which settings/rules we should keep, ignore, or add when moving from jshint to eslint.
When we switch to eslint, we will be able to keep the same jshint settings (listed above).
We are also using ‘extends’, which is taking a set of rules and adding them to your config. There are more than one ‘extends’ to pick from and so far we are using semi-standard because it supports checking for semi-colons. (Note : semi-standard adds Standard, and then adds the one rule on top of that for semicolons).
When using semi-standard, eslint is pickier about a few more things than jshint. It has certain rules that are built in. These additional rules in eslint could either be just turned off and ignored if we don’t think they are necessary. (In some cases you can customize your rules. For instance, you can change the indenting from 2 to 4).
Link to the standard rules —> https://standardjs.com/rules.html
There are many rules and listed below are the ones that have come up most frequently when testing eslint using extending semi-standard in cordova-repos.
comma-spacing
- enforce spacing before and after commakeyword-spacing
- enforce spacing before and after keywordsno-multi-spaces
- disallow use of multiple spacesspace-before-function-paren
- require or disallow a space before function opening parenthesisspaced-comment
- require or disallow a space immediately following the // or /* in a commentspace-infix-ops
- require spaces around operatorsbrace-style
- enforce one true brace stylecamelcase
- require camel case namescurly
- specify curly brace conventions for all control statementseqeqeq
- require the use of === and !==no-extra-boolean-cast
- disallow double-negation boolean casts in a boolean contextno-throw-literal
- restrict what can be thrown as an exceptionoperator-linebreak
- enforce operators to be placed before or after line breakspadded-blocks
- enforce padding within blocksI propose that we keep the eslint semi-standard defaults in initially and remove padded-block, operator-linebreaker, and no-throw-literal.
Would we like to use eslint's semi-standard default rules across the cordova repos or would we prefer to ignore certain ones and turn them off? Are there any other eslint rules not listed above that we would like to turn off or customize? Concerns? Thoughts? Pros and cons?