IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
285 stars 110 forks source link

ESLINT - handle warnings and errors #476

Open MysticJay opened 3 years ago

MysticJay commented 3 years ago

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

McBen commented 3 years ago
* 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$" }]

johnd0e commented 3 years ago

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

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

johnd0e commented 3 years ago
  • 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.

MysticJay commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.