Socket
Socket
Sign inDemoInstall

eslint-config-react-app

Package Overview
Dependencies
434
Maintainers
5
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eslint-config-react-app

ESLint configuration used by Create React App


Version published
Weekly downloads
4.3M
increased by2%
Maintainers
5
Install size
29.4 MB
Created
Weekly downloads
 

Package description

What is eslint-config-react-app?

The eslint-config-react-app package is a set of ESLint rules curated for React applications created with Create React App. It provides a baseline ESLint configuration that enforces best practices and common conventions for React and JavaScript code.

What are eslint-config-react-app's main functionalities?

Enforcing Code Style

This feature allows developers to enforce a consistent code style across their React project by extending the eslint-config-react-app in their project's ESLint configuration.

"eslintConfig": { "extends": "react-app" }

Catching Common Errors

The package helps catch common errors, such as using incorrect data types or misusing React hooks, which can prevent potential bugs in the application.

// Example of an error caught by ESLint using eslint-config-react-app
const [count, setCount] = useState('0');
setCount(count + 1);

Integration with Create React App

eslint-config-react-app is designed to integrate seamlessly with projects bootstrapped using Create React App, providing out-of-the-box linting that adheres to the conventions and rules preferred for React apps.

// No specific code sample, as this is about integration
// When using Create React App, eslint-config-react-app is automatically included.

Other packages similar to eslint-config-react-app

Readme

Source

eslint-config-react-app

This package includes the shareable ESLint configuration used by Create React App.
Please refer to its documentation:

  • Getting Started – How to create a new app.
  • User Guide – How to develop apps bootstrapped with Create React App.

Usage in Create React App Projects

The easiest way to use this configuration is with Create React App, which includes it by default.

You don’t need to install it separately in Create React App projects.

Usage Outside of Create React App

If you want to use this ESLint configuration in a project not built with Create React App, you can install it with the following steps.

First, install this package and ESLint.

npm install --save-dev eslint-config-react-app eslint@^8.0.0

Then create a file named .eslintrc.json with following contents in the root folder of your project:

{
  "extends": "react-app"
}

That's it! You can override the settings from eslint-config-react-app by editing the .eslintrc.json file. Learn more about configuring ESLint on the ESLint website.

Jest rules

This config also ships with optional Jest rules for ESLint (based on eslint-plugin-jest).

You can enable these rules by adding the Jest config to the extends array in your ESLint config.

{
  "extends": ["react-app", "react-app/jest"]
}

Accessibility Checks

The following rules from the eslint-plugin-jsx-a11y plugin are activated:

If you want to enable even more accessibility rules, you can create an .eslintrc.json file in the root of your project with this content:

{
  "extends": ["react-app", "plugin:jsx-a11y/recommended"],
  "plugins": ["jsx-a11y"]
}

However, if you are using Create React App and have not ejected, any additional rules will only be displayed in the IDE integrations, but not in the browser or the terminal.

FAQs

Last updated on 12 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc