Appearance
ESLint Plugin
Dolphin Components ships a custom ESLint plugin (dolphin-eslint-plugin) that enforces project-specific coding standards. The plugin is distributed as part of the dolphin-components package and can be integrated directly into your ESLint flat config.
Table of Contents
Installation
The ESLint plugin is included in the dolphin-components package. No additional installation is required beyond installing the main package.
Peer Dependency: ESLint v9+ must be installed in your project.
sh
npm install eslint@^9 dolphin-componentsConfiguration
Import and add the plugin's recommended config to your ESLint flat config file.
eslint.config.ts
ts
import dolphinEslint from "dolphin-components/eslint";
const config = [
// ... your other configs
// Dolphin ESLint Plugin — add this before other rule sets
dolphinEslint.configs.recommended,
// ... rest of your configs
];
export default config;Full Example
For a complete configuration example including TypeScript, Vue, and Prettier, see the Configuration Guide.
Rules
The recommended config enables the following rules:
| Rule | Severity | Description |
|---|---|---|
dolphin/no-duplicate-pinia-store-ids | error | Prevents duplicate Pinia store IDs across files. |
Rule: no-duplicate-pinia-store-ids
Purpose
Catches duplicate Pinia store defineStore() IDs at lint time rather than at runtime. Duplicate store IDs cause silent data sharing bugs that are extremely difficult to debug.
What It Catches
ts
// ❌ ERROR — store ID "users" is already used in another file
export const useUserStore = defineStore("users", () => {
// ...
});
// In another file:
export const useAdminStore = defineStore("users", () => {
// This silently shares state with useUserStore!
});Correct Usage
ts
// ✅ File: stores/userStore.ts
export const useUserStore = defineStore("users", () => {
// ...
});
// ✅ File: stores/adminStore.ts
export const useAdminStore = defineStore("admins", () => {
// Unique ID — no conflict
});Detection Pattern
The rule scans all defineStore() calls in your project and tracks the first argument (the store ID string). If the same string literal appears in multiple defineStore() calls across different files, the rule reports an error on the duplicate.
Supported Patterns
The rule detects defineStore() calls in both the Setup Store and Options Store patterns:
ts
// Setup Store (Composition API)
defineStore("myId", () => { /* ... */ });
// Options Store (Options API)
defineStore("myId", { state: () => ({ /* ... */ }) });Plugin Structure
The ESLint plugin exports the following structure:
typescript
// dolphin-components/eslint
{
plugin: {
meta: { name: "dolphin-eslint-plugin", version: "1.0.0" },
rules: {
"no-duplicate-pinia-store-ids": /* rule implementation */
}
},
configs: {
recommended: {
plugins: { dolphin: /* plugin reference */ },
rules: {
"dolphin/no-duplicate-pinia-store-ids": "error"
}
}
}
}Troubleshooting
Rule not triggering
- Ensure
dolphinEslint.configs.recommendedis included in your ESLint config array. - Verify ESLint v9+ is installed (
eslint --version). - Run
eslint --debugto check if the plugin is loaded.
Import error: Cannot find module
- Make sure you are using the correct import path:
dolphin-components/eslint(notdolphin-components/eslint-rules). - The package exports both CJS (
eslint-rules.cjs) and TypeScript declarations (eslint-rules.d.ts).
False positives in test files
If your test files use defineStore with duplicate IDs intentionally, add an ignore pattern:
ts
{
ignores: ["**/*.test.ts", "**/*.spec.ts"],
}