eslint-plugin-react-hooks feature request: enforce naming convention for useState()

2019-09-26 19:03:11

Do you want to request a feature or report a bug?

What is the current behavior?

There is currently no rule to enforce the standard naming convention for useState.

What is the expected behavior?

It would be great to have a rule to enforce the standard naming convention for useState():

const [x, setX] = useState(...)

For example, the rule would consider this an error:

const [x, setFoo] = useState(...)

This would ensure that all useState variables followed the same convention, i.e. ${varName} and set${upperFirstVarName}.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

All versions with hooks


I originally submitted a feature request for eslint-plugin-react: yannickcr/eslint-plugin-react#2417. It was suggested that I make the feature request here instead. I'm not sure which plugin would be the more appropriate place for this.

2020-01-09 20:48:26

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.

2020-01-16 20:59:20

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

2020-09-22 08:50:26

@mbrowne would you be open to creating a new issue for this? It would be nice for beginners to learn!

2020-09-22 11:44:48


2020-09-22 12:43:14

Thanks, will watch there!

当前位于第1页,总计5 条回复


Stateless function components cannot have refs.

After applying Route and Link I am facing this problem. Stateless function components cannot have refs. ▶ 22 stack frame
讨论数 2
创建时间:2019-09-26 16:15:38

A note on function components default parameters

When you define default parameters for a function component, the component will have brand new parameters on every rende
讨论数 8
创建时间:2019-09-26 14:51:44

More time between releasing @next and @latest

As a library author, I test against both the @next and @latest versions of react and react-dom (as well as 16.3, the old
讨论数 3
创建时间:2019-09-26 14:18:06

can ReactDOM.render render to body without warning

Do you want to request a feature or report a bug? feature What is the current behavior? I want render dom struct like wh
讨论数 5
创建时间:2019-09-26 06:44:57

Why does parent's componentDidMount gets called first, then child's?

I thought it was always the case, that first, child's componentDidMount would be called, and then, parent's. However, in
讨论数 8
创建时间:2019-09-26 06:36:13

State not updating in realtime

I am updating state in setState() and the page is rendered correctly, but "React Developer Tools" is showing previous st
讨论数 8
创建时间:2019-09-25 12:32:56

Problem with updating component state in the "Components" tab of React Developer Tools - Chrome extension

Hello everyone, I have a problem with Chrome extension - React Developer Tools, if I change component's state it's not c
讨论数 2
创建时间:2019-09-25 12:13:45

React dev tools doesn't appear in chrome (Ubuntu 18.04.3)

Do you want to request a feature or report a bug? Report a bug What is the current behavior? React dev tools don't appea
讨论数 4
创建时间:2019-09-25 10:40:39

Hook params inside functions are not updated (only for event listeners)

Do you want to request a feature or report a bug? Bug(possibly) What is the current behavior? Whenever a function is cal
讨论数 3
创建时间:2019-09-25 09:03:18

Error: Invalid operand to 'in': Object expected ==> IE10

Getting "Invalid operand to 'in': Object expected" error, in react application, I haven't used 'in' operator throughout
讨论数 5
创建时间:2019-09-25 08:40:21