Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peakchen90 committed Oct 19, 2019
1 parent e317624 commit d426635
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/rules/no-unused-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <input x-model={data}/>
return <input x-model-hook={data}/>
}
```

```jsx harmony
function Foo() {
const [data, setData] = React.useState(0)
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
```

Expand All @@ -34,7 +34,7 @@ function Foo() {
```jsx harmony
function Foo() {
const [data, setData] = Foo.useState(0)
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
```

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
29 changes: 20 additions & 9 deletions tests/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = useState(0);
return <input x-model={data.foo}/>
return <input x-model-hook={data.foo}/>
}
`
},
{
code: `
export default () => {
const [data, setData] = React.useState(0);
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
`
},
{
code: `
export default () => {
const [data, setData] = React['useState'](0);
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
`
},
{
code: `
export default () => {
const [data, setData] = useState(0);
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
`
},
Expand All @@ -47,15 +47,15 @@ new RuleTester({
0: data,
1: setState
} = useState(0);
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
`
},
{
code: `
export default () => {
const [data, setData] = useState(0);
return <input v-model={data}/>
return <input v-model-hook={data}/>
}
`,
settings: {
Expand All @@ -68,7 +68,7 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = Preact.useState(0);
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
`,
settings: {
Expand All @@ -81,7 +81,7 @@ new RuleTester({
code: `
export default () => {
const data = useState(0);
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
`
}
Expand All @@ -100,7 +100,18 @@ new RuleTester({
code: `
export default () => {
const [data, setData] = Foo.useState(0);
return <input x-model={data}/>
return <input x-model-hook={data}/>
}
`,
errors: [
{ message: /assigned a value but never used/ }
]
},
{
code: `
export default () => {
const [data, setData] = useState(0);
return <input x-abc={data}/>
}
`,
errors: [
Expand Down

0 comments on commit d426635

Please sign in to comment.