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

[prefer-stateless-function] should check if component has ES7 decorator #501

Closed
dmt0 opened this issue Mar 15, 2016 · 7 comments
Closed

Comments

@dmt0
Copy link

dmt0 commented Mar 15, 2016

ES7 decorators only work with classes and not with functions. If a decorator is present [react/prefer-stateless-function] should not be recommended.

@ljharb
Copy link
Member

ljharb commented Mar 15, 2016

Decorators are not ES7, and part of the proposal absolutely might be that they work with function declarations. They also certainly work with concise object methods as well.

@Kerumen
Copy link
Contributor

Kerumen commented Mar 16, 2016

Related #491 (comment)

@thewillhuang
Copy link

thewillhuang commented Jul 23, 2016

@ljharb thats great and all, but the current proposal is with classes, and until that has been agreed upon and or implemented this is still a false positive and a bug. see https://github.com/wycats/javascript-decorators, first line in the summery for decorators.

Decorators make it possible to annotate and modify classes and properties at design time.

@ljharb
Copy link
Member

ljharb commented Jul 23, 2016

@thewillhuang "and properties". https://github.com/wycats/javascript-decorators#object-literal-method-declaration - it is NOT a bug, it is an essential part of the proposal.

@thewillhuang
Copy link

thewillhuang commented Jul 26, 2016

@ljharb ah i see, missed that part completely

@ljharb
Copy link
Member

ljharb commented Feb 2, 2022

Decorators remain stage 2, and have changed 3-4 times since this was filed.

However, we do support them via the TS eslint parser.

Additionally, the likely state of the proposal will exclude functions, so we should use the presence of a class decorator as an indication that the component should not be a stateless function.

@golopot
Copy link
Contributor

golopot commented Jun 4, 2022

fixed in #1086

@ljharb ljharb closed this as completed Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants