Justia's ESLint configuration for React projects
This package uses @justia/eslint-config
as a base configuration, slightly modifies prettier rules and adds React-specific rules for React projects.
Install the correct versions of the peer dependencies, which are listed by the command:
npm info "@justia/eslint-config-react@latest" peerDependencies
If using npm 5+, use this shortcut
npx install-peerdeps --dev @justia/eslint-config-react
If using npm < 5, Linux/OSX users can run
(
export PKG=@justia/eslint-config-react;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)
Which produces and runs a command like:
npm install --save-dev @justia/eslint-config-react eslint@^#.#.# prettier@^#.#.# babel-eslint@^#.#.# eslint-config-prettier@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-prettier@^#.#.# eslint-plugin-promise@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-react@^#.#.# eslint-plugin-react-hooks@^#.#.#
Default configuration that contains all the base ESLint rules, including ECMAScript 6+ and React. It requires the following external packages:
eslint
prettier
babel-eslint
eslint-config-prettier
eslint-plugin-import
eslint-plugin-prettier
eslint-plugin-promise
eslint-plugin-jsx-a11y
eslint-plugin-react
After installation of the package and the peer dependencies, add "extends": ["@justia/eslint-config-react"]
to your .eslintrc
.
This entry point enables the linting rules for React hooks (requires v16.8+). It requires eslint-plugin-react-hooks
.
To use, add the following to your .eslintrc
:
{
"extends": [
"@justia/eslint-config-react",
"@justia/eslint-config-react/hooks"
]
}