ingress-intel-total-conversion icon indicating copy to clipboard operation
ingress-intel-total-conversion copied to clipboard

ESLINT - handle warnings and errors

Open MysticJay opened this issue 3 years ago • 6 comments

ESLINT checks based on the current .eslintrc.json cause a number of errors and warnings that we usually ignore. Some (possibly incomplete) changes will reduce the amount.

To .eslintrc.json

  • [ ] add "globals": { "L": true } To all plugins:
  • [ ] change setup-function declaration to function setup () { // eslint-disable-line no-unused-vars
  • [ ] Add code section copying all global variables and functions to local focus: // Global functions used var dialog = window.dialog; (this is the preferred way over using window.function)

MysticJay avatar Apr 04 '21 11:04 MysticJay

* change setup-function declaration to `function setup () { // eslint-disable-line no-unused-vars`

or add /* exported setup */ to the file.

or as general solution add to eslint.json no-unused-vars: ["error", { "varsIgnorePattern": "^setup$" }]

McBen avatar Apr 04 '21 11:04 McBen

or add /* exported setup */ to the file.

I like this way: add this to the end if file.

johnd0e avatar Apr 07 '21 14:04 johnd0e

  • Add code section copying all global variables and functions to local focus:

Not sure about that, as it prevents such functions overriding (which is rather common pattern in iitc plugins). Let's consider other options: https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals

May be put such declaration in the beginning of the file:

/* global map, plugin, dialog */

May be put some base globals to .eslintrc.json.

johnd0e avatar Apr 07 '21 14:04 johnd0e

or add /* exported setup */ to the file.

I like this way: add this to the end if file.

I prefer these to go after the headers, so that they are easily identified. also I am not sure that all linters parse to the end before warning.

MysticJay avatar May 01 '21 21:05 MysticJay

A) in the HIGHLIGHTERS (PR#495) the following was done:

  1. /* global L, map, TEAM_NONE */ ~~(eslint accepts both keywords "global" and "globals"~~
  2. /* exported setup --eslint */ these are placed at the start of the file right after the headers.

MysticJay avatar May 02 '21 12:05 MysticJay

Do we want to normalize calculations?

  1. spaces around operators "a + b" instead of "a+b"
  2. "0.7" instead of ".7" Both can be checked by eslint. While we are still on es5, I am not sure if ES6 requires either so we could change it now aleady.

MysticJay avatar May 02 '21 13:05 MysticJay