Socket
Book a DemoInstallSign in
Socket

eslint-plugin-react-hook-form

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react-hook-form - npm Package Compare versions

Comparing version

to
0.2.3

lib/utils/findPropertyByName.js

@@ -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

lib/rules/destructuring-formstate.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.