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

Add pre-commit linting hook #570

Merged
merged 1 commit into from
Jan 15, 2020
Merged

Add pre-commit linting hook #570

merged 1 commit into from
Jan 15, 2020

Conversation

bfreeds
Copy link

@bfreeds bfreeds commented Jan 14, 2020

This commit closes #538 by adding a pre-commit hook that lints files staged for commits. This keeps the same eslinting rules as #555, but automates them in the developer process.

During the pre-commit hook, eslint --fix is run, which will automatically take care of formatting lint rules as per our config. I tried integrating prettier which does code formatting nicely, however ran into an issue where eslint --fix wouldn't automatically fix. I think it may be related to this issue: prettier/prettier-vscode#870, or have something to do with the complexity of using airbnb-base, ember, and prettier to work together.

Here's an example of how lint-staged and husky work in the git commit process, fixing some formatting:
2020-01-14 16 44 38

And here's what this would do if you were trying to commit code with a lint error (which would also fail our ember tests):
2020-01-14 16 55 47

@bfreeds bfreeds marked this pull request as ready for review January 14, 2020 21:58
@bfreeds bfreeds requested a review from a team January 14, 2020 21:58
@codecov
Copy link

codecov bot commented Jan 14, 2020

Codecov Report

Merging #570 into develop will increase coverage by 0.92%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop    #570      +/-   ##
==========================================
+ Coverage    45.58%   46.5%   +0.92%     
==========================================
  Files          157     157              
  Lines         1516    1516              
==========================================
+ Hits           691     705      +14     
+ Misses         825     811      -14
Impacted Files Coverage Δ
...mponents/project/project-area-selection-toggler.js 33.33% <0%> (+33.33%) ⬆️
...pp/components/project/project-area-selector-map.js 77.77% <0%> (+66.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3e833d...661e4a9. Read the comment docs.

@bfreeds bfreeds force-pushed the 538-precommit-lint branch from 1e1827b to 661e4a9 Compare January 15, 2020 16:19
@bfreeds bfreeds merged commit 16db2fe into develop Jan 15, 2020
@bfreeds bfreeds deleted the 538-precommit-lint branch January 15, 2020 17:05
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.

Automate linting to improve developer experience
2 participants