eslint-config-haku

1.0.21 • Public • Published

🍃 Haku's Eslint Config

🦴 Setup Project

Installation

  • Install eslint-config-haku

    npm i --save-dev eslint-config-haku
    yarn add -D eslint-config-haku
    pnpm add -D eslint-config-haku
  • Extend the config in .eslintrc.js

    // Extend the config matching your project
    extends: ["haku/react"],
    parserOptions: {
        // Warn: the location may differ in different project structure
        project: "./tsconfig.json",
    },

VSCode

  • setup to auto fix lint problems on save
    # .vscode/config.json
    {
      "editor.codeActionsOnSave": { "source.fixAll": true },
      "editor.formatOnSave": false
    }

🥑 Recipes

Linting with Type Information

Redux

  • Refer to https://redux.js.org/usage/usage-with-typescript#define-typed-hooks
  • Add rule to restrict using custom useAppSelector and useAppDispatch for typing
    "@typescript-eslint/no-restricted-imports": [
      "warn",
      {
        name: "react-redux",
        importNames: ["useSelector", "useDispatch"],
        message: "Use typed hooks `useAppDispatch` and `useAppSelector` instead.",
      },
    ],

🍳 Trouble Shooting

Can't resolve paths alias in monorepo projects

Package Sidebar

Install

npm i eslint-config-haku

Weekly Downloads

7

Version

1.0.21

License

ISC

Unpacked Size

3.65 kB

Total Files

6

Last publish

Collaborators

  • hakudevtw