Skip to content

Instantly share code, notes, and snippets.

@madhums
Last active March 23, 2023 12:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save madhums/cdd89751cfa15ef1cb051910420ce665 to your computer and use it in GitHub Desktop.
eslint prettier config
{
"presets": ["next/babel"],
"plugins": []
}
node_modules
styleguide
.next
.vscode
module.exports = {
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "@babel/eslint-parser",
"rules": {
"prettier/prettier": ["error", {
"singleQuote": true,
"jsxBracketSameLine": true
}],
"max-len": ["error", {
"code": 80,
"ignoreUrls": true,
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}],
"quotes": ["error", "single"],
"camelcase": "off",
"no-console": "off"
}
}
npm i eslint prettier eslint-config-prettier eslint-plugin-prettier @babel/core @babel/eslint-parser -D
  1. If you want to add react

    npm i eslint-plugin-react -D
    "extends": [
        "eslint:recommended", 
    +    "plugin:react/recommended", 
        "plugin:prettier/recommended"
      ],
  2. If you want to add pre-commit hook to fix code style

    npm i husky lint-staged -D

    In package.json

    {
      "husky": {
        "hooks": {
          "pre-commit": "lint-staged"
        }
      },
      "lint-staged": {
        "*.js": [
          "eslint --fix"
        ]
      },
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment