Berry: [Bug] `yarn run` incorrect exit code (regression)

Created on 15 Oct 2020  Â·  5Comments  Â·  Source: yarnpkg/berry

  • [x] I'd be willing to implement a fix

Describe the bug

I have the following script in my package.json:
"lint": "eslint --max-warnings 0 --ext=ts,tsx . && prettier --check .",
In yarn 2.1.1, if eslint finds a warning, it exits with exit code 1.
In yarn 2.3.3, if it finds a warning, it exits with exit code 0.
I downgraded back to yarn 2.1.1 (yarn set version), it exits with exit code 1.

This change in behaviour is not listed in the changelog and it is critical to fix for CI.
On a less relevant note, the reason for upgrading is the addition of the yarn dedupe command, which I also did not find in the changelog. That said, thanks for making yarn!

To Reproduce

Clone https://github.com/Dico200/reproduce-yarn-exit-code-0
Follow instructions in readme.
I tested this on windows, you may need to adapt the instructions for linux (where the bug may or may not happen).
It should be easy to confirm a fix by using a different yarn version in the instructions.

Screenshots

Output from following the instructions on my computer:

C:\CA\reproduce-yarn-exit-code-0>yarn run lint

C:\CA\reproduce-yarn-exit-code-0\index.js
  1:1  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  1:1  error  'oi' is not defined                                                    no-undef
  1:3  error  Trailing spaces not allowed                                            no-trailing-spaces

✖ 3 problems (3 errors, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.


C:\CA\reproduce-yarn-exit-code-0>echo %errorlevel%
0

C:\CA\reproduce-yarn-exit-code-0>yarn set version 2.1.1
➤ YN0000: Downloading https://github.com/yarnpkg/berry/raw/%40yarnpkg/cli/2.1.1/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-2.1.1.cjs
➤ YN0000: Done in 1s 617ms

C:\CA\reproduce-yarn-exit-code-0>yarn run lint

C:\CA\reproduce-yarn-exit-code-0\index.js
  1:1  error  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  1:1  error  'oi' is not defined                                                    no-undef
  1:3  error  Trailing spaces not allowed                                            no-trailing-spaces

✖ 3 problems (3 errors, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.


C:\CA\reproduce-yarn-exit-code-0>echo %errorlevel%
1

Environment

  • OS: Windows 10
  • Node version v12.16.3
  • Yarn version v2.3.3 (berry)
bug

Most helpful comment

Fixed in https://github.com/yarnpkg/berry/pull/1985, you can test it using yarn set version from sources --branch 1985

All 5 comments

I noticed that running yarn eslint --max-warnings 0 --ext=js . does give the correct exit code.

the issue started with Yarn version 2.3.0

Fixed in https://github.com/yarnpkg/berry/pull/1985, you can test it using yarn set version from sources --branch 1985

the suggested fix works for me

@merceyz Thanks for getting on top of it! That was very fast.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benwainwright picture benwainwright  Â·  3Comments

chrisands picture chrisands  Â·  3Comments

wojtekmaj picture wojtekmaj  Â·  3Comments

mormahr picture mormahr  Â·  3Comments

thealjey picture thealjey  Â·  4Comments