Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
eslint-config-react-app
Advanced tools
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.
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.
This package provides Airbnb's ESLint configuration, which is a popular style guide in the JavaScript community. It includes React-specific linting rules and differs from eslint-config-react-app by enforcing stricter code conventions and patterns.
This is an ESLint configuration package that extends the StandardJS ruleset with React-specific rules. It offers a different set of opinions on code style and best practices compared to eslint-config-react-app.
eslint-config-prettier disables all ESLint rules that might conflict with Prettier formatting. While it doesn't provide React-specific rules, it's often used in conjunction with other ESLint configs, like eslint-config-react-app, to ensure code style consistency.
This package includes the shareable ESLint configuration used by Create React App.
Please refer to its documentation:
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.
If you want to use this ESLint configuration in a project not built with Create React App, you can install it with following steps.
First, install this package, ESLint and the necessary plugins.
npm install --save-dev eslint-config-react-app babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 eslint-plugin-react@^7.1.0
Then create a file named .eslintrc
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
file. Learn more about configuring ESLint on the ESLint website.
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
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
ESLint configuration used by Create React App
The npm package eslint-config-react-app receives a total of 2,687,980 weekly downloads. As such, eslint-config-react-app popularity was classified as popular.
We found that eslint-config-react-app demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
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.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.