ni / javascript-styleguide

JavaScript and TypeScript Style Guide
MIT License
9 stars 9 forks source link

Improve experience when using ruleset in repo with mixed JS, TS, and Angular code #79

Open jattasNI opened 2 years ago

jattasNI commented 2 years ago

In this Skyline PR I enabled linting for the JS files in an Angular project. This situation is common because of config files like karma.conf.js and .eslintrc.js. I hit a couple small bumps that would be nice to address in this repo.

  1. Had to manually modify the repo's .eslintrc.js to use the JavaScript ruleset for files matching *.js. We should either document this as our recommended approach or change our Angular and TS rulesets to apply to JS files too.
  2. I had to modify angular.json lintFilePatterns to include *.js since the npm run lint command called ng lint. We should document this.
  3. A few rules failed on the default karma.conf.js generated by Angular. I chose to suppress those rules. In another case we chose to fix them (see discussion in linked PR). It would be nice to settle on a preferred approach and include guidance in our repo since most projects will likely hit the same errors.
    • if we choose to suppress, we could change our ruleset to do this automatically for karma.conf.js
    • if we choose to fix, we could add notes on each rule's docs or create StackOverflow posts explaining how to fix
jattasNI commented 2 years ago

General agreement at our meeting today that we can solve most of this with documentation. For issue 3 above, adding an override for karma*.js which turns off a couple rules seems preferable, but we'd be fine with docs if we run into issues with that approach.