{"id":19872,"library":"eslint-plugin-pinia","title":"ESLint Plugin Pinia","description":"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.","status":"active","version":"0.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/lisilinhart/eslint-plugin-pinia","tags":["javascript","eslint","eslint-plugin","eslint-config","vue","vuejs","pinia","piniajs","rules","typescript"],"install":[{"cmd":"npm install eslint-plugin-pinia","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-pinia","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-pinia","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: required to run the plugin","package":"eslint","optional":false},{"reason":"Peer dependency: used for TypeScript AST utilities","package":"@typescript-eslint/utils","optional":true}],"imports":[{"note":"ESM only; package has no default export in CJS. Use import for both flat and legacy configs.","wrong":"const pinia = require('eslint-plugin-pinia')","symbol":"default import (plugin object)","correct":"import pinia from 'eslint-plugin-pinia'"},{"note":"In flat config, use 'recommended-flat' not 'recommended'. The 'recommended' key is for legacy .eslintrc.","wrong":"pinia.configs[\"recommended\"]","symbol":"recommended-flat config","correct":"pinia.configs[\"recommended-flat\"]"},{"note":"In flat config, use 'all-flat'. The 'all' key is for legacy .eslintrc.","wrong":"pinia.configs[\"all\"]","symbol":"all-flat config","correct":"pinia.configs[\"all-flat\"]"}],"quickstart":{"code":"import pinia from 'eslint-plugin-pinia';\n\nexport default [\n  {\n    plugins: {\n      pinia\n    },\n    rules: {\n      \"pinia/no-duplicate-store-ids\": \"error\",\n      \"pinia/no-store-to-refs-in-store\": \"error\"\n    }\n  }\n];\n\n// Also use the recommended flat config:\nexport default [\n  pinia.configs[\"recommended-flat\"]\n];","lang":"typescript","description":"Shows how to import and configure the plugin in ESLint flat config, including rules and recommended preset."},"warnings":[{"fix":"Use pinia.configs[\"recommended-flat\"] instead of pinia.configs[\"recommended\"].","message":"Flat config users must use 'recommended-flat' or 'all-flat' config keys, not 'recommended' or 'all'.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Consider migrating to flat config (eslint.config.js) with pinia.configs[\"recommended-flat\"].","message":"Legacy .eslintrc format (like 'extends': ['plugin:pinia/recommended']) is deprecated but still supported.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Explicitly enable the rule if desired: \"pinia/prefer-single-store-per-file\": \"warn\".","message":"The rule 'prefer-single-store-per-file' is disabled by default, but users may expect it to be active.","severity":"gotcha","affected_versions":">=0.1.10"},{"fix":"Upgrade ESLint to 8.0.0 or higher, and Node to 18+.","message":"Requires ESLint >= 8.0.0 and Node >= 18. Older ESLint versions are not supported.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Remove storeToRefs calls from inside defineStore; use the store's reactive properties directly.","message":"Using storeToRefs inside a store definition is flagged by rule no-store-to-refs-in-store, which is in the recommended set.","severity":"gotcha","affected_versions":">=0.4.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install eslint-plugin-pinia --save-dev and ensure plugin name is 'pinia' (without 'eslint-plugin-') in legacy config.","cause":"Missing npm install of eslint-plugin-pinia or incorrect plugin name in config.","error":"Error: Failed to load plugin 'pinia' declared in 'plugins': Cannot find module 'eslint-plugin-pinia'"},{"fix":"Use dynamic import: const pinia = await import('eslint-plugin-pinia'); or switch to ESM.","cause":"Trying to access pinia.configs after require() in CJS, but package is ESM-only.","error":"TypeError: Cannot read properties of undefined (reading 'configs')"},{"fix":"Replace pinia.configs['recommended'] with pinia.configs['recommended-flat'].","cause":"Using pinia.configs['recommended'] in flat config; should be 'recommended-flat'.","error":"ESLint configuration error: Cannot read properties of undefined (reading 'recommended')"},{"fix":"Add import { defineStore } from 'pinia' to your store file.","cause":"ESLint rule requires that defineStore is imported from 'pinia', but it's missing.","error":"Parsing error: 'defineStore' is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}