Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upFat arrow method definitions #935
Comments
This comment has been minimized.
This comment has been minimized.
eddiemonge
commented
Jun 28, 2017
|
That plugin also enables
which Standard is complaining about |
This comment has been minimized.
This comment has been minimized.
Talor-A
commented
Jun 28, 2017
•
|
another example that I believe is related, standard doesn't like it when writing your react state this way:
this is convenient because it's much more readable than the alternative:
|
This comment has been minimized.
This comment has been minimized.
|
Is it a matter of setting up https://standardjs.com/#how-do-i-use-experimental-javascript-es-next-features ? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
eddiemonge
commented
Jun 28, 2017
|
If I use |
This comment has been minimized.
This comment has been minimized.
|
That's just a normal rule. Second bullet point here |
This comment has been minimized.
This comment has been minimized.
eddiemonge
commented
Jun 28, 2017
|
Except its not. If I don't use |
This comment has been minimized.
This comment has been minimized.
|
It might not have been linting your jsx properly if you weren't using the babel-eslint parser with the react preset.
|
This comment has been minimized.
This comment has been minimized.
|
I think if you are not using |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The other issue is that class properties assigned to arrow functions is still in babel land iirc: http://babeljs.io/docs/plugins/transform-class-properties/ If you are using babel transforms to access future JS features, you are definately going to want to turn on the babel parser. |
This comment has been minimized.
This comment has been minimized.
|
Yeah class properties are still in the ES Next zone: http://kangax.github.io/compat-table/esnext/#test-class_fields_class_properties If you are using these features, you must have the |
This comment has been minimized.
This comment has been minimized.
|
If $ standard --version
$ npm ls standard
$ npm ls babel-eslint |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
I think I figured it out. I was attempting to convert my project from using my own set of eslint rules to standard. Incidentally, I had After noticing the unmet peer dependency that standard has on
and now everything is working as expected. @feross I'll let you close this issue if you think it's resolved or wait on the others to see if what I did works for them as well. |
This comment has been minimized.
This comment has been minimized.
joke2k
commented
Nov 30, 2017
•
|
Hi @dadamssg, your solution doesn't work for me.
returns: error 'work' is not defined
|
This comment has been minimized.
This comment has been minimized.
|
@joke2k I can only guess that it's because you have eslint 4.10.0 installed alongside eslint 3.19.0 because of the requirement from react-scripts. I bet if you removed react-scripts, and thus eslint 4.10.0, and only had 3.19.0 it would work. |
This comment has been minimized.
This comment has been minimized.
joke2k
commented
Nov 30, 2017
•
|
Yeah! @dadamssg you were right! |
This comment has been minimized.
This comment has been minimized.
|
@joke2k haha sorry to hear that! Unfortunately, I don't have any experience with create-react-app/react-scripts so I can't help you there :/ |
This comment has been minimized.
This comment has been minimized.
joke2k
commented
Dec 2, 2017
|
It seems that we have to wait standard 11 |
This comment has been minimized.
This comment has been minimized.
IlyasAbdighni
commented
Dec 12, 2017
|
Did someone find any solution? |
This comment has been minimized.
This comment has been minimized.
GBarkhatov
commented
Jan 3, 2018
|
Any solutions? |
This comment has been minimized.
This comment has been minimized.
|
Have you tried with |
This comment has been minimized.
This comment has been minimized.
GBarkhatov
commented
Jan 3, 2018
|
Yep, not working |
This comment has been minimized.
This comment has been minimized.
Tommos0
commented
Jan 3, 2018
•
|
I'm having the same issue. Using
|
This comment has been minimized.
This comment has been minimized.
|
@Tommos0 does |
This comment has been minimized.
This comment has been minimized.
Dean177
commented
Jan 4, 2018
|
@Flet using the beta version of standard resolved the issues I was having with ‘babel -eslint’ |
This comment has been minimized.
This comment has been minimized.
KITSMattStyles
commented
Jan 9, 2018
|
Upgrading to beta helped me also. Despite |
This comment has been minimized.
This comment has been minimized.
franky47
commented
Jan 19, 2018
|
I also have this issue with the following setup:
Example code : // test.js
export default class Foo {
// Static class fields - https://github.com/tc39/proposal-static-class-features/
static propTypes = {}
// Class fields - https://github.com/tc39/proposal-class-fields
state = {
foo: 'foo'
}
// Fat arrow method
foo = () => this.state.foo
}Result: $ standard test.js
test.js:3:20: Parsing error: Unexpected token =
$ standard --parser babel-eslint test.js
test.js:3:10: 'propTypes' is not defined.
test.js:6:3: 'state' is not defined.
test.js:11:3: 'foo' is not defined. |
This comment has been minimized.
This comment has been minimized.
ip413
commented
Jan 25, 2018
|
Doesn't work with beta version 11.0.0-beta.0 Still have |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
franky47
commented
Jan 26, 2018
•
|
@bcomnes yep, tried that initially, no luck with either local or global Edit: alright I've got a combination working:
The confusing thing seems to come from |
This comment has been minimized.
This comment has been minimized.
|
iirc you also need to ensure the correct babel transforms, I forget if env ships class fields or not. |
This comment has been minimized.
This comment has been minimized.
azizhk
commented
Feb 5, 2018
|
babel-eslint's version is what is causing the issue, downgraded babel-eslint to ^7.0.0 and the error stopped appearing. |
This comment has been minimized.
This comment has been minimized.
jnreynoso
commented
Feb 9, 2018
|
Any solutions? |
This comment has been minimized.
This comment has been minimized.
azizhk
commented
Feb 9, 2018
|
@jnreynoso Are you using prettier-standard? |
This comment has been minimized.
This comment has been minimized.
fedorinoGore
commented
Feb 9, 2018
•
|
Any solutions? None of the listed works for me... |
This comment has been minimized.
This comment has been minimized.
jnreynoso
commented
Feb 9, 2018
|
@azizhk prettier-standard solved this problem? |
This comment has been minimized.
This comment has been minimized.
azizhk
commented
Feb 9, 2018
|
@fedorinoGore my setup is: @jnreynoso |
This comment has been minimized.
This comment has been minimized.
fedorinoGore
commented
Feb 10, 2018
|
@jnreynoso @azizhk I'm not using Prettier for now... But the problem persist. |
This comment has been minimized.
This comment has been minimized.
azizhk
commented
Feb 10, 2018
|
Run these three commands and write the results here. |
This comment has been minimized.
This comment has been minimized.
fedorinoGore
commented
Feb 12, 2018
•
I made several upgrades recently trying to escape from other issue with eslint and babel-styled-components plugin |
This comment has been minimized.
This comment has been minimized.
azizhk
commented
Feb 12, 2018
•
|
Ok so based on these issues: But it might also be of having mixed dependency versions of babel (babel/babel-eslint#585)
|
This comment has been minimized.
This comment has been minimized.
fedorinoGore
commented
Feb 12, 2018
This comment has been minimized.
This comment has been minimized.
Rachomir
commented
Feb 15, 2018
|
I am having same problems with fat arrow functions. :( |
This comment has been minimized.
This comment has been minimized.
will-hart
commented
Feb 15, 2018
|
I found a combination that works for me with a
At this stage
Hopefully that helps somebody else! |
This comment has been minimized.
This comment has been minimized.
tlvince
commented
Feb 21, 2018
|
This is fixed for me in v11.0.0 (and using |
This comment has been minimized.
This comment has been minimized.
Kikobeats
commented
Feb 21, 2018
|
Me too! |
This comment has been minimized.
This comment has been minimized.
|
Sorry for all the trouble with this issue. If you install the latest version of If you're not sure what version of standard you're using, run: npx standard --versionEnsure that you're on at least 11.0.0 and you'll be good to go! |
feross
closed this
Feb 22, 2018
This comment has been minimized.
This comment has been minimized.
jligeza
commented
Feb 28, 2018
|
I have version 11 and it still doesn't work. |
This comment has been minimized.
This comment has been minimized.
|
@jligeza Without any additional information, it's impossible to help you. Open a new issue and share a full bug report. |
This comment has been minimized.
This comment has been minimized.
jligeza
commented
Mar 3, 2018
|
Sorry, it works now. I just didn't use |



dadamssg commentedJun 26, 2017
•
edited
Is disallowing defining methods via fat arrows a rule or a bug? This is valid syntax with babel and I'm using babel-eslint but the rule is
no-undefwhich I believe is wrong.This is really helpful because it auto-binds
thisto the component instance. If you were to use the non fat arrow syntax, you would need to manually bindthisto that method.This is enabled by the transform-class-properties babel plugin which i have enabled in my .babelrc
{ "presets": [ "stage-0", ["es2015", {"modules": false}], "react" ], "plugins": [ "transform-class-properties" ] }