Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint: Audit global variable usage #1426

Closed
6 tasks
jdlrobson opened this issue Oct 24, 2018 · 2 comments · Fixed by #1430
Closed
6 tasks

Eslint: Audit global variable usage #1426

jdlrobson opened this issue Oct 24, 2018 · 2 comments · Fixed by #1430
Labels
Good First Issue Easy issue. Good for newcomers. [managed]

Comments

@jdlrobson
Copy link
Collaborator

We have eslint linting for our JS. Let's add a rule for no-undef for consistency.

Define the environment in .eslintrc.json:

  "env": {
    "browser": true,
    "jquery": true
  },

Make sure all other undefined variables are accounted for (see below)

Checklist

  • Enable no-undef eslint rule.
  • Define the global environment (browser:
  • Make sure --config .eslintrc.json is passed in the lint:js scripts section in package.json
  • Beware openlibrary/plugins/openlibrary/js/lazy.js - don't make any changes to minified blocks of JavaScript. Instead disable the rule for these blocks
  • Where a variable is not defined, fix the error.
  • Where a variable is defined outside the file, disable the rule and note where it comes from
    e.g.
// startTime is defined inside openlibrary/plugins/openlibrary/js/ol.js
// eslint-disable-next-line no-undef
'loadtime':(endTime.getTime() - startTime.getTime()),
@jdlrobson jdlrobson added Linting Good First Issue Easy issue. Good for newcomers. [managed] labels Oct 24, 2018
@ajluong
Copy link

ajluong commented Oct 25, 2018

I'm going to take a look at this

@dnguneratne
Copy link
Contributor

I've opened a PR for this and would love your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Easy issue. Good for newcomers. [managed]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants