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

CLI: Exit code is 0 when --check is specified and "no parser could be inferred" (since version 3.1) #16146

Open
advanderveer opened this issue Mar 12, 2024 · 1 comment
Labels
area:cli Issues with Prettier's Command Line Interface type:bug Issues identifying ugly output, or a defect in the program
Milestone

Comments

@advanderveer
Copy link

advanderveer commented Mar 12, 2024

Environments:

  • Prettier Version: 3.1.0, 3.2.5, 3.0.3
  • Running Prettier via: CLI
  • Runtime: Node 20
  • Operating System: MacOs
  • Prettier plugins (if any): none

Steps to reproduce:

➜  atswui git:(ci_setup) ✗ yarn add prettier@3.0.3      
➤ YN0000: · Yarn 4.1.1
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + prettier@npm:3.0.3
➤ YN0085: │ - prettier@npm:3.1.0
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 345ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 0s 244ms
➤ YN0000: · Done in 0s 778ms
➜  atswui git:(ci_setup) ✗ yarn check:formatting  
Checking formatting...
[warn] src/app/app.component.html
yarn.lock
[error] No parser could be inferred for file "/Users/adam/Documents/Projects/github.com/crewlinker/atswui/yarn.lock".
[warn] Code style issues found in the above file. Run Prettier to fix.
➜  atswui git:(ci_setup) ✗ echo $?
1
➜  atswui git:(ci_setup) ✗ yarn add prettier@3.1.0
➤ YN0000: · Yarn 4.1.1
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + prettier@npm:3.1.0
➤ YN0085: │ - prettier@npm:3.0.3
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 300ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 0s 219ms
➤ YN0000: · Done in 0s 706ms
➜  atswui git:(ci_setup) ✗ yarn check:formatting  
Checking formatting...
yarn.lock
[error] No parser could be inferred for file "/Users/adam/Documents/Projects/github.com/crewlinker/atswui/yarn.lock".
All matched files use Prettier code style!
➜  atswui git:(ci_setup) ✗ echo $?
0

The command "check:formatting" runs: "check:formatting": "prettier --check \"**/*\""
Note: it is also an issue in the latest version

Expected behavior:
Should exit with status code 1
Actual behavior:
Exits with status code 0 since version 3.1.0

@advanderveer advanderveer changed the title CLI: Exit code is 0 when --check is specified, even when NOT using stdin (since version 3.1) CLI: Exit code is 0 when --check is specified and "no parser" (since version 3.1) Mar 12, 2024
@advanderveer advanderveer changed the title CLI: Exit code is 0 when --check is specified and "no parser" (since version 3.1) CLI: Exit code is 0 when --check is specified and "no parser could be inferred" (since version 3.1) Mar 12, 2024
@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program area:cli Issues with Prettier's Command Line Interface labels Apr 6, 2024
@sosukesuzuki
Copy link
Member

I think this is a bug, but it is a breaking change and will be addressed in the next major version.

@sosukesuzuki sosukesuzuki added this to the 4.0 milestone Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:cli Issues with Prettier's Command Line Interface type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants