# @shopify/eslint-plugin

> Shopify's ESLint rules and configs.

Latest version **50.0.0** (published 2025-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @shopify/eslint-plugin
pnpm add @shopify/eslint-plugin
yarn add @shopify/eslint-plugin
bun add @shopify/eslint-plugin
```

## Health

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

Positive: no vulnerabilities; has provenance; high maintenance score.

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

Negative: stale.

## Facts

| | |
|---|---|
| Version | 50.0.0 |
| Published | 2025-05-27 |
| First published | 2020-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 22 |
| Unpacked size | 274.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 492 |
| Author | Shopify Inc. |
| Maintainers | shopify-admin, shopify-dep, mishsmelle, netlohan, pmoloney89, maryharte, jaykay101 |
| Keywords | eslint, eslintconfig, eslintplugin, eslint-config, eslint-plugin |

## Links

- npm: https://www.npmjs.com/package/@shopify/eslint-plugin
- Repository: https://github.com/Shopify/web-configs
- Homepage: https://github.com/Shopify/web-configs/blob/main/packages/eslint-plugin/README.md
- Issues: https://github.com/Shopify/web-configs/issues
- npm.io page: https://npm.io/package/@shopify/eslint-plugin

## Dependencies (22)

- [globals](https://npm.io/package/globals.md) ^15.13.0
- [pkg-dir](https://npm.io/package/pkg-dir.md) ^5.0.0
- [doctrine](https://npm.io/package/doctrine.md) ^2.1.0
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [change-case](https://npm.io/package/change-case.md) ^4.1.2
- [common-tags](https://npm.io/package/common-tags.md) ^1.8.2
- [jsx-ast-utils](https://npm.io/package/jsx-ast-utils.md) ^3.3.5
- [eslint-plugin-n](https://npm.io/package/eslint-plugin-n.md) ^17.5.0
- [typescript-eslint](https://npm.io/package/typescript-eslint.md) ^8.18.0
- [eslint-plugin-jest](https://npm.io/package/eslint-plugin-jest.md) ^28.9.0
- [eslint-module-utils](https://npm.io/package/eslint-module-utils.md) ^2.12.0
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.37.2
- [eslint-plugin-promise](https://npm.io/package/eslint-plugin-promise.md) ^7.2.1
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^9.1.0
- [eslint-plugin-import-x](https://npm.io/package/eslint-plugin-import-x.md) ^4.13.3
- [eslint-plugin-jsx-a11y](https://npm.io/package/eslint-plugin-jsx-a11y.md) ^6.10.2
- [eslint-plugin-prettier](https://npm.io/package/eslint-plugin-prettier.md) ^5.2.1
- [eslint-plugin-react-hooks](https://npm.io/package/eslint-plugin-react-hooks.md) ^5.1.0
- [eslint-plugin-eslint-comments](https://npm.io/package/eslint-plugin-eslint-comments.md) ^3.2.0
- [eslint-plugin-jest-formatting](https://npm.io/package/eslint-plugin-jest-formatting.md) ^3.1.0
- [eslint-plugin-sort-class-members](https://npm.io/package/eslint-plugin-sort-class-members.md) ^1.21.0
- [eslint-import-resolver-typescript](https://npm.io/package/eslint-import-resolver-typescript.md) ^4.4.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 50.0.0 (latest) — 2025-05-27
- 0.0.0-snapshot-20250527021638 (snapshot) — 2025-05-27
- 41.1.0-babel-version-beta.0 (next) — 2022-02-15
- 49.0.0 — 2025-05-26
- 0.0.0-snapshot-20250523222705 — 2025-05-23
- 48.0.2 — 2025-03-21
- 48.0.0 — 2025-03-19
- 0.0.0-snapshot-20250311213039 — 2025-03-11
- 0.0.0-snapshot-20250311210802 — 2025-03-11
- 0.0.0-snapshot-20250311145226 — 2025-03-11
- 47.0.1 — 2025-02-02
- 47.0.0 — 2025-01-31
- 0.0.0-snapshot-20250131075836 — 2025-01-31
- 0.0.0-snapshot-20250131064425 — 2025-01-31
- 0.0.0-snapshot-20241230075214 — 2024-12-30
- … 67 more at https://npm.io/package/@shopify/eslint-plugin/versions

## README

# `@shopify/eslint-plugin`

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](../../LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Feslint-plugin.svg)](https://badge.fury.io/js/%40shopify%2Feslint-plugin.svg)

Shopify’s ESLint rules and configs.

## Installation

You'll first need to install [ESLint](http://eslint.org):

**With Yarn**

```bash
yarn add --dev eslint
```

**With npm**

```bash
$ npm i eslint --save-dev
```

Next, install `@shopify/eslint-plugin`:

**With Yarn**

```bash
yarn add --dev @shopify/eslint-plugin
```

**With npm**

```bash
$ npm install @shopify/eslint-plugin --save-dev
```

**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@shopify/eslint-plugin` globally.

## Usage

As of version 46.0.0, this package uses Eslint's "Flat Config" format, not the legacy "eslintrc" format. To upgrade your Eslint configuration, follow the [Configuration Migration Guide](https://eslint.org/docs/latest/use/configure/migration-guide).

As of version 47.0.0, this package no longer configures formatting related rules in the `es5`, `esnext` and `typescript` configs, as ESLint [depreacated their formatting related rules](https://eslint.org/blog/2023/10/deprecating-formatting-rules/).

---

Shopify’s ESLint configs come bundled in this package. In order to use them, you include the relevant configurations in your project’s `eslint.config.js`. For example, the following will use the ESNext (ES2015 and later) config:

```js
import shopifyEslintPlugin from '@shopify/eslint-plugin';

export default [...shopifyEslintPlugin.configs.esnext];
```

If you are working on an ES5 project, use the ES5 version of the configuration:

```js
import shopifyEslintPlugin from '@shopify/eslint-plugin';

export default [...shopifyEslintPlugin.configs.es5];
```

You can also add some "augmenting" configs on top of the "core" config by using an array of linting configs. For example, the following configuration would provide a base ESNext config that is augmented by a React config:

```js
import shopifyEslintPlugin from '@shopify/eslint-plugin';

export default [
  ...shopifyEslintPlugin.configs.esnext,
  ...shopifyEslintPlugin.configs.react,
];
```

Likewise, if you are using TypeScript and React, the following configuration uses the TypeScript base config with the React-specific rules provided by the React configuration file. To demonstrate multiple augmentations, we've also added the Prettier config, which disables rules that will conflict in projects using prettier.

```js
import shopifyEslintPlugin from '@shopify/eslint-plugin';

export default [
  ...shopifyEslintPlugin.configs.typescript,
  ...shopifyEslintPlugin.configs.react,
  ...shopifyEslintPlugin.configs.prettier,
];
```

## Provided configurations

This plugin provides the following core configurations:

- [esnext](lib/config/esnext.js): Use this for anything written with ES2015+ features.
- [typescript](lib/config/typescript.js): Use this for Typescript projects. The rules enabled in this config do not require type-checking to run. To enable all Typescript rules, you must augment this config with the `typescript-type-checking` config mentioned below.
- [es5](lib/config/es5.js): Use this for legacy projects.

This plugin also provides the following tool-specific configurations, which can be used on top of the core configurations:

- [typescript-type-checking](lib/config/typescript-type-checking.js) Use this config to augment the `typescript` config to enable all TypeScript rules, including those that require type checking. These rules are slower to run and and you will need to specify a path to your tsconfig.json file in the "project" property of "parserOptions". The following example would provide all of the TypeScript rules, assuming the tsconfig.json is in the same directory as you ESlint configuration.

```js
import shopifyEslintPlugin from '@shopify/eslint-plugin';

export default [
  ...shopifyEslintPlugin.configs.typescript,
  ...shopifyEslintPlugin.configs['typescript-type-checking'],
  {
    languageOptions: {
      parserOptions: {
        project: 'tsconfig.json',
      },
    },
  },
];
```

- [react](lib/config/react.js): Use this for React projects.
- [polaris](lib/config/polaris.js): Use this for projects that use [Shopify’s React Polaris components](https://polaris.shopify.com/components).
- [prettier](lib/config/prettier.js): Use [prettier](https://github.com/prettier/prettier) for consistent formatting. Using this Shopify's prettier config will [override](https://github.com/prettier/eslint-config-prettier/blob/master/index.js) the default Shopify eslint rules in favor of prettier formatting. Prettier must be installed within your project, as @shopify/eslint-plugin does not provide the dependency itself.
- [webpack](lib/config/webpack.js): Use this for projects built by [webpack](https://webpack.js.org/).

### node

If you are working on a node module, we also provide the [node configuration](lib/config/node.js) for you. Note that this configuration needs to be used in conjunction with one of the core configurations (either `es5` or `esnext`). If you plan to transpile your code using Babel, use the `esnext` config. If you do not plan to do so, the config you choose depends on the version of node you wish to support, and how many ESNext features are natively available in that version. You can see a detailed list of what version of node supports what new JavaScript features by visiting http://node.green.

A node project that will use Babel for transpilation would need the following ESLint config:

```js
import shopifyEslintPlugin from '@shopify/eslint-plugin';

export default [
  ...shopifyEslintPlugin.configs.esnext,
  ...shopifyEslintPlugin.configs.node,
];
```

### Supported Typescript version

The supported version of TypeScript is constrained by the [@typescipt-eslint parser support](https://typescript-eslint.io/users/dependency-versions/#typescript) that is installed.

## Plugin-Provided Rules

This plugin provides the following custom rules, which are included as appropriate in all core linting configs:

- [binary-assignment-parens](docs/rules/binary-assignment-parens.md): Require (or disallow) assignments of binary, boolean-producing expressions to be wrapped in parentheses.
- [class-property-semi](docs/rules/class-property-semi.md): Require (or disallow) semicolons for class properties.
- [images-no-direct-imports](docs/rules/images-no-direct-imports.md): Prevent images from being directly imported.
- [jest-no-snapshots](docs/rules/jest-no-snapshots.md): Disallows jest snapshots.
- [jsx-no-complex-expressions](docs/rules/jsx-no-complex-expressions.md): Disallow complex expressions embedded in in JSX.
- [jsx-no-hardcoded-content](docs/rules/jsx-no-hardcoded-content.md): Disallow hardcoded content in JSX.
- [jsx-prefer-fragment-wrappers](docs/rules/jsx-prefer-fragment-wrappers.md): Disallow useless wrapping elements in favour of fragment shorthand in JSX.
- [no-namespace-imports](docs/rules/no-namespace-imports.md): Prevent namespace import declarations.
- [no-useless-computed-properties](docs/rules/no-useless-computed-properties.md): Prevent the usage of unnecessary computed properties.
- [polaris-no-bare-stack-item](docs/rules/polaris-no-bare-stack-item.md): Disallow the use of Polaris’s `Stack.Item` and `LegacyStack.Item` without any custom props.
- [polaris-prefer-sectioned-prop](docs/rules/polaris-prefer-sectioned-prop.md): Prefer the use of the `sectioned` props in Polaris components instead of wrapping all contents in a `Section` component.
- [prefer-class-properties](docs/rules/prefer-class-properties.md): Prefer class properties to assignment of literals in constructors.
- [prefer-early-return](docs/rules/prefer-early-return.md): Prefer early returns over full-body conditional wrapping in function declarations.
- [no-ancestor-directory-import](docs/rules/no-ancestor-directory-import.md): Prefer imports from within a directory extend to the file from where they are importing without relying on an index file.
- [prefer-module-scope-constants](docs/rules/prefer-module-scope-constants.md): Prefer that screaming snake case variables always be defined using `const`, and always appear at module scope.
- [prefer-twine](docs/rules/prefer-twine.md): Prefer Twine over Bindings as the name for twine imports.
- [react-hooks-strict-return](docs/rules/react-hooks-strict-return.md): Restrict the number of returned items from React hooks.
- [react-initialize-state](docs/rules/react-initialize-state.md): Require that React component state be initialized when it has a non-empty type.
- [react-no-multiple-render-methods](docs/rules/react-no-multiple-render-methods.md): Disallow multiple render methods in React component classes.
- [react-prefer-private-members](docs/rules/react-prefer-private-members.md): Prefer all non-React-specific members be marked private in React class components.
- [react-type-state](docs/rules/react-type-state.md): Require that React component state be typed in TypeScript.
- [restrict-full-import](docs/rules/restrict-full-import.md): Prevent importing the entirety of a package.
- [sinon-no-restricted-features](docs/rules/sinon-no-restricted-features.md): Restrict the use of specified sinon features.
- [sinon-prefer-meaningful-assertions](docs/rules/sinon-prefer-meaningful-assertions.md): Require the use of meaningful sinon assertions through sinon.assert or sinon-chai.
- [strict-component-boundaries](docs/rules/strict-component-boundaries.md): Prevent module imports between components.
- [typescript-prefer-pascal-case-enums](docs/rules/typescript-prefer-pascal-case-enums.md): Prefer TypeScript enums be defined using Pascal case.
- [typescript-prefer-singular-enums](docs/rules/typescript-prefer-singular-enums.md): Prefer TypeScript enums be singular.
- [typescript-prefer-build-client-schema](docs/rules/typescript-prefer-build-client-schema.md): Prefer buildClientSchema for schema building.
- [webpack-no-unnamed-dynamic-imports](docs/rules/webpack-no-unnamed-dynamic-imports.md): Require that all dynamic imports contain a `webpackChunkName` comment.

## Suggested additional configs

For applications that use graphql we recommend using the `operations-recommended` preset from [`@graphql-eslint/eslint-plugin`](https://github.com/B2o5T/graphql-eslint). This is not included as part of this plugin because graphql has a large install footprint and not everybody needs it.

For applications that wish to have code formatting opinions, we strongly suggest using `prettier`, and either format with `prettier`'s CLI after running eslint, or run prettier within eslint by using the `prettier` config. If you wish to diverge from this then you can configure formatting using the rules from [`@stylistic/eslint-plugin`](https://eslint.style/packages/default) package.

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