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

Shoudn't format file when only prettier can process file #68

Closed
sheerun opened this issue Apr 18, 2017 · 5 comments
Closed

Shoudn't format file when only prettier can process file #68

sheerun opened this issue Apr 18, 2017 · 5 comments

Comments

@sheerun
Copy link
Contributor

sheerun commented Apr 18, 2017

If file has non-standard syntax, like class properties, prettier-eslint passes source through prettier but silently skips transforming through eslint. This behavior makes file to be formatted with default prettier settings, while the expected behavior is leaving file intact.

Example file:

import React from 'react';

class Example extends React.Component {
  state = {
    foo: 'bar'
  }
  
  render() {
    return <div foo='bar'></div>
  }
}

if you format this with prettier-eslint rules set to

{
  quotes: [
    'error',
    'single',
    {avoidEscape: true, allowTemplateLiterals: true}
  ],
  'jsx-quotes': ['error', 'prefer-single'],
}

the jsx is formatted to double quotes

@kentcdodds
Copy link
Member

Hmmmmm... Are you sure that's what's happening? If you look at the source code, you'll see that it throws an error if prettier or eslint fail.

If it is a problem, feel free to open a pull request to fix it. Thanks!

@sheerun
Copy link
Contributor Author

sheerun commented Apr 18, 2017

I'm sure only about the result, maybe it happens because of some other reason

@kentcdodds
Copy link
Member

Any chance you could make a repo that reproduces the issue?

@sheerun
Copy link
Contributor Author

sheerun commented Apr 19, 2017

It's no longer an issue for me, I ended up configuring babel-eslint parser so any syntax babel recognizes is possible. You might consider the same for prettier-eslint-cli: sheerun/prettier-standard@eea070e

@sheerun sheerun closed this as completed Apr 19, 2017
@kentcdodds
Copy link
Member

Thanks for sharing. I think it's not an issue for prettier-eslint because people configure ESLint with the parser that works for their code. So if they're using ESNext code that ESLint doesn't support, they'll specify they want to use the babel-eslint parser and that's what we'll use.

Cheers.

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