Skip to content

Add eslint using the airbnb config. #2905

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

Merged
merged 4 commits into from
May 24, 2017
Merged

Conversation

cmc333333
Copy link
Contributor

@cmc333333 cmc333333 commented May 24, 2017

In an effort to make the JS consistent, this adds an ESLint gulp task. ESLint
is very configurable, and has no defaults. Instead, this reaches for
airbnb's legacy config (which covers ES5), which is one of the most popular
configurations. As a last step, it turns off all of the rules which currently
fail. We can turn them on piecemeal, or override the airbnb style to use a
different format.

Rules to prioritize (as they likely indicate bugs):

  • "array-callback-return": "off",
  • "eqeqeq": "off",
  • "guard-for-in": "off",
  • "no-inner-declarations": "off",
  • "no-loop-func": "off",
  • "no-mixed-operators": "off",
  • "no-undef": "off",
  • "no-use-before-define": "off",
  • "one-var": "off",

Also adds to CI, though I didn't come up with a great strategy to separate execution from the Python tests. This means that ESLint is running once per Travis configuration...

In an effort to make the JS consistent, this adds an ESLint gulp task. ESLint
is *very* configurable, and has no defaults. Instead, this reaches for
airbnb's legacy config (which covers ES5), which is one of the most popular
configurations. As a last step, it turns off all of the rules which currently
fail. We can turn them on piecemeal, or override the airbnb style to use a
different format.

Rules to prioritize (as they likely indicate bugs):
* "array-callback-return": "off",
* "eqeqeq": "off",
* "guard-for-in": "off",
* "no-inner-declarations": "off",
* "no-loop-func": "off",
* "no-mixed-operators": "off",
* "no-undef": "off",
* "no-use-before-define": "off",
* "one-var": "off",
This adds an ESLint step to the CI service so we prevent unlinted code from
making its way in.
@ericholscher
Copy link
Member

This is great! Thanks for this. I'll let @agjohnson look over it since he owns most of the front end, but I think this is a solid step forward.

@ericholscher
Copy link
Member

I wonder if we can add this to tox, during the lint step? I don't know if it has a good support for installing JS deps, but it would be useful to be able to run it locally.

CM Lubinski and others added 2 commits May 24, 2017 12:06
By adding a tox env for eslint, we allow users to run it locally as part of
tox runs.

Thanks for the suggestion @ericholscher!
@cmc333333
Copy link
Contributor Author

Thanks @agjohnson . I've been going down a rabbit hole of tox configurations to try to avoid setting up a whole python env, but I'm pleased with this state.

@agjohnson
Copy link
Contributor

Great, yeah this is a solid addition. I've opened up #2909 to actually address the linting rules to a stricter level.

@agjohnson agjohnson merged commit 9e07061 into readthedocs:master May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants