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

--allow-empty-input CLI flag not working #4649

Closed
yipei1028 opened this issue Mar 13, 2020 · 6 comments
Closed

--allow-empty-input CLI flag not working #4649

yipei1028 opened this issue Mar 13, 2020 · 6 comments
Labels
status: needs clarification triage needs clarification from author

Comments

@yipei1028
Copy link

yipei1028 commented Mar 13, 2020

Clearly describe the bug

While stylelint running CLI with --allow-empty-input, there are still error throwed...

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

None.

What code is needed to reproduce the bug?

None.

What stylelint configuration is needed to reproduce the bug?

None.

Which version of stylelint are you using?

13.2.0

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

CLI with stylelint --allow-empty-input

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

None.

What did you expect to happen?

No error, while no input files it should exit quietly.

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

Error and exit code 2. It seems like there is no flag --aei


This issue is related to #2048 #3880 #4029

@jeddy3
Copy link
Member

jeddy3 commented Mar 13, 2020

@yipei1028 Thanks for the report.

I can't reproduce this locally.

% npx stylelint -v      
13.2.1
% npx stylelint "*.none" --allow-empty-input
% echo $?                                   
0
% npx stylelint "*.none" --aei              
% echo $?                     
0
% npx stylelint "*.none"                    
Error: No files matching the pattern "*.none" were found.
    at /Users/jeddy3/Projects/stylelint/lib/standalone.js:213:12
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
% echo $?               
1

ANS: CLI with stylelint --allow-empty-input

Unless you are piping std-in to stylelint, you need to specify an input glob.

From the CLI help:

--allow-empty-input, --aei
  When glob pattern matches no files, the process will exit without throwing an error.

Using --aei without a glob display the CLI help and exits with 2.

Do you have a use case where you aren't specifying a glob?

@jeddy3 jeddy3 added the status: needs clarification triage needs clarification from author label Mar 13, 2020
@yipei1028
Copy link
Author

yipei1028 commented Mar 18, 2020

Hi @jeddy3 ,
Appreciate for your quick reply.
Looks like I taking this --allow-empty-input the wrong way: The word empty makes me think I can really put nothing inside.

Only running the stylelint command should display the stylelint CLI help. (I found it here) Not sure should it throw error or not 😕
Correct me if I misunderstood.

And will u consider changing the name of the option? Say something like --allow-no-match. Rather than allow empty, what exactly happened here is more like there is no match with your input string.

Thank you in advance. 👍 👍 👍

// Not working
npx stylelint --aei 

// working
npm stylelint  "*.none" --aei 

@jeddy3
Copy link
Member

jeddy3 commented Mar 25, 2020

// Not working
npx stylelint --aei

What's your use case for providing no glob? I suspect all users would provide a glob unless they are piping in from stdin.

@jeddy3
Copy link
Member

jeddy3 commented May 10, 2020

Closing due to inactivity.

@seeliang
Copy link

seeliang commented Oct 17, 2021

BTW, the same set works with eslint

@johnnybenson
Copy link

johnnybenson commented Nov 9, 2021

yarn stylelint --config ./stylelint.config.js $(git diff --name-only --oneline --relative | egrep '\\.ts$|\\.tsx$\\.js$') --allow-empty-input

Glob is slower than only linting modified files.

The nested git command returns empty when there are no modified files and --aei still exits with 2 instead of 0.

It should exit 0 IMO.

FWIW, workaround it with this:

stylelint --config ./stylelint.config.js $(git diff --name-only --oneline --relative | egrep '\\.tsx$|\\.ts$' | awk -v def=\"*.none\" '{print} END { if(NR==0) {print def} }') --allow-empty-input

If git diff returns nothing, a glob pattern that is guaranteed to miss will exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification triage needs clarification from author
Development

No branches or pull requests

4 participants