sheerun / prettier-standard

Formats with Prettier and lints with ESLint+Standard! (✿◠‿◠)
MIT License
868 stars 44 forks source link

Prettier-standard output not equal to standard --fix output #10

Closed adonis-work closed 7 years ago

adonis-work commented 7 years ago

Running prettier-standard does not replace double quotes in JSX.

C:\>prettier-standard --version
4.0.0
C:\>prettier-standard test.js
success formatting 1 file with prettier-standard

C:\>type test.js
const GoogleLoginButton = React.createClass({
  componentDidMount: () => {
    window.addEventListener('google-loaded', renderGoogleLoginButton)
    renderGoogleLoginButton()
  },
  render: () => <div id="gmailLogin" />
})

Using standard with --fix replaces the quotes:

C:\>standard --version
9.0.1
C:\>standard --fix test.js
standard: Use JavaScript Standard Style (http://standardjs.com)
  C:\test.js:1:7: 'GoogleLoginButton' is assigned a value but never used.
  C:\test.js:1:27: 'React' is not defined.
  C:\test.js:3:46: 'renderGoogleLoginButton' is not defined.
  C:\test.js:4:5: 'renderGoogleLoginButton' is not defined.

C:\>type test.js
const GoogleLoginButton = React.createClass({
  componentDidMount: () => {
    window.addEventListener('google-loaded', renderGoogleLoginButton)
    renderGoogleLoginButton()
  },
  render: () => <div id='gmailLogin' />
})

How to get this functionality with prettier-standard?

sheerun commented 7 years ago

it work for me (osx), I don't know how to reproduce ;/ could you try to debug it somehow? (please clone this repository)

adonis-work commented 7 years ago

I think that standard --fix does something more than run fixing through eslint rules.

Here is the cli of standard, --fix applies the result of the marked line: https://github.com/Flet/standard-engine/blob/master/bin/cmd.js#L96

Maybe these rules could be of help https://github.com/feross/eslint-config-standard-jsx/blob/master/eslintrc.json

sheerun commented 7 years ago

prettier-standard doesn't use standard for formatting, but prettier-eslint with some eslint rules

sheerun commented 7 years ago

@adonis-work I've released 4.1.0, please check if it works for you

adonis-work commented 7 years ago

Yes, now it works ok. Tnx for fast response.

C:\>type test.js
const GoogleLoginButton = React.createClass({
  componentDidMount: () => {
    window.addEventListener('google-loaded', renderGoogleLoginButton)
    renderGoogleLoginButton()
  },
  render: () => <div id="gmailLogin" />
})

C:\>prettier-standard test.js
success formatting 1 file with prettier-standard

C:\>type test.js
const GoogleLoginButton = React.createClass({
  componentDidMount: () => {
    window.addEventListener('google-loaded', renderGoogleLoginButton)
    renderGoogleLoginButton()
  },
  render: () => <div id='gmailLogin' />
})
sheerun commented 7 years ago

@adonis-work Thank you as well, please feel free to add yourself to contributor list