What is @react-native-community/eslint-config?
@react-native-community/eslint-config is an ESLint configuration package specifically tailored for React Native projects. It provides a set of linting rules and configurations that help maintain code quality and consistency in React Native applications.
What are @react-native-community/eslint-config's main functionalities?
Standard React Native Linting Rules
This feature provides a standard set of linting rules for React Native projects. By extending the @react-native-community configuration, you can ensure that your code adheres to best practices and common conventions in the React Native community.
{
"extends": ["@react-native-community"]
}
Integration with Prettier
This feature allows you to integrate Prettier with ESLint, ensuring that your code is not only linted but also formatted according to Prettier's rules. This helps in maintaining a consistent code style across your project.
{
"extends": ["@react-native-community", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
Customizable Rules
This feature allows you to customize the linting rules according to your project's needs. You can override the default rules provided by @react-native-community to better fit your development workflow.
{
"extends": ["@react-native-community"],
"rules": {
"no-console": "warn",
"react-native/no-inline-styles": "off"
}
}
Other packages similar to @react-native-community/eslint-config
eslint-config-airbnb
eslint-config-airbnb is a popular ESLint configuration that follows the Airbnb JavaScript style guide. It is widely used in both React and React Native projects. Compared to @react-native-community/eslint-config, it provides a more general set of rules that are not specifically tailored for React Native.
eslint-config-standard
eslint-config-standard is another popular ESLint configuration that follows the JavaScript Standard Style. It is less opinionated than eslint-config-airbnb and provides a simpler set of rules. While it can be used in React Native projects, it does not offer the specific rules and configurations that @react-native-community/eslint-config provides.
eslint-config-react-app
eslint-config-react-app is the ESLint configuration used by Create React App. It is designed for React projects and includes rules for both JavaScript and JSX. While it can be used in React Native projects, it is more focused on web development and does not include React Native-specific rules.
![Version](https://img.shields.io/npm/v/@react-native-community/eslint-config.svg?style=flat-square)
Installation
yarn add --dev eslint prettier @react-native-community/eslint-config
Note: We're using yarn
to install deps. Feel free to change commands to use npm
3+ and npx
if you like
Usage
Add to your eslint config (.eslintrc
, or eslintConfig
field in package.json
):
{
"extends": "@react-native-community"
}