# eslint-plugin-pinia

> ESLint plugin for Pinia best practices

Latest version **0.4.2** (published 2025-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-pinia
pnpm add eslint-plugin-pinia
yarn add eslint-plugin-pinia
bun add eslint-plugin-pinia
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2025-11-21 |
| First published | 2024-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18 |
| Dependencies | 0 |
| Unpacked size | 47.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lisi Linhart |
| Maintainers | lisilinhart |
| Keywords | eslint, eslint-plugin, eslint-config, vue, vuejs, pinia, piniajs, rules |

## Links

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

## 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
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 0.4.2 (latest) — 2025-11-21
- 0.4.1 — 2024-08-25
- 0.4.0 — 2024-08-25
- 0.3.1 — 2024-08-24
- 0.3.0 — 2024-08-24
- 0.2.0 — 2024-07-05
- 0.1.13 — 2024-04-13
- 0.1.12 — 2024-04-05
- 0.1.11 — 2024-04-05
- 0.1.10 — 2024-04-04
- 0.1.9 — 2024-04-03
- 0.1.8 — 2024-04-03
- 0.1.7 — 2024-04-03
- 0.1.4 — 2024-04-02
- 0.1.3 — 2024-04-02
- … 3 more at https://npm.io/package/eslint-plugin-pinia/versions

## README

# eslint-plugin-pinia

![npm](https://img.shields.io/npm/v/eslint-plugin-pinia)
[![test](https://github.com/lisilinhart/eslint-plugin-pinia/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/lisilinhart/eslint-plugin-pinia/actions/workflows/test.yml)

Eslint plugin that enforces some best practices for writing pinia stores

## Installation

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

```sh
npm i eslint --save-dev
```

Next, install `eslint-plugin-pinia`:

```sh
npm install eslint-plugin-pinia --save-dev
```

## Usage

Add `pinia` to the plugins section of your `.eslintrc` or `eslint.config.js` configuration file. You can omit the `eslint-plugin-` prefix:

```json
// .eslintrc [Legacy Config]
{
  "plugins": ["pinia"]
}
```

```js
// eslint.config.js
import pinia from 'eslint-plugin-pinia'

export default [
  plugins: {
    pinia
  }
]
```

### Rule Configuration

Then configure the rules you want to use under the rules section.

```json
// .eslintrc [Legacy Config]
{
  "rules": {
    "pinia/require-export-define-store": [
      "warn"
    ]
  }
}
```

```js
// eslint.config.js
import pinia from 'eslint-plugin-pinia'

export default [
  {
    plugin: {
      pinia
    },
    rules: {
      "pinia/require-export-define-store": ["warn"]
    }
  }
]
```

### Recommended

To use the recommended configuration, extend it in your `.eslintrc` or `eslint.config.js` file:

```json
// .eslintrc [Legacy Config]
{
  "extends": ["plugin:pinia/recommended"]
}
```

```js
// eslint.config.js
import pinia from 'eslint-plugin-pinia'

export default [
  pinia.configs["recommended-flat"],
]
```

All recommend rules will be set to error by default. You can however disable some rules by setting turning them `off` in your configuration file or by setting them to `warn` in your configuration file.

### all rules

To use the all configuration, extend it in your `.eslintrc` or `eslint.config.js` file:

```json
// .eslintrc [Legacy Config]
{
  "extends": ["plugin:pinia/all"]
}
```

```js
// eslint.config.js
import pinia from 'eslint-plugin-pinia'

export default [
  pinia.configs["all-flat"],
]
```

## Rules

<!-- begin auto-generated rules list -->

💼 Configurations enabled in.\
⚠️ Configurations set to warn in.\
🚫 Configurations disabled in.\
🌐 Set in the `all` configuration.\
🌐 Set in the `all-flat` configuration.\
✅ Set in the `recommended` configuration.\
✅ Set in the `recommended-flat` configuration.

| Name                                                                                         | Description                                                                                | 💼  | ⚠️        | 🚫    |
| :------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :-- | :-------- | :---- |
| [never-export-initialized-store](docs/rules/never-export-initialized-store.md)               | Never export an initialized named or default store.                                        | ✅ ✅ | 🌐 🌐     |       |
| [no-duplicate-store-ids](docs/rules/no-duplicate-store-ids.md)                               | Disallow duplicate store ids.                                                              | ✅ ✅ | 🌐 🌐     |       |
| [no-return-global-properties](docs/rules/no-return-global-properties.md)                     | Disallows returning globally provided properties from Pinia stores.                        | ✅ ✅ | 🌐 🌐     |       |
| [no-store-to-refs-in-store](docs/rules/no-store-to-refs-in-store.md)                         | Disallow use of storeToRefs inside defineStore                                             | ✅ ✅ | 🌐 🌐     |       |
| [prefer-single-store-per-file](docs/rules/prefer-single-store-per-file.md)                   | Encourages defining each store in a separate file.                                         |     |           | 🌐 🌐 |
| [prefer-use-store-naming-convention](docs/rules/prefer-use-store-naming-convention.md)       | Enforces the convention of naming stores with the prefix `use` followed by the store name. |     | 🌐 🌐 ✅ ✅ |       |
| [require-setup-store-properties-export](docs/rules/require-setup-store-properties-export.md) | In setup stores all state properties must be exported.                                     | ✅ ✅ | 🌐 🌐     |       |

<!-- end auto-generated rules list -->

## Credits

- [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) The core repository structure came from this eslint plugin

## Licence

[MIT](https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/LICENSE) Licence &copy; 2024

## Contributing

Please check the [Contributing](https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/.github/CONTRIBUTING.md) file.

This project exists thanks to all the people who contribute 😍!

<a href="https://github.com/lisilinhart/eslint-plugin-pinia/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=lisilinhart/eslint-plugin-pinia" />
</a>

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