Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions packages/eslint-config-react-native/README.md

This file was deleted.

340 changes: 0 additions & 340 deletions packages/eslint-config-react-native/index.js

This file was deleted.

44 changes: 0 additions & 44 deletions packages/eslint-config-react-native/package.json

This file was deleted.

67 changes: 64 additions & 3 deletions packages/eslint-plugin-react-native/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,74 @@
# @react-native/eslint-plugin

This plugin is intended to be used in [`@react-native/eslint-config`](https://github.com/facebook/react-native/tree/HEAD/packages/eslint-config-react-native). You probably want to install that package instead.
[![Version][version-badge]][package]

## About
This plugin exports a recommended eslint config for React Native projects

## Installation

```
yarn add --dev eslint @react-native/eslint-plugin
yarn add --dev eslint prettier @react-native/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`):
From [`v8.23.0`](https://github.com/eslint/eslint/releases/tag/v8.23.0) onwards, you can use `eslint.config.js` which uses the new [flat config file format](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new).

```javascript
const reactNative = require('@react-native/eslint-plugin');
const myplugin = require('my-plugin');

module.exports = [
...reactNative.configs.flat,
{
plugins: {
myplugin
},
...
},
];
Comment on lines +21 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this example use ESM?

```

If you're still using a version of eslint < `v8.23.0` or still using the old configuration files, place the following on your eslint config file (`.eslintrc`, or `eslintConfig` field in `package.json`):

```json
{
"extends": "plugin:@react-native/legacy"
}
```

## Plugin supported Eslint versions

| Eslint version | `.eslintrc` support | `eslint.config.js` support |
| :------------------- | :-----------------: | :------------------------: |
| `>= 9.0.0` | ❌ | ✅ |
| `>= 8.23.0 < 9.0.0` | ✅ | ✅ |
| `< 8.23.0` | ✅ | ❌ |


## Manual Configuration

This plugin also exports rules that you can manually configure by importing this package as a plugin

## Usage

```javascript
const reactNative = require('@react-native/eslint-plugin');

module.exports = [
{
plugins: {
reactNative
},
...
},
];
```

If you're still using a version of eslint < `v8.23.0` or still using the old configuration files (`.eslintrc`, or `eslintConfig` field in `package.json`):

```json
{
Expand All @@ -32,3 +88,8 @@ To run the tests in this package, run the following commands from the React Nati

1. `yarn` to install the dependencies. You just need to run this once
2. `yarn jest packages/eslint-plugin-react-native`.


[version-badge]: https://img.shields.io/npm/v/@react-native/eslint-plugin.svg?style=flat-square
[package]: https://www.npmjs.com/package/@react-native/eslint-plugin

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const rule = require('../platform-colors.js');
const rule = require('../rules/platform-colors.js');
const ESLintTester = require('./eslint-tester.js');

const eslintTester = new ESLintTester();
Expand Down
Loading