Skip to content

Commit f842c7e

Browse files
committed
test(no-use-context): add test case for 'useContext' with generic type parameters
1 parent 3cd6465 commit f842c7e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-use-context.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,33 @@ ruleTester.run(RULE_NAME, rule, {
3030
},
3131
},
3232
},
33+
{
34+
code: /* tsx */ `
35+
import { useContext } from 'react'
36+
37+
export const Component = () => {
38+
const value = useContext<MyContext>(MyContext)
39+
return <div>{value}</div>
40+
}
41+
`,
42+
errors: [
43+
{ messageId: "noUseContext" },
44+
{ messageId: "noUseContext" },
45+
],
46+
output: /* tsx */ `
47+
import { use } from 'react'
48+
49+
export const Component = () => {
50+
const value = use<MyContext>(MyContext)
51+
return <div>{value}</div>
52+
}
53+
`,
54+
settings: {
55+
"react-x": {
56+
version: "19.0.0",
57+
},
58+
},
59+
},
3360
{
3461
code: /* tsx */ `
3562
import { use, useContext } from 'react'

0 commit comments

Comments
 (0)