Giter Site home page Giter Site logo

eslint-plugin-react-hook-form's Introduction

Andrew's GitHub stats

eslint-plugin-react-hook-form's People

Contributors

andykao1213 avatar david-crespo avatar gettobiasnielsen avatar goatwu1993 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eslint-plugin-react-hook-form's Issues

The plugin crashes unexpectedly when not destructuring the result of calling useForm

Describe the bug
The plugin crashes unexpectedly when not destructuring the result of calling useForm.

To Reproduce

  1. The code you are going to lint.
const { useForm } = require('react-hook-form')
export function Component() {
  const formMethods = useForm()
  return null
}
  1. Your ESlint config
{
  ...
  'react-hook-form/no-nested-object-setvalue': ['error', { bracketAsArrayIndex: true }],
}

Expected behavior
I expect the React Hook Form Eslint plugin to not crash.

Actual behavior
The React Hook Form ESLing plugin crashes with the following error message:

TypeError: Cannot read property 'find' of undefined
Occurred while linting my-project/components/TestComponent.jsx:3
    at check (my-project/node_modules/eslint-plugin-react-hook-form/lib/rules/no-nested-object-setvalue.js:48:53)
    at my-project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (my-project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (my-project/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (my-project/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (my-project/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (my-project/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at my-project/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Enviornment (please complete the following information):

  • Eslint version: 7.12.1
  • Node version: v14.18.3
  • React-Hook-Form version: 6.15.8
  • eslint-plugin-react-hook-form version: 0.2.2

Additional context
n/a

TypeError: Cannot read property 'type' of null when using `for...of`

Describe the bug
ESLint exits with fatal error.

To Reproduce

  1. The code you are going to lint.
for (const element of array) {
  bar(element);
}
  1. Your ESlint config
{
  "parserOptions": {
    "ecmaVersion": "latest"
  },

  "plugins": ["react-hook-form"],

  "rules": {
    "react-hook-form/destructuring-formstate": "error"
  }
}

Expected behavior
No fatal error.

Actual behavior

Oops! Something went wrong! :(

ESLint: 8.6.0

TypeError: Cannot read property 'type' of null
Occurred while linting /example/example.js:1
Rule: "react-hook-form/destructuring-formstate"
    at check (/example/node_modules/eslint-plugin-react-hook-form/lib/rules/destructuring-formstate.js:45:19)
    at ruleErrorHandler (/example/node_modules/eslint/lib/linter/linter.js:1079:28)
    at /example/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/example/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/example/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/example/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/example/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (/example/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:795:23)
    at /example/node_modules/eslint/lib/linter/linter.js:1110:32

Enviornment (please complete the following information):

  • Eslint version: 8.6.0
  • Node version: 14.18.2
  • React-Hook-Form version: 0.2.1

Additional context

The plugin crashes unexpectedly when using `...rest` syntax in the destructuring of the result of calling useForm

Describe the bug
The plugin crashes unexpectedly when using ...rest syntax in the destructuring of the result of calling useForm.

To Reproduce

  1. The code you are going to lint.
const { useForm } = require('react-hook-form')
export function Component() {
  const { watch, ...restFormMethods } = useForm()
  return null
}
  1. Your ESlint config
{
  ...
  'react-hook-form/no-nested-object-setvalue': ['error', { bracketAsArrayIndex: true }],
}

Expected behavior
I expect the React Hook Form Eslint plugin to not crash.

Actual behavior
The React Hook Form ESLing plugin crashes with the following error message:

TypeError: Cannot read property 'name' of undefined
Occurred while linting my-project/components/TestComponent.jsx:3
    at my-project/node_modules/eslint-plugin-react-hook-form/lib/rules/no-nested-object-setvalue.js:49:24
    at Array.find (<anonymous>)
    at check (my-project/node_modules/eslint-plugin-react-hook-form/lib/rules/no-nested-object-setvalue.js:48:53)
    at my-project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (my-project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (my-project/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (my-project/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (my-project/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (my-project/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)

Enviornment (please complete the following information):

  • Eslint version: 7.12.1
  • Node version: v14.18.3
  • React-Hook-Form version: 6.15.8
  • eslint-plugin-react-hook-form version: 0.2.2

Additional context
n/a

`no-nested-object-setvalue` throws when passing a function call

Describe the bug
react-hook-form/no-nested-object-setvalue is thrown with message Avoid passing object or array as second argument in setValue since this is less performant, when using the following syntax:

setValue("someName", myFunctionReturningANumber())

To Reproduce

  1. The code you are going to lint.
function Component() {
  const {useValue} = useForm();

  const myFunctionReturningANumber = () => 5

  setValue("someName", myFunctionReturningANumber())

  return null;
}
  1. Your ESlint config
{
  ...
  'react-hook-form/no-nested-object-setvalue': ['error', { bracketAsArrayIndex: true }],
}

Expected behavior
Expect react-hook-form/no-nested-object-setvalue not to throw an error.

Actual behavior
react-hook-form/no-nested-object-setvalue throws with message Avoid passing object or array as second argument in setValue since this is less performant

Enviornment (please complete the following information):

  • Eslint version: 7.12.1
  • Node version: v14.18.3
  • React-Hook-Form version: 6.15.8
  • eslint-plugin-react-hook-form version: 0.2.3

Additional context
n/a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.