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

Parse errors not as pretty as ESLint's #44

Closed
orlin opened this issue Mar 8, 2017 · 2 comments
Closed

Parse errors not as pretty as ESLint's #44

orlin opened this issue Mar 8, 2017 · 2 comments

Comments

@orlin
Copy link

orlin commented Mar 8, 2017

I run prettier-eslint --write through husky & lint-staged. I wonder if there are any lint errors / or warnings that the --write cannot --fix (other than parser errors, maybe a question for eslint?), or rephrased: would there be any use of running eslint after prettier-eslint --write? I wrote more on this here.

While playing with it, I noticed that parse errors are prettier when running just eslint. So I also thought that maybe we could at least have an option for --no-stacktrace, as -l silent is neither silent nor gives enough info about where the error is at. Or maybe a -l concise?

Here is an example of a parse error I get from eslint - contains only the info needed to go fix the code, and a summary of total warnings / errors:

$ eslint $npm_package_config_code

/Users/om/Dev/mel/drmelgill.com/components/reveal.js
  3:20  error  Parsing error: Unterminated string constant

  1 | import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
  2 | import FirstChild from 'components/first-child'
> 3 | import styles from './reveal.js.scss;
    |                    ^
  4 |
  5 | export default props => (
  6 |   <div className='reveal'>

✖ 1 problem (1 error, 0 warnings)

error Command failed with exit code 1.

Here is the same error coming from prettier-eslint --write:

prettier-eslint [ERROR]: prettier formatting failed due to a prettier error
prettier-eslint-cli [ERROR]: There was an error formatting "/Users/om/Dev/mel/drmelgill.com/components/reveal.js":
    SyntaxError: Unterminated string constant (3:19)
      1 | import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
      2 | import FirstChild from 'components/first-child'
    > 3 | import styles from './reveal.js.scss;
        |                    ^
      4 |
      5 | export default props => (
      6 |   <div className='reveal'>
        at Parser.pp$5.raise (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:4333:13)
        at Parser.readString (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:1296:33)
        at Parser.getTokenFromCode (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:1102:21)
        at Parser.readToken (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:771:19)
        at Parser.<anonymous> (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:6626:20)
        at Parser.readToken (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:5443:22)
        at Parser.nextToken (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:761:19)
        at Parser.next (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:686:10)
        at Parser.eat (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:693:12)
        at Parser.pp.eatContextual (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:1661:44)

failure formatting 1 file with prettier-eslint

Running prettier-eslint --write -l silent says:

failure formatting 1 file with prettier-eslint

An alternative request would be to maybe add a --no-error option (making the cli completely silent and with exit code 0), which would allow people to run eslint after prettier-eslint --write --no-error.

@kentcdodds
Copy link
Member

Hey @orlin,
Thanks for your input. If you want to make a pull request, that'd be great. The challenge is that errors can come from any number of modules. prettier-eslint-cli, prettier-eslint, eslint, prettier, or any number of transitive dependencies as well. And previously we didn't show very much information and that led to a lot of people asking for help when more information in the error would have empowered them to fix their issues themselves.

But yeah, feel free to makeapullrequest.com if you feel like it could be improved.

@github-actions
Copy link
Contributor

Stale issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants