# eslint-plugin-react-perf

> Performance-minded React linting rules for ESLint

Latest version **3.3.3** (published 2024-10-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-react-perf
pnpm add eslint-plugin-react-perf
yarn add eslint-plugin-react-perf
bun add eslint-plugin-react-perf
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.3.3 |
| Published | 2024-10-18 |
| First published | 2016-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.9.1 |
| Dependencies | 0 |
| Unpacked size | 98.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 233 |
| Author | Charles Vazac |
| Maintainers | vbud, cvazac |
| Keywords | react, eslint, eslintplugin, eslint-plugin, perf |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-react-perf
- Repository: https://github.com/cvazac/eslint-plugin-react-perf
- Homepage: https://github.com/cvazac/eslint-plugin-react-perf#readme
- Issues: https://github.com/cvazac/eslint-plugin-react-perf/issues
- npm.io page: https://npm.io/package/eslint-plugin-react-perf

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.3.3 (latest) — 2024-10-18
- 3.3.2 — 2024-01-11
- 3.3.1 — 2021-12-14
- 3.3.0 — 2020-10-30
- 3.2.4 — 2020-07-23
- 3.2.3 — 2019-11-05
- 3.2.2 — 2019-11-05
- 3.2.1 — 2019-08-13
- 3.2.0 — 2019-06-08
- 3.1.0 — 2019-03-15
- 3.0.2 — 2019-02-09
- 3.0.1 — 2019-01-12
- 3.0.0 — 2019-01-12
- 2.0.9 — 2018-07-24
- 2.0.8 — 2018-01-31
- … 13 more at https://npm.io/package/eslint-plugin-react-perf/versions

## README

# eslint-plugin-react-perf

Performance-minded React linting rules for ESLint (motivated by [esamatti](https://twitter.com/esamatti)'s post ["React.js pure render performance anti-pattern"](https://medium.com/@esamatti/react-js-pure-render-performance-anti-pattern-fb88c101332f)).

# Installation

```sh
$ npm i eslint-plugin-react-perf
```

Add `plugins` section and specify eslint-plugin-react-perf as a plugin.

```json
{
  "plugins": ["react-perf"]
}
```

# List of supported rules

- [react-perf/jsx-no-new-object-as-prop](docs/rules/jsx-no-new-object-as-prop.md): Prevent `{...}` as JSX prop value
- [react-perf/jsx-no-new-array-as-prop](docs/rules/jsx-no-new-array-as-prop.md): Prevent `[...]` as JSX prop value
- [react-perf/jsx-no-new-function-as-prop](docs/rules/jsx-no-new-function-as-prop.md): Prevent `function` as JSX prop value
- [react-perf/jsx-no-jsx-as-prop](docs/rules/jsx-no-jsx-as-prop.md): Prevent JSX as JSX prop value

# Configuration

As of v3.3.0, each eslint-plugin-react-perf rule supports configuration to control whether native elements (lower case first letter React components) are ignored.

With this configuration, all native elements are ignored for this rule:

```json
{
  "react-perf/jsx-no-new-object-as-prop": [
    "error",
    {
      "nativeAllowList": "all"
    }
  ]
}
```

With this configuration, the "style" attribute is ignored for native elements for this rule:

```json
{
  "react-perf/jsx-no-new-object-as-prop": [
    "error",
    {
      "nativeAllowList": ["style"]
    }
  ]
}
```

## Recommended

This plugin exports a `recommended` configuration that enforce React good practices.

### Flat configuration

To enable this configuration add the following to your eslint.config.js:
```js
import reactPerfPlugin from 'eslint-plugin-react-perf';

const config = [
  reactPerfPlugin.configs.flat.recommended
];

export default config;
```

### eslintrc configuration

To enable this configuration use the `extends` property in your `.eslintrc` config file:

```js
{
  "extends": ["plugin:react-perf/recommended"]
}
```

See [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information about extending configuration files.

The rules enabled in this configuration are:

- [react-perf/jsx-no-new-object-as-prop](docs/rules/jsx-no-new-object-as-prop.md)
- [react-perf/jsx-no-new-array-as-prop](docs/rules/jsx-no-new-array-as-prop.md)
- [react-perf/jsx-no-new-function-as-prop](docs/rules/jsx-no-new-function-as-prop.md)
- [react-perf/jsx-no-jsx-as-prop](docs/rules/jsx-no-jsx-as-prop.md)

## All

This plugin also exports an `all` configuration that includes every available rule.

### Flat configuration

To enable this configuration add the following to your eslint.config.js:
```js
import reactPerfPlugin from 'eslint-plugin-react-perf';

const config = [
  reactPerfPlugin.configs.flat.all
];

export default config;
```

### eslintrc configuration

```js
{
  "plugins": [
    "react-perf"
  ],
  "extends": ["plugin:react-perf/all"]
}
```

# Test anti-patterns in runtime

Try out [cvazac/test-ref-pattern](https://github.com/cvazac/test-ref-pattern).

# License

eslint-plugin-react-perf is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

---
_Source: https://npm.io/package/eslint-plugin-react-perf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
