Giter VIP home page Giter VIP logo

react-eslint-prettier-hustky-init's Introduction

packages

npm i -D eslint @typescript-eslint/parser eslint-config-prettier eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks lint-staged husky

npm i -D --save-exact prettier

npm i -D --legacy-peer-deps @typescript-eslint/eslint-plugin
Purposes:
- @typescript-eslint/parser: help eslint understand typescript
- eslint-config-prettier: prettier applied rules (put in extends)
- eslint-plugin-prettier: prettier rule sets (put in plugins)
- eslint-plugin-react: react apllied rules
- eslint-plugin-react-hooks: react hooks apllied rules

.prettierrc

{
  "printWidth": 80,
  "tabWidth": 2,
  "semi": true,
  "singleQuote": true,
  "jsxSingleQuote": true,
  "bracketSpacing": true,
  "bracketSameLine": false,
  "arrowParens": "always",
  "trailingComma": "all"
}

.eslintrc

{
  "root": true,
  "env": { "browser": true, "es2022": true },
  "settings": {
    "react": { "version": "detect" }
  },
  "ignorePatterns": ["dist", ".eslintrc", "*.test.tsx"],
  "parser": "@typescript-eslint/parser", // language parser
  "plugins": ["prettier"], // set of rules, but not applied yet
  "extends": [ // preset applied rules
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:react/recommended",
    "plugin:react/jsx-runtime",
    "plugin:react-hooks/recommended",
    "plugin:prettier/recommended"
  ],
  "parserOptions": { "sourceType": "module" },
  "rules": {
    "prettier/prettier": [1, { "endOfLine": "auto" }], // fix endline problem
    "react-hooks/rules-of-hooks": 2,
    "react-hooks/exhaustive-deps": 0,
    "react/jsx-no-useless-fragment": 1,
    "no-console": 1,
    "@typescript-eslint/no-unused-vars": 1,
    "@typescript-eslint/no-inferrable-types": 1,
    "@typescript-eslint/no-non-null-assertion": 0,
    "@typescript-eslint/no-explicit-any": 0
  },
  "overrides": [
    {
      "files": ["*.ts"],
      "rules": { "no-unused-vars": 0 } // ignore warning of unused variables in interface of typescript, @typescript-eslint/no-unused-vars already handle this
    }
  ]
}

package.json

  "lint": "eslint --ignore-path .eslintignore --max-warnings 0 \"./src/**/*.{js,jsx,ts,tsx}\"",
  "lint:fix": "eslint --ignore-path .eslintignore --fix \"./src/**/*.{js,jsx,ts,tsx}\"",
  "format": "prettier --ignore-path .gitignore --write \"./src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
  "prepare": "husky install"

.lintstagedrc

{
  "*.{js,jsx,ts,tsx}": ["prettier -w", "eslint --max-warnings 0"],
  "*.{css,json,md}": ["prettier -w"]
}

husky

npx husky-init
npm i
npx husky set .husky/pre-commit "npx lint-staged"

react-eslint-prettier-hustky-init's People

Contributors

trinhtuan2801 avatar

Stargazers

 avatar

Watchers

 avatar

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.