-
Notifications
You must be signed in to change notification settings - Fork 550
Lint static files and dependencies with eslint + knip #23198
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95af7be
to
d2d5c30
Compare
1f5c6dd
to
ae0e908
Compare
60d568a
to
2f1c508
Compare
Rebased after merging the vite cleanup |
2f1c508
to
05e6ae6
Compare
deac710
to
52c3283
Compare
@KevinMind wrong issue linked ? |
965ed1c
to
28aaac5
Compare
28aaac5
to
9ba5a8a
Compare
47dcbea
to
58c1dfe
Compare
fbd213e
to
ba88b76
Compare
Rebased version #23230 |
Closed in favor of #23229 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: mozilla/addons#15482
Description
add eslint + knip + styleline to handle code style and formatting
Context
Ensure our static files are high quality with stricter linting rules. All of the changes in the
./static
directory are a result of automated formatting or light manual changes when automatic formatting didn't work.This PR will be too big to review, but you can scan the commits to see how each tool is introduced in a pattern:
Javascript
We already used prettier for formatting, but eslint includes a more robust set of checks and extendable rules. Additionally prettier can be run via eslint, so there's still just one tool to call. Finally, knip is useful for identifying "dead code" that is not imported or used anywhere.. as you can see we had a fair bit of that.
Re-writing the config files in
.ts
just makes them a lot easier to validate while editing them as vscode will give you the type errors. Again, as you can see, there were invalid properties there that were previously missed.Finally, zod gives syntax and runtime validation of our environment variables. Ensures you cannot run the build without valid parameters defined in the environment.
LESS/CSS
Using styleline I used the same approach as for JS, applied each rule one at a time to make it clear exactly what is changing why.
Testing
Test that addons-server can run addons-linter by verifying file upload works with validation as expected.
You can test the linting by:
npm i react -S
./static/js|css
directories.Run
make lint
and expectknip
to show errors in each case.Finally, you can test that knip will fix it's mistakes. After adding the additional dead code/deps run
make format
and knip should remove the files and dependency from package.json. The undefined variable may or may not be fixed automatically but if you "unformat" some code it should be reformatted.Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.