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 --stdin-file-path option #125
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.
Overall supportive, just some small questions.
end.flatten | ||
else | ||
collect_lints($stdin.read, options[:stdin_file_path], linter_selector, config) | ||
end | ||
|
||
SlimLint::Report.new(lints, files) |
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.
It seems like we would need to ensure files
is correctly updated to use the provided stdin_file_path
, which is missing here. Have we tested this? What do the reports show?
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.
Could you clarify how exactly should it be updated? Currently with stdin files = extract_applicable_files(config, options)
returns an empty array.
This is how it works:
$ cat t.slim
divdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdivdiv
= 1
$ cat t.slim | bundle exec ./bin/slim-lint --stdin-file-path index.slim
warning: parser/current is loading parser/ruby27, which recognizes
warning: 2.7.3-compliant syntax, but you are running 2.7.2.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
index.slim:1 [W] LineLength: Line is too long. [105/80]
or in short
index.slim:1 [W] LineLength: Line is too long. [105/80]
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.
Right, you don't want to pass an empty files
array to SlimLint::Report.new(lints, files)
. You would want to pass a single item array containing [options[:stdin_file_path]]
, i.e. files = [options[:stdin_file_path]]
.
See the definition for the Report
class. It's expecting the list of files that were linted:
slim-lint/lib/slim_lint/report.rb
Lines 9 to 10 in f9c2c21
# List of files that were linted. | |
attr_reader :files |
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.
Thanks! I changed that files
variable as you asked. For your information, it didn't change the output, everything is still same.
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.
Ah, that's probably because the default reporter doesn't use files
. But it is used by other reporters.
lib/slim_lint/runner.rb
Outdated
@@ -19,9 +19,14 @@ def run(options = {}) | |||
|
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.
Could we skip calling extract_applicable_files
since it isn't necessary if you're passing in a single file via standard input?
Let me know if you want any squashing of commits |
Refs #50
Hi, decided to add this option