-
Notifications
You must be signed in to change notification settings - Fork 10
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
Init setup to lint HTML & HTML ERB files #730
Open
Splines
wants to merge
11
commits into
dev
Choose a base branch
from
lint/html
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
Splines
added
the
ide
Related to integrated developer environments, e.g. VSCode etc.
label
Dec 15, 2024
f-buerckel
approved these changes
Dec 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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.
New HTML Linters
With version 2.1.0, I've made my
eslint-plugin-erb
ready to be pluggable intohtml-eslint
, also see my comment on this issue. This allows us to lint the pure HTML part (in.html
and.html.erb
files).To also lint the ERB tags inside
.html.erb
files, I set up Shopify'serb_lint
and deactivate purely HTML-specific linters. This allows us to have RuboCop look over the ERB tags and many other linters which is quite nice.VSCode Integration
Tip
After having checked out this branch, you have to update your NPM dependencies, i.e.
yarn install
. Otherwise, no linting with ESLint will work anymore.erb_lint
only offers a CLI tool. I've also tried out this ERB Linter extension but it didn't quite work for me. So, instead, I've added thisRun on Save
extension and let it run the erb_lint CLI every time the file is saved. I've also added the respective CLI command to a newjust lint erb
command.Note that compared to the speed of ESLint wrapped inside the extension, this is really slow as
bundle exec
has to invoked and thenerb_lint
itself seems to be quite slow. So what you will experience is quick linting for HTML, then wait a bit to also get ERB parts auto-corrected.In the future, we might consider finding (or writing our own small) VSCode extension such that erb_lint can run more quickly on files as it doesn't have to use the terminal and instead can be directly integrated as formatter into the VSCode API.
Tip
I've added a new recommended extension (Run on Save) to our workspace that you should install in order for
erb_lint
to work automatically as soon as you save the file.Warning
erb_lint will overwrite the file content. As it is slow, you might have already adjusted the file in the meantime. VSCode will then show a popup "The content on disk is newer...". As this is quite annoying, I've added the
"files.saveConflictResolution": "overwriteFileOnDisk",
. This also means: don't edit files outside of VSCode for MaMpf, otherwise you might loose some code!Reviewers
This PR is currently in draft as I want to experiment a bit more with all the rules that html-eslint provides. Feel free to do the same and see the effects on some real-world examples in our codebase. After this PR, I will file another PR that does something like this:
and additionally adds the
--fix
option.I also hope that html-eslint will get a
max-length
for lines, see my feature request here: yeonjuan/html-eslint#251.