Skip to content

Commit b765350

Browse files
authored
feat: upgrade eslint-plugin-react-hooks to v7 (#764)
1 parent 7971e95 commit b765350

File tree

15 files changed

+350
-143
lines changed

15 files changed

+350
-143
lines changed

fixtures/input/jsx.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
import React from 'react';
12
export function HelloWorld({
23
greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {
34

5+
const [num] = React.useState(()=> Math
6+
.floor (Math.random() * 1E+7).toString()
7+
.replace(/\.\d+/ig, ""))
8+
49
if(!greeting){
510
return null};
611

7-
// TODO: Don't use random in render
8-
let num = Math
9-
.floor (Math.random() * 1E+7).toString()
10-
.replace(/\.\d+/ig, "")
11-
1212
return <div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}>
1313
<strong>{ greeting.slice( 0, 1 ).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
14-
{greeting.endsWith(",")
14+
{greeting.endsWith(",")
1515
? " " : <span style={{color: '\grey'}}>", "</span> }
1616
<em>
1717
{ greeted }

fixtures/output/all/jsx.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import React from 'react'
2+
13
export function HelloWorld({
24
greeting = 'hello',
35
greeted = '"World"',
46
silent = false,
57
onMouseOver,
68
}) {
9+
const [num] = React.useState(() => Math
10+
.floor (Math.random() * 1e+7)
11+
.toString()
12+
.replace(/\.\d+/g, ''))
13+
714
if (!greeting) {
815
return null
916
};
1017

11-
// TODO: Don't use random in render
12-
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
16-
1718
return (
1819
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
1920
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

fixtures/output/js/jsx.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import React from 'react'
2+
13
export function HelloWorld({
24
greeting = 'hello',
35
greeted = '"World"',
46
silent = false,
57
onMouseOver,
68
}) {
9+
const [num] = React.useState(() => Math
10+
.floor (Math.random() * 1e+7)
11+
.toString()
12+
.replace(/\.\d+/g, ''))
13+
714
if (!greeting) {
815
return null
916
};
1017

11-
// TODO: Don't use random in render
12-
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
16-
1718
return (
1819
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
1920
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

fixtures/output/no-style/jsx.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
import React from 'react';
12
export function HelloWorld({
23
greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {
34

5+
const [num] = React.useState(()=> Math
6+
.floor (Math.random() * 1e+7).toString()
7+
.replace(/\.\d+/g, ""))
8+
49
if(!greeting){
510
return null};
611

7-
// TODO: Don't use random in render
8-
const num = Math
9-
.floor (Math.random() * 1e+7).toString()
10-
.replace(/\.\d+/g, "")
11-
1212
return <div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}>
1313
<strong>{ greeting.slice( 0, 1 ).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
14-
{greeting.endsWith(",")
14+
{greeting.endsWith(",")
1515
? " " : <span style={{color: '\grey'}}>", "</span> }
1616
<em>
1717
{ greeted }

fixtures/output/tab-double-quotes/jsx.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import React from "react"
2+
13
export function HelloWorld({
24
greeting = "hello",
35
greeted = "\"World\"",
46
silent = false,
57
onMouseOver,
68
}) {
9+
const [num] = React.useState(() => Math
10+
.floor (Math.random() * 1e+7)
11+
.toString()
12+
.replace(/\.\d+/g, ""))
13+
714
if (!greeting) {
815
return null
916
};
1017

11-
// TODO: Don't use random in render
12-
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, "")
16-
1718
return (
1819
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
1920
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

fixtures/output/ts-override/jsx.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import React from 'react'
2+
13
export function HelloWorld({
24
greeting = 'hello',
35
greeted = '"World"',
46
silent = false,
57
onMouseOver,
68
}) {
9+
const [num] = React.useState(() => Math
10+
.floor (Math.random() * 1e+7)
11+
.toString()
12+
.replace(/\.\d+/g, ''))
13+
714
if (!greeting) {
815
return null
916
};
1017

11-
// TODO: Don't use random in render
12-
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
16-
1718
return (
1819
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
1920
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

fixtures/output/ts-strict-with-react/jsx.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import React from 'react'
2+
13
export function HelloWorld({
24
greeting = 'hello',
35
greeted = '"World"',
46
silent = false,
57
onMouseOver,
68
}) {
9+
const [num] = React.useState(() => Math
10+
.floor (Math.random() * 1e+7)
11+
.toString()
12+
.replace(/\.\d+/g, ''))
13+
714
if (!greeting) {
815
return null
916
};
1017

11-
// TODO: Don't use random in render
12-
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
16-
1718
return (
1819
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
1920
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

fixtures/output/ts-strict/jsx.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import React from 'react'
2+
13
export function HelloWorld({
24
greeting = 'hello',
35
greeted = '"World"',
46
silent = false,
57
onMouseOver,
68
}) {
9+
const [num] = React.useState(() => Math
10+
.floor (Math.random() * 1e+7)
11+
.toString()
12+
.replace(/\.\d+/g, ''))
13+
714
if (!greeting) {
815
return null
916
};
1017

11-
// TODO: Don't use random in render
12-
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
16-
1718
return (
1819
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
1920
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

fixtures/output/with-formatters/jsx.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import React from 'react'
2+
13
export function HelloWorld({
24
greeting = 'hello',
35
greeted = '"World"',
46
silent = false,
57
onMouseOver,
68
}) {
9+
const [num] = React.useState(() => Math
10+
.floor (Math.random() * 1e+7)
11+
.toString()
12+
.replace(/\.\d+/g, ''))
13+
714
if (!greeting) {
815
return null
916
};
1017

11-
// TODO: Don't use random in render
12-
const num = Math
13-
.floor (Math.random() * 1e+7)
14-
.toString()
15-
.replace(/\.\d+/g, '')
16-
1718
return (
1819
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
1920
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"eslint-plugin-astro": "^1.2.0",
5353
"eslint-plugin-format": ">=0.1.0",
5454
"eslint-plugin-jsx-a11y": ">=6.10.2",
55-
"eslint-plugin-react-hooks": "^5.2.0",
55+
"eslint-plugin-react-hooks": "^7.0.0",
5656
"eslint-plugin-react-refresh": "^0.4.19",
5757
"eslint-plugin-solid": "^0.14.3",
5858
"eslint-plugin-svelte": ">=2.35.1",

0 commit comments

Comments
 (0)