ingress-intel-total-conversion
ingress-intel-total-conversion copied to clipboard
ESLINT - handle warnings and errors
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)
* 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$" }]
or add
/* exported setup */
to the file.
I like this way: add this to the end if file.
- 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
.
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.
A) in the HIGHLIGHTERS (PR#495) the following was done:
-
/* global L, map, TEAM_NONE */
~~(eslint accepts both keywords "global" and "globals"~~ -
/* exported setup --eslint */
these are placed at the start of the file right after the headers.
Do we want to normalize calculations?
- spaces around operators "a + b" instead of "a+b"
- "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.