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

Pass filename to stylelint #11

Merged
merged 3 commits into from
Dec 14, 2017
Merged

Pass filename to stylelint #11

merged 3 commits into from
Dec 14, 2017

Conversation

cristianl
Copy link
Contributor

When working with stdin, stylelint needs the filename to determine the syntax of the file.

This fixes a bug: all files would be linted as CSS, so SCSS files that are not plain valid CSS files would get a CssSyntaxError.

When working with stdin, stylelint needs the filename to determine the syntax of the file.
@jo-sm
Copy link
Owner

jo-sm commented Nov 23, 2017

Hey @cristianl good catch! Thanks for working on this.

I think it makes more sense to pass a --lang or --language flag, rather than the filename. Although there is already a --file flag available, I intended it to be used for determining the configuration location, rather than the language of the file. Sorry if this was a little weird/confusing, and now I realize that I should probably rework how the configuration file location determination code works within stylelint_d.

Anyway, if you can change it to support the --lang or --language flag, and also ideally a way to alert the user if their language selection isn't valid, I'll merge this in. Internally you can use the syntax API option (see the Stylelint Node API docs about this flag) when passing to the actual stylelint process.

Tells stylelint the syntax of a stylesheet from stdin
@cristianl
Copy link
Contributor Author

Oh, I went with the laziest approach that would work without requiring modifications to SublimeLinter-contrib-stylelint_d. Something about nails and hammers...

Should I keep the codeFilename block or only support the --language flag? Plugins using stylelint_d would have to implement their own syntax detection, which seems wasteful.

Even when you pass codeFilename you can override the syntax, as the value of syntax always takes precedence over what stylelint infers from codeFilename.

@jo-sm
Copy link
Owner

jo-sm commented Dec 3, 2017

Hmm, good point. Originally I would say only support the --language flag, but I think that's a valid argument to keep both. In that case, can you make a condition to warn the user if they use both flags, in case they have valid reasons to override the syntax from the filename? Otherwise it looks good and I'll merge it after that.

@jo-sm
Copy link
Owner

jo-sm commented Dec 12, 2017

Hey @cristianl just wanted to check in on this, were you able to take a look at my comments?

@cristianl
Copy link
Contributor Author

cristianl commented Dec 14, 2017

Hi @jo-sm, sorry for not replying sooner. I'm not sure I understand your request: should I warn the user that the value from --language will override the file extension?

@jo-sm
Copy link
Owner

jo-sm commented Dec 14, 2017

Yeah, essentially the language flag will take precedence over the file extension, including if they supply both the --file and --language flags. I just want to make it clear to the user that if they supply both, that the --language flag overrides or has higher precedence than the extension/--file flag.

@cristianl
Copy link
Contributor Author

Done. Let me know if it needs further changes.

@jo-sm
Copy link
Owner

jo-sm commented Dec 14, 2017

Looks good, thanks for the PR!

@jo-sm jo-sm merged commit df93aec into jo-sm:master Dec 14, 2017
jo-sm pushed a commit that referenced this pull request Sep 25, 2019
Allow passing language explicitly via --language flag
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.

2 participants