ESLint & Prettier configurations for quick starting different type of JavaScript projects.
📙 Note: All these configurations are based on the Airbnb JavaScript Style Guide.
All the configuration files include Prettier in their "extends" key, this will disable all ESLint formatting rules that interfere with Prettier and leave the formatting responsibility only to Prettier.
We make use of the .prettierrc.json file to enforce the default configuration of Prettier (among any other rules defined inside it), preventing any possible non-desired configuration variations inside the Visual Studio Code extension among developers.
For more information about Prettier, follow this link to the official site.
For more information about configuring ESLint, follow this link to the official site.
⬆️ Back to top
- Copy and paste the corresponding
.eslintrc.jsonfile inside your project's root directory. - Copy and paste the
.prettierrc.jsonfile in your project's root directory. - Install the required dependencies specified for your type of project on each section.
💡 TIP: You can add the following scripts to your
package.jsonto run ESLint and Prettier from your terminal.
-
Run ESLint on all
.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts, and.mtsfiles in the whole project (run this command from the project's root directory)."scripts": { "lint": "npx eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\" --report-unused-disable-directives --max-warnings 0", "lint:fix": "npx eslint \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}\" --report-unused-disable-directives --max-warnings 0 --fix" }
-
Run Prettier on all supported files in the whole project (run this command from the project's root directory).
"scripts": { "prettier": "npx prettier . --check", "prettier:write": "npx prettier . --write" }
It is highly recommended to install the official ESLint extension and Prettier extension for Visual Studio Code to have real-time automatic linting and formatting.
❗️ WARNING: If you are not using ECMAScript modules (you don't have
"type": "module"in yourpackage.json), you'll need to remove"sourceType": "module"from.eslintrc.json
⬆️ Back to top
You can use this config if you just want to use JavaScript without any specific framework.
Make sure to install all the required dependencies:
npm install eslint eslint-config-airbnb-base eslint-config-prettier -Dnpm install prettier -D -E⬆️ Back to top
You can use this config if you want to use React.
Make sure to install all the required dependencies:
npm install eslint eslint-config-airbnb eslint-config-prettier -Dnpm install prettier -D -E⬆️ Back to top
⬆️ Back to top
- More project-specific configurations may be added in the future.
⬆️ Back to top


