tangway / flag-guessing-game-frontend

0 stars 0 forks source link

add 'plugin:react-hooks/recommended' for eslint #35

Open tangway opened 4 months ago

tangway commented 4 months ago

saw from a video where linting for react-hooks was used and looked it up react documentation has recommended linting: https://react.dev/learn/editor-setup#linting

this is what i did: pnpm install eslint-plugin-react-hooks --save-dev

//.eslintrc.cjs file
module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  // only these 2 lines need to be changed
  extends: ['airbnb', 'plugin:react-hooks/recommended'],
  plugins: ['react-hooks'],
}

// the above 'plugin:react-hooks/recommended' setting essentially adds these 2 lines so you dont have to manually add them in the rules section
 "react-hooks/rules-of-hooks": "error",
 "react-hooks/exhaustive-deps": "warn"