Apparently the official creator was no longer active in the community, so I decided to make this modified version. If you are interested in suggesting, contributing or implementing something, feel free to do a PR. (Credits at the end)
If you have mastered any language and want to help translating the readme or correcting the translations already done, click on this issue and/or do a PR.
-
Navigate to your app directory where you want to include this style configuration.
cd my-app
-
Run this command inside your app's root directory. (Note: this command executes the
automatic-config.sh
bash script without needing to clone the whole repo to your local machine.)exec 3<&1;bash <&3 <(curl https://raw.githubusercontent.com/otaldonunes/eslint-stylelint-prettier-airbnb-editorconfig-react/main/automatic-config.sh 2> /dev/null)
-
Make selections for your preference of package manager (Npm, Yarn or Yarn Workspaces), file format (.js or .json), max-line size, and trailing commas (none, es5, all).
-
Look in your project's root directory and notice the four newly added/updated config files:
.eslintrc.js
(or.eslintrc.json
) (Install theESLint
extension, it can be easily added by pressing (Ctrl + P) in VS Code, pasting the following command (ext install ext install dbaeumer.vscode-eslint
), and pressing enter.).prettierrc.js
(or.prettierrc.json
) (Install thePrettier - Code formatter
extension, it can be easily added by pressing (Ctrl + P) in VS Code, pasting the following command (ext install esbenp.prettier-vscode
), and pressing enter.).stylelintrc
(Install thestylelint
extension, it can be easily added by pressing (Ctrl + P) in VS Code, pasting the following command (ext install stylelint.vscode-stylelint
), and pressing enter.).editorconfig
(Install theEditorConfig for VS Code
extension, it can be easily added by pressing (Ctrl + P) in VS Code, pasting the following command (ext install EditorConfig.EditorConfig
), and pressing enter.)
- eslint-config-airbnb
- This package provides Airbnb's .eslintrc as an extensible shared config.
- eslint-plugin-jsx-a11y (Peer Dependency)
- Static AST checker for accessibility rules on JSX elements.
- eslint-plugin-react (Peer Dependency)
- React specific linting rules for ESLint
- eslint-plugin-import
- Support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
- stylelint-config-airbnb
- This package provides Airbnb's .stylelintrc as an extensible shared config.
- eslint-plugin-react-hooks
- This package provides the Rules of Hooks.
- babel-eslint
- A wrapper for Babel's parser used for ESLint.
- We decided to include this since Airbnb Style Guide uses Babel.
-
- Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.
-
- Runs Prettier as a Stylelint rule and reports differences as individual Stylelint issues.
-
- Turns off all rules that are unnecessary or might conflict with Prettier.
-
- Turns off all rules that are unnecessary or might conflict with Prettier.
- eslint-plugin-html
- A ESLint plugin to lint and fix inline scripts contained in HTML files.
- eslint-plugin-jest
- ESLint plugin for Jest.
Once files are created, you may edit to your liking.
{
"extends": [
"airbnb",
"plugin:prettier/recommended",
],
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"rules": {
"jsx-a11y/href-no-hash": ["off"],
"react/jsx-filename-extension": ["warn", { "extensions": [".js", ".jsx"] }],
"max-len": [
"warn",
{
"code": (SET BY USER),
"tabWidth": 2,
"comments": (SET BY USER),
"ignoreComments": false,
"ignoreTrailingComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
]
}
}
{
"printWidth": (SET BY USER),
"singleQuote": true,
"trailingComma": (SET BY USER)
}
{
"extends": ["stylelint-prettier/recommended", "stylelint-config-airbnb"]
}
root = true
[*.{js,jsx,html,md,css}]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,jsx,css}]
indent_size = 2
indent_style = space
This script was created by Paulo Ramos, updated and modified with new features added by Arthur Nunes, Martin Dobrev, Darshan Gada, Imed Adel. and inspired by Jeffrey Zhen's tutorial.