-
-
Notifications
You must be signed in to change notification settings - Fork 208
Using decorator doesn't count as usage by eslint #72
Comments
+1 |
Related: Using in decorator's parameters doesn't count as usage either
|
This is currently the biggest blocker for using decorators. Would love to see this fixed! |
+1 |
2 similar comments
+1 |
+1 |
There is also no-shadow hint for such situation with decorator function blabla() {}
@blabla(() => 1)
export class Test {
} gives |
+1. Just ran into this as well. |
👍 |
I guess you can contribute: https://github.com/alexkuz/eslint-plugin-decorator |
I think it should be fixed by "fixing" estraverse to visit decorator AST On Sat, May 16, 2015, 16:35 Dan Abramov notifications@github.com wrote:
|
Can work on this - I guess I'l be using the examples from https://github.com/wycats/javascript-decorators for tests? Looks like there's 3 checks - class, property, method |
Did a PR: #105 |
patch escope to visit decorators - fixes #72
Should be fixed in 3.1.6! |
Thank you! On Thu, May 21, 2015, 04:12 Henry Zhu notifications@github.com wrote:
|
@hzoo You are awesome. Thank you so much. |
Thanks @hzoo ! |
ESLint doesn't realize that use of a decorator constitutes use: babel/babel-eslint#72 Other than that, we're all clean.
This feature apparently was broken sometime between releases |
Nothing was changed related to decorators in the last few releases - most likely an issue with babel. I would either wait for the next release or pin your babel version (or actually maybe we should pin the babel version?). Looking into it though. |
You were right about it being an issue in babel, it seems; as noted in babel/babel#2098 (and other issues that it is a duplicate of), some bug crept into babel, making decorators not working properly. After preventing the issue (by not using parens in decorators), babel-eslint once again recognizes uses within decorators as uses of variables. |
Still not working + 1
|
Can you make a new issue, and post with your config, and eslint, babel-eslint, babel version? Thanks |
Sorry, that's a typo. It's working perfectly. On Wed, Sep 16, 2015 at 7:29 PM, Henry Zhu notifications@github.com wrote:
|
Hi, I'm running into the exact same symptoms on a version of eslint that should have this fix (4.4.1). I'm using mobx with mobx-react and trying to use the import React from 'react'
import {observer} from 'mobx-react'
export default @observer class Test extends React.Component {
render () {
return (
<div>hello</div>
)
}
} I get
This is my {
"parser": "babel-eslint",
"plugins": ["react"],
"extends": ["standard", "standard-jsx", "plugin:react/recommended"],
"rules": {
"comma-dangle": ["off", "always-multiline"],
},
"env": {
"browser": true,
},
} And this is my {
"presets": ["es2015", "stage-0", "react"],
"plugins": ["transform-decorators-legacy"]
} Any ideas? This actually seems to work fine, but the Here are the versions of all my eslint / babel plugins just in case that's useful."babel-plugin-react-transform": "2.0.2", "babel-plugin-transform-decorators-legacy": "1.3.4", "babel-preset-react-hmre": "1.1.1", "babel-register": "^6.24.1", "eslint": "^4.4.1", "eslint-config-standard": "10.2.1", "eslint-config-standard-jsx": "4.0.2", "eslint-plugin-babel": "^4.1.2", "eslint-plugin-import": "^2.7.0", "eslint-plugin-node": "^5.1.1", "eslint-plugin-promise": "3.5.0", "eslint-plugin-standard": "3.0.1", "babel-cli": "^6.24.1", "babel-core": "^6.25.0", "babel-loader": "7.1.1", "babel-plugin-transform-decorators": "^6.24.1", "babel-polyfill": "^6.23.0", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", |
So if anyone else runs into the above: I had |
Ran into this issue using version
upgraded to
Ran a "scorched earth install" and it did the trick. |
patch escope to visit decorators - fixes babel/babel-eslint#72
Have the following code:
which results into:
The text was updated successfully, but these errors were encountered: