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 silent flag to avoid default node error message on --fix #159

Closed
kristianmandrup opened this issue Nov 2, 2016 · 7 comments
Closed

Comments

@kristianmandrup
Copy link

Not clear how to run xo --fix in silent mode to avoid the exit code 1 error displayed.
Please advice. Thanks :)

18:19 $ npm run fix

> nodelib-2017@1.0.0 fix /Users/kristianmandrup/repos/node-libs/nodelib-2017
> xo --fix --quiet


  src/a.test.js:2:8
  ✖  2:8  goofy is defined but never used.  no-unused-vars

  1 error

npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "fix"
npm ERR! node v6.9.1
npm ERR! npm  v4.0.1
npm ERR! code ELIFECYCLE
npm ERR! nodelib-2017@1.0.0 fix: `xo --fix --quiet`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the nodelib-2017@1.0.0 fix script 'xo --fix --quiet'.
@kristianmandrup
Copy link
Author

Discovered a solution xo --fix -- -s :)

@kristianmandrup
Copy link
Author

kristianmandrup commented Nov 2, 2016

Would be nice if there was a way to display the errors, but still avoid the final node fail error.
When I run xo with --fix and "semicolon": false" my code still has semicolons.

@kristianmandrup
Copy link
Author

My xo package.json settings:

  "xo": {
    "esnext": true,
    "parser": "babel-eslint",
    "semicolon": false,
    "reporter": "compact",
    "plugins": [
      "filenames"
    ],
    "rules": {
      "filenames/match-regex": [
        2,
        "^[a-z-\\.]+$",
        true
      ]
    }
  },

@sindresorhus
Copy link
Member

Not clear how to run xo --fix in silent mode to avoid the exit code 1 error displayed.

Why do you want to avoid the exit code 1? --fix reports the remaining errors so you know what you need to manually fix.

When I run xo with --fix and "semicolon": false" my code still has semicolons.

That's weird. The semi rule has auto-fixing: http://eslint.org/docs/rules/semi

"filenames/match-regex": [

Btw, XO already includes a filename rule that does this:
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/filename-case.md

@friday
Copy link

friday commented Nov 6, 2016

You can add || true after the xo command. It would have the same effect as the -s flag

  "scripts": {
    "fix": "xo --fix || true"
  }

@kristianmandrup
Copy link
Author

Thanks a lot guys. I will try.

@fregante
Copy link
Member

fregante commented Aug 6, 2022

Closing as resolved. || true is the native way to do this and it's shorter than any flag ever could.

Eslint doesn't offer such a flag either https://eslint.org/docs/latest/user-guide/command-line-interface

@fregante fregante closed this as completed Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants