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

Add --stdin flag #4570

Closed
alypeng opened this issue Jan 27, 2020 · 2 comments · Fixed by #4594
Closed

Add --stdin flag #4570

alypeng opened this issue Jan 27, 2020 · 2 comments · Fixed by #4594
Labels
status: ready to implement is ready to be worked on by someone type: enhancement a new feature that isn't related to rules

Comments

@alypeng
Copy link
Contributor

alypeng commented Jan 27, 2020

Clearly describe the bug

If a.css is an empty file then cat a.css | stylelint outputs help instead of an error.

Which rule, if any, is the bug related to?

no-empty-source

What CSS is needed to reproduce the bug?

An empty file (e.g. touch a.css)

What stylelint configuration is needed to reproduce the bug?

{
  "rules": {
    "no-empty-source": true
  }
}

Which version of stylelint are you using?

13.0.0

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

CLI

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

No

What did you expect to happen?

Same output as stylelint a.css

a.css
 1:1  ✖  Unexpected empty source   no-empty-source

What actually happened (e.g. what warnings or errors did you get)?

Same output as stylelint --help


  A mighty, modern CSS linter.

  Usage: stylelint [input] [options]

  Input: Files(s), glob(s), or nothing to use stdin.

    If an input argument is wrapped in quotation marks, it will be passed to
    globby for cross-platform glob support. node_modules are always ignored.
    You can also pass no input and use stdin, instead.

  Options:

...

Possibly related to #1557

@jeddy3
Copy link
Member

jeddy3 commented Jan 27, 2020

@alypeng Thanks for the report and for using the template.

What did you expect to happen?

Same output as stylelint a.css

That does seem like the best behaviour. I suspect ESLint has its --stdin flag to support this behaviour. Without the flag ESLint, like stylelint, prints help when an empty file is piped to it.

Ideally, we can achieve this without a new flag because turning off stdin support by default would be a breaking change.

I'll label as a discussion to see if anyone else has an opinion on this.

@jeddy3 jeddy3 added the status: needs discussion triage needs further discussion label Jan 27, 2020
@jeddy3 jeddy3 changed the title Support piping an empty file to stdin Add --stdin flag Feb 11, 2020
@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone type: enhancement a new feature that isn't related to rules and removed status: needs discussion triage needs further discussion labels Feb 11, 2020
@jeddy3
Copy link
Member

jeddy3 commented Feb 11, 2020

I suggest we implement this as a non-breaking change. We can keep the existing default behaviour, but add a new --stdin flag that changes the behaviour of the CLI to not trigger help if an empty file it piped in.

We would document the flag in the Developer guide > Usage > CLI (options), perhaps as:

### `--stdin`

Force accepting of the standard input stream even if it is empty

I've labelled the issue as ready to implement. Please consider contributing if you have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to implement is ready to be worked on by someone type: enhancement a new feature that isn't related to rules
Development

Successfully merging a pull request may close this issue.

2 participants