eslint-plugin-react-hook-form
Advanced tools
Comparing version
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.2.3](https://github.com/andykao1213/eslint-plugin-react-hook-form/compare/v0.2.2...v0.2.3) (2022-02-28) | ||
### Bug Fixes | ||
* handle different cases of the id of VariableDeclarator ([#15](https://github.com/andykao1213/eslint-plugin-react-hook-form/issues/15)) ([d04638b](https://github.com/andykao1213/eslint-plugin-react-hook-form/commit/d04638bee6263af7b494f488a15a75036f75ce92)), closes [#13](https://github.com/andykao1213/eslint-plugin-react-hook-form/issues/13) [#14](https://github.com/andykao1213/eslint-plugin-react-hook-form/issues/14) [#13](https://github.com/andykao1213/eslint-plugin-react-hook-form/issues/13) [#14](https://github.com/andykao1213/eslint-plugin-react-hook-form/issues/14) | ||
### [0.2.2](https://github.com/andykao1213/eslint-plugin-react-hook-form/compare/v0.2.1...v0.2.2) (2022-01-16) | ||
@@ -7,0 +14,0 @@ |
@@ -7,2 +7,4 @@ /** | ||
const findPropertyByName = require("../utils/findPropertyByName"); | ||
//------------------------------------------------------------------------------ | ||
@@ -46,8 +48,7 @@ // Rule Definition | ||
if ( | ||
node.type === "VariableDeclarator" && | ||
node.init?.type === "CallExpression" && | ||
node.init?.callee.name === "useForm" | ||
) { | ||
const formStateProperty = node.id.properties.find( | ||
(p) => p.key.name === "formState" | ||
); | ||
const formStateProperty = findPropertyByName(node, "formState"); | ||
// Only looking for {formState} or {formState: alias} | ||
@@ -54,0 +55,0 @@ if (formStateProperty?.value.type !== "Identifier") return; |
@@ -7,2 +7,4 @@ /** | ||
const findPropertyByName = require("../utils/findPropertyByName"); | ||
//------------------------------------------------------------------------------ | ||
@@ -33,8 +35,7 @@ // Rule Definition | ||
if ( | ||
node.type === "VariableDeclarator" && | ||
node.init?.type === "CallExpression" && | ||
node.init?.callee.name === "useForm" | ||
) { | ||
const controlProperty = node.id.properties.find( | ||
(p) => p.key.name === "control" | ||
); | ||
const controlProperty = findPropertyByName(node, "control"); | ||
// Only looking for {control} or {control: alias} | ||
@@ -41,0 +42,0 @@ if (controlProperty?.value.type !== "Identifier") return; |
@@ -7,2 +7,4 @@ /** | ||
const findPropertyByName = require("../utils/findPropertyByName"); | ||
//------------------------------------------------------------------------------ | ||
@@ -46,8 +48,7 @@ // Rule Definition | ||
if ( | ||
node.type === "VariableDeclarator" && | ||
node.init?.type === "CallExpression" && | ||
node.init?.callee.name === "useForm" | ||
) { | ||
const setValueProperty = node.id.properties.find( | ||
(p) => p.key.name === "setValue" | ||
); | ||
const setValueProperty = findPropertyByName(node, "setValue"); | ||
// Only looking for {setValue} or {setValue: alias} | ||
@@ -54,0 +55,0 @@ if (setValueProperty?.value.type !== "Identifier") return; |
{ | ||
"name": "eslint-plugin-react-hook-form", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "ESLint plugin for react-hook-form", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -19,3 +19,3 @@ /** | ||
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } }); | ||
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 9 } }); | ||
ruleTester.run("destructuring-formstate", rule, { | ||
@@ -50,2 +50,16 @@ valid: [ | ||
}, | ||
{ | ||
code: normalizeIndent` | ||
function Component() { | ||
const formMethods = useForm(); | ||
} | ||
`, | ||
}, | ||
{ | ||
code: normalizeIndent` | ||
function Component() { | ||
const {watch, ...restFormMethods} = useFormState(); | ||
} | ||
`, | ||
}, | ||
], | ||
@@ -52,0 +66,0 @@ |
@@ -21,3 +21,3 @@ /** | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
ecmaVersion: 9, | ||
ecmaFeatures: { | ||
@@ -46,2 +46,16 @@ jsx: true, | ||
}, | ||
{ | ||
code: normalizeIndent` | ||
function Component() { | ||
const formMethods = useForm(); | ||
} | ||
`, | ||
}, | ||
{ | ||
code: normalizeIndent` | ||
function Component() { | ||
const {watch, ...restFormMethods} = useFormState(); | ||
} | ||
`, | ||
}, | ||
], | ||
@@ -48,0 +62,0 @@ invalid: [ |
@@ -21,3 +21,3 @@ /** | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
ecmaVersion: 9, | ||
ecmaFeatures: { | ||
@@ -42,2 +42,16 @@ jsx: true, | ||
}, | ||
{ | ||
code: normalizeIndent` | ||
function Component() { | ||
const formMethods = useForm(); | ||
} | ||
`, | ||
}, | ||
{ | ||
code: normalizeIndent` | ||
function Component() { | ||
const {watch, ...restFormMethods} = useFormState(); | ||
} | ||
`, | ||
}, | ||
], | ||
@@ -44,0 +58,0 @@ |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
36512
5.72%22
4.76%653
7.76%2
100%