diff --git a/docs/rules/no-unused-vars.md b/docs/rules/no-unused-vars.md
index f6a8e3b..fde4c37 100644
--- a/docs/rules/no-unused-vars.md
+++ b/docs/rules/no-unused-vars.md
@@ -11,14 +11,14 @@ Ignore some unused variables when using the [`x-model`](https://github.com/peakc
```jsx harmony
function Foo() {
const [data, setData] = useState(0)
- return
+ return
}
```
```jsx harmony
function Foo() {
const [data, setData] = React.useState(0)
- return
+ return
}
```
@@ -34,7 +34,7 @@ function Foo() {
```jsx harmony
function Foo() {
const [data, setData] = Foo.useState(0)
- return
+ return
}
```
diff --git a/lib/rules/no-unused-vars.js b/lib/rules/no-unused-vars.js
index 0d06a5b..13b1c7a 100644
--- a/lib/rules/no-unused-vars.js
+++ b/lib/rules/no-unused-vars.js
@@ -32,7 +32,7 @@ module.exports = {
return parent
&& parent.type === 'JSXExpressionContainer'
&& parent.parent.type === 'JSXAttribute'
- && parent.parent.name.name === `${prefix}-model`;
+ && parent.parent.name.name === `${prefix}-model-hook`;
});
if (valid) {
diff --git a/package.json b/package.json
index 8faf1db..560cac4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-directives",
- "version": "0.0.2",
+ "version": "1.0.0",
"description": "some rules for babel-plugin-react-directives.",
"keywords": [
"eslint",
diff --git a/tests/lib/rules/no-unused-vars.js b/tests/lib/rules/no-unused-vars.js
index 48148d9..8b506e6 100644
--- a/tests/lib/rules/no-unused-vars.js
+++ b/tests/lib/rules/no-unused-vars.js
@@ -12,7 +12,7 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = useState(0);
- return
+ return
}
`
},
@@ -20,7 +20,7 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = React.useState(0);
- return
+ return
}
`
},
@@ -28,7 +28,7 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = React['useState'](0);
- return
+ return
}
`
},
@@ -36,7 +36,7 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = useState(0);
- return
+ return
}
`
},
@@ -47,7 +47,7 @@ new RuleTester({
0: data,
1: setState
} = useState(0);
- return
+ return
}
`
},
@@ -55,7 +55,7 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = useState(0);
- return
+ return
}
`,
settings: {
@@ -68,7 +68,7 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = Preact.useState(0);
- return
+ return
}
`,
settings: {
@@ -81,7 +81,7 @@ new RuleTester({
code: `
export default () => {
const data = useState(0);
- return
+ return
}
`
}
@@ -100,7 +100,18 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = Foo.useState(0);
- return
+ return
+ }
+ `,
+ errors: [
+ { message: /assigned a value but never used/ }
+ ]
+ },
+ {
+ code: `
+ export default () => {
+ const [data, setData] = useState(0);
+ return
}
`,
errors: [