Skip to content

Commit

Permalink
Fixed linter crash when eslintrc is missing from a repo, but the repo…
Browse files Browse the repository at this point in the history
… has eslintrc.js

Summary:
The olc repo doesn't have an `.eslintrc` but instead has an `eslintrc.js`, because that way you can have comments in the rc, and that's _way_ cooler than no comments....

Khan linters, called by the `pre-push.linter` hook, crashes if there isn't an `.eslintrc` file. Now it checks for both.

Issue: <url or "none">

Test Plan:
In the olc repo, with the pre-push hooks all enabled:
`$ git co -b new-branch`
(maybe make a change and commit so there's something to lint?)
`$ git push -u origin new-branch`
See that linter doesn't crash anymore

Reviewers: kevinb, csilvers, john, adamgoforth

Reviewed By: kevinb, csilvers, john, adamgoforth

Subscribers: csilvers, kevinb

Differential Revision: https://phabricator.khanacademy.org/D73218
  • Loading branch information
lillialexis committed Jul 8, 2021
1 parent 6405721 commit 8cb70d4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions runlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ def _get_linters_for_file(file_to_lint, lang, propose_arc_fixes):
# If eslint_config is None, linters.Eslint will default to the
# configuration in the khan-linter repo.
eslint_config = _find_base_config(file_to_lint, '.eslintrc')

if eslint_config is None:
eslint_config = _find_base_config(file_to_lint, '.eslintrc.js')

# The same is true for the eslint executable.
exec_path = _find_base_config(file_to_lint, 'node_modules/.bin/eslint')
if eslint_config or exec_path:
Expand Down

0 comments on commit 8cb70d4

Please sign in to comment.