-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(template-lint): Read from stdin #2622
feat(template-lint): Read from stdin #2622
Conversation
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.
The reason the author is checking a temporary file is so they can check for problems with the buffer as you type. Does this linter support some sort of option to make this work properly? If it does, find out that that is and use it. If it doesn't, set 'lint_file': 1
so the linter only runs when the buffer is opened/saved.
Interesting! Thank you for your guidance. Unfortunately, there is no such option with this linter. I've added the |
It should be good now :) |
Reading from stdin is currently being added in template-lint. Maybe we should wait for that feature and then update this PR. |
Okay, let's wait for that then. Sorry for the delay. |
Cross-linking the wip for future reference: ember-template-lint/ember-template-lint#783 |
The above-mentioned PR has been merged in ember-template-lint. I've updated this PR to lint from stdin. It should be good now @w0rp! |
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.
Update the tests to handle this. I think we should add a --version
check for this linter too, so it will work with older and newer versions. ale_linters/php/phpstan.vim
contains some pretty good example code for running different commands for different versions.
@@ -34,6 +34,6 @@ call ale#linter#Define('handlebars', { | |||
\ 'executable': {b -> ale#node#FindExecutable(b, 'handlebars_embertemplatelint', [ | |||
\ 'node_modules/.bin/ember-template-lint', | |||
\ ])}, | |||
\ 'command': '%e --json %t', | |||
\ 'command': '%e --json < %t', |
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.
If you take < %t
away from the command, ALE should pipe in stdin to the command automatically. ALE does that whenever %t
isn't present in the command, and the read_buffer
option isn't set to 0
.
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.
Ok, I didn’t know that. I will update accordingly.
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.
@dcyriller - We should also pass the current file name in via --filename
(so that the linting rules that make changes based on filename have the correct value).
This feature has recently been implemented in ember-template-lint.
@w0rp it should be ready for review |
I wound need some help to understand why the CI is failing. @w0rp is there any chance you have some time to help me on this? |
|
||
AssertEqual | ||
\ ale_linters#handlebars#embertemplatelint#GetCommand(bufnr(''), [2, 0, 0]), | ||
\ '%e --json --filename /testplugin/test/ember-template-lint-test-files/app/template.hbs' |
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.
This fails on Windows: https://ci.appveyor.com/project/dense-analysis/ale/builds/32131713?fullLog=true#L316
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.
Something like:
if has('win32')
let g:ember_template_lint_command =
\ '%e --json --filename C:\testplugin\test\ember-template-lint-test-files\app\template.hbs'
else
let g:ember_template_lint_command =
\ '%e --json --filename /testplugin/test/ember-template-lint-test-files/app/template.hbs'
endif
AssertEqual
\ ale_linters#handlebars#embertemplatelint#GetCommand(bufnr(''), [2, 0, 0]),
\ g:ember_template_lint_command
should work.
Okay CI is green now, thanks a lot for your help @jamescdavis! This PR has been tested locally by a few people I believe @w0rp. So the changes should be safe 😄. Do you mind giving it a review? |
Oh, that's much better than the conditional! |
I tested locally again with this latest change and can confirm it works. |
friendly ping @w0rp |
Also ping @hsanson 😉 |
This doesn't work because |
Cheers! 🍻 |
Thanks a lot @w0rp ! |
* master: (123 commits) Add tests for maven.vim file Fix grammatical error in doc Add maven helper file; use maven wrapper if available instead of global 'mvn' executable fix lint, fix variable semantics and update tests bibclean: update matchlist reges for bibclean > v2.11.4 Bump the ALE version to 3.0.0 Close dense-analysis#2522 - Check pylint on the fly Add tests for covering the coming Vint version Close dense-analysis#3003 - Show ignored linters in :ALEInfo Close dense-analysis#3333 - Add an ALECompletePost event Fix a completion error Fix typo Close dense-analysis#3268 - Implement :ALEImport Fix dense-analysis#3183 - Escape filename characters from LSP/tsserver Clean up embertemplatelint code Fix asciidoc languagetool integration Fix dense-analysis#3322 - Apply rename changes correctly feat(template-lint): Read from stdin (dense-analysis#2622) Fix flake8 cd logic for invalid options Add tests for \r removal ...
Description
This PR proposes to leverage a new feature introduced in ember-template-lint v1.6: reading from stdin.
Currently, ale copies the file to a temporary file and lints it from there. But this approach has a few issues regarding the configuration files (especially
.prettierrc.js
).