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 flags/options to set custom exit codes depending on the severity #7659

Open
alSergey opened this issue Apr 27, 2024 · 10 comments
Open

Add flags/options to set custom exit codes depending on the severity #7659

alSergey opened this issue Apr 27, 2024 · 10 comments
Labels
status: needs discussion triage needs further discussion

Comments

@alSergey
Copy link

alSergey commented Apr 27, 2024

What is the problem you're trying to solve?

We have a fe stylelint job in GitLab CI that runs stylelint checks. Currently there is no way to show a warning in a job if stylelint ends with a warning.

What solution would you like to see?

Add a new exit code, which will be triggered if stylelint checks find 0 error and more than 0 warning.

fe stylelint:
  script:
    - npx stylelint **/*.css
   allow_failure:
      exit_codes: X
@Mouvedia Mouvedia added the status: needs clarification triage needs clarification from author label Apr 27, 2024
@Mouvedia
Copy link
Contributor

Mouvedia commented Apr 27, 2024

If you add --max-warnings 0 it should exit 2 if you have 1 or more warnings.

@alSergey
Copy link
Author

alSergey commented Apr 27, 2024

This option doesn't suit me. I want my job to not crash with an error when stylelint ended with warning. What i want:

  • stylelint command completed successfully (0 errors, 0 warnings) - job successful
  • stylelint command ended with warnings (0 errors, more than 0 warnings) - job warning
  • stylelint command ended with errors (more than 0 errors) - job errors

In GitLab CI this can be implemented using exit code.

@Mouvedia
Copy link
Contributor

Mouvedia commented Apr 27, 2024

That sounds like a change that would break many scripts that assumes 2 for errors and --max-warnings.
It could possibly be done in the next major version.

Adding 2 new flags that sets custom exit code for lint problems of severity error and warning could be a solution in the meantime.
e.g. --lint-error-code 3, --lint-warning-code 4
It must fail if the custom code is one of the reserved ones.

@Mouvedia Mouvedia changed the title Change Request: (add stylelint warnings exit code) Add flags/option to set custom exit codes depending on the severity Apr 27, 2024
@Mouvedia Mouvedia changed the title Add flags/option to set custom exit codes depending on the severity Add flags/options to set custom exit codes depending on the severity Apr 27, 2024
@Mouvedia Mouvedia added status: needs discussion triage needs further discussion and removed status: needs clarification triage needs clarification from author labels Apr 27, 2024
@alSergey
Copy link
Author

Adding the flags feature sounds like a cool solution that won't break anything. At the same time, it will solve my problem.

@Mouvedia
Copy link
Contributor

@ybiquitous what's your take on this?
It seems like a legitimate request. Do you have proposals for the names?

@ybiquitous
Copy link
Member

@alSergey Just to clarify, you want a different exit code from 0 if lint problems are only warning, right?

$ stylelint error-and-warning.css
...
✖ 2 problems (1 error, 1 warning)

$ echo $?
2

$ stylelint warning.css
...
⚠ 1 problem (0 errors, 1 warning)

$ echo $?
0   #=> Do you want a different exit code here?

@alSergey
Copy link
Author

@ybiquitous Yes, you got it right. I need this to do a warning job in GitLab CI. As @Mouvedia suggested, this can be done through the flag feature, then it won’t break anything.

@ybiquitous
Copy link
Member

@alSergey Thanks for the answer. I understand your motivation. I was wondering if ESLint CLI had already provided a similar option (I couldn't find such an option in the ESLint doc). If you have the same problem with ESLint, can you please provide us with some information?

@alSergey
Copy link
Author

The eslint cli also does not have this option, so I opened an issue for them. Let's see what they answer me there.

@ybiquitous
Copy link
Member

Thanks for sharing the ESLint issue. I agree with seeing an ESLint team's answer.

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

No branches or pull requests

3 participants