Registry / testing / eslint-plugin-pinia

eslint-plugin-pinia

JSON →
library0.4.2jsnpmunverified

An ESLint plugin that enforces best practices for writing Pinia stores in Vue.js applications. Current stable version is 0.4.2, released in November 2025, with a focus on store structure and common pitfalls. It provides a recommended configuration that includes rules like never-export-initialized-store, no-duplicate-store-ids, no-return-global-properties, and no-store-to-refs-in-store, plus optional rules like prefer-single-store-per-file. Ships TypeScript types, requires ESLint >=8.0.0 and @typescript-eslint/utils >=7.5, and supports both legacy ESLint config and flat config.

npm install eslint-plugin-pinia
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-PINI
E
eslint-plugin-pinia
testingjavascriptv0.4.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default import (plugin object)
import pinia from 'eslint-plugin-pinia'
const pinia = require('eslint-plugin-pinia')
ESM only; package has no default export in CJS. Use import for both flat and legacy configs.
recommended-flat config
pinia.configs["recommended-flat"]
pinia.configs["recommended"]
In flat config, use 'recommended-flat' not 'recommended'. The 'recommended' key is for legacy .eslintrc.
all-flat config
pinia.configs["all-flat"]
pinia.configs["all"]
In flat config, use 'all-flat'. The 'all' key is for legacy .eslintrc.

Shows how to import and configure the plugin in ESLint flat config, including rules and recommended preset.

import pinia from 'eslint-plugin-pinia'; export default [ { plugins: { pinia }, rules: { "pinia/no-duplicate-store-ids": "error", "pinia/no-store-to-refs-in-store": "error" } } ]; // Also use the recommended flat config: export default [ pinia.configs["recommended-flat"] ];
Debug
Known issues
gotchaFlat config users must use 'recommended-flat' or 'all-flat' config keys, not 'recommended' or 'all'.
fix
Use pinia.configs["recommended-flat"] instead of pinia.configs["recommended"].
affects: >=0.3.0
deprecatedLegacy .eslintrc format (like 'extends': ['plugin:pinia/recommended']) is deprecated but still supported.
fix
Consider migrating to flat config (eslint.config.js) with pinia.configs["recommended-flat"].
affects: >=0.3.0
gotchaThe rule 'prefer-single-store-per-file' is disabled by default, but users may expect it to be active.
fix
Explicitly enable the rule if desired: "pinia/prefer-single-store-per-file": "warn".
affects: >=0.1.10
breakingRequires ESLint >= 8.0.0 and Node >= 18. Older ESLint versions are not supported.
fix
Upgrade ESLint to 8.0.0 or higher, and Node to 18+.
affects: >=0.4.0
gotchaUsing storeToRefs inside a store definition is flagged by rule no-store-to-refs-in-store, which is in the recommended set.
fix
Remove storeToRefs calls from inside defineStore; use the store's reactive properties directly.
affects: >=0.4.0
Errors
Common errors & fixes
Error: Failed to load plugin 'pinia' declared in 'plugins': Cannot find module 'eslint-plugin-pinia'
Missing npm install of eslint-plugin-pinia or incorrect plugin name in config.
fix
Run: npm install eslint-plugin-pinia --save-dev and ensure plugin name is 'pinia' (without 'eslint-plugin-') in legacy config.
TypeError: Cannot read properties of undefined (reading 'configs')
Trying to access pinia.configs after require() in CJS, but package is ESM-only.
fix
Use dynamic import: const pinia = await import('eslint-plugin-pinia'); or switch to ESM.
ESLint configuration error: Cannot read properties of undefined (reading 'recommended')
Using pinia.configs['recommended'] in flat config; should be 'recommended-flat'.
fix
Replace pinia.configs['recommended'] with pinia.configs['recommended-flat'].
Parsing error: 'defineStore' is not defined
ESLint rule requires that defineStore is imported from 'pinia', but it's missing.
fix
Add import { defineStore } from 'pinia' to your store file.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
eslintrequiredPeer dependency: required to run the plugin
@typescript-eslint/utilsoptionalPeer dependency: used for TypeScript AST utilities
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-pinia — npm install eslint-plugin-pinia · libregistry