Skip to content

Instantly share code, notes, and snippets.

@vvahyudi
Forked from Bagusth15/.eslintrc
Created February 5, 2023 06:04
Show Gist options
  • Save vvahyudi/d01bd2b388d299b19517e6258c2305c6 to your computer and use it in GitHub Desktop.
Save vvahyudi/d01bd2b388d299b19517e6258c2305c6 to your computer and use it in GitHub Desktop.
Formatting Eslint Prettier React 🌼
module.exports = {
env: {
browser: true,
es2021: true
},
extends: ["eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended"],
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: "latest",
sourceType: "module"
},
plugins: ["react"],
rules: {
"react/react-in-jsx-scope": "off",
"prettier/prettier": [
"error",
{
endOfLine: "auto"
}
]
}
};
{
"semi": true,
"trailingComma": "none",
"doubleQuotes": true,
"printWidth": 100,
"tabWidth": 2,
"bracketSpacing": true,
"arrowParens": "always",
"jsxBracketSameLine": false
}

Step by Step Configuration Eslint and Prettier in React JS 🎈

  1. npx eslint --init
  • a. How would you like to use ESLint? To check syntax and find problems
  • b. What type of modules does your project use? Javascript modules (import/export)
  • c. Which framework does your project use? React
  • d. Does your project use TypeScript? No
  • e. Where does your code run? browser
  • f. What format do you want your config file to be in? Javascript
  • g. Would you like to install them now with npm? yes
  1. copy syntax to .eslintrc
  2. install devDependencies npm install eslint-config-prettier eslint-plugin-prettier prettier --save-dev
  3. create file .prettierrc and copy syntax to .prettierrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment