sheerun / prettier-standard

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

Decorator warnings after the update to 7.0.1 (from 6.0.0) #30

Closed whphhg closed 5 years ago

whphhg commented 7 years ago

I ran into some minor issues after updating from 6.0.0 to 7.0.1.

Peer dependencies are not satisfied for these two packages anymore because of eslint@4.7.2.

npm WARN eslint-plugin-import@2.2.0 requires a peer of eslint@2.x - 3.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react@6.10.3 requires a peer of eslint@^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

All decorators get reported as defined but never used, and functions using decorators are reported as is not defined.

/home/user/e/src/components/Transaction.js:2:10: 'translate' is defined but never used.
/home/user/e/src/components/Transaction.js:3:10: 'inject' is defined but never used.
/home/user/e/src/components/Transaction.js:3:18: 'observer' is defined but never used.
/home/user/e/src/components/AddressGet.js:4:18: 'computed' is defined but never used.

The ones above reference these imports.

import React from 'react'
import { translate } from 'react-i18next'
import { computed } from 'mobx'
import { inject, observer } from 'mobx-react'

export default @observer class Test extends React.Component {
  render () {
    return (
      <div>hello</div>
    )
  }
}
sheerun commented 7 years ago

Thanks, I'll investigate

sheerun commented 7 years ago

This should be fixed in 7.0.3, could you check?

whphhg commented 7 years ago

I'm getting the same response.

If you want to try yourself, you can git clone https://github.com/openvcash/vcash-electron and update your devDep to 7.0.3 and npm run format.

I've since switched to the method used in the issue referenced above for the time being (using eslint & prettier directly).

sheerun commented 7 years ago

@whphhg I don't experience warnings you mention:

vcash-electron  node_modules/.bin/prettier-standard --version
7.0.3
vcash-electron  node_modules/.bin/prettier-standard 'src/**/*.js'
54 files were unchanged

I think you're getting these warnings because of && standard at the end of format script:

"format": "prettier-standard 'src/**/*.js' && standard"

standard is for linting, not formatting, so it's reasonable you're getting extra messages (it's because prettier-standard is not able to automatically fix all rules standard uses, only fixable ones. for example it cannot automatically fix "is defined but never used." errors).

whphhg commented 7 years ago

I understand the above (difference between the two use-cases). Sorry for a poor issue description. I think we're on the same page regarding what each packages does.

I'll try to better describe the issue.

When using prettier-standard@6.0.0 there are no errors / warnings reported by standard. As soon as I upgrade to prettier-standard@7.0.x and format the src/ directory, standard reports the warnings for files that were formatted.

Furthermore, if I save (ctrl-s, nothing else) any of the files that were not formatted by prettier-standard@7.0.x in the src/components/ or src/stores then standard reports the defined but never used / not defined warnings for those files as well.

You can format (or just save) file by file (src/components/, src/stores/ or any other file which uses decorators) and see the warnings show up in standard output (npm run lint).

To be clear, everything is defined and used (no linting warnings should be reported), but for some reason after upgrading to prettier-standard@7.0.x, standard stops respecting decorators and reports the warnings above.

azizhk commented 6 years ago

Ok so I'm getting the same error when I install prettier-standard, standard itself starts throwing the above errors that class properties are not defined.

yarn list standard:
└─ standard@10.0.3

yarn list eslint:
├─ eslint@4.17.0
└─ standard@10.0.3
   └─ eslint@3.19.0

yarn list prettier-standard:
└─ prettier-standard@8.0.0

yarn list babel-eslint:
├─ babel-eslint@7.2.3
└─ prettier-standard@8.0.0
   └─ babel-eslint@8.2.1

without prettier standard we have just one version of eslint and babel-eslint. also getting the error without prettier-standard if babel-eslint's version is ^8.0.0. So there is something fishy happening where installing prettier-standard makes standard's babel-eslint version to be ^8.0.0

sheerun commented 5 years ago

This should be fixed for prettier-standard@9