0.4.1 β€’ Published 10 months ago

eslint-plugin-pinia v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

eslint-plugin-pinia

npm test

Eslint plugin that enforces some best practices for writing pinia stores

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-pinia:

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:

// .eslintrc [Legacy Config]
{
  "plugins": ["pinia"]
}
// 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.

// .eslintrc [Legacy Config]
{
  "rules": {
    "pinia/require-export-define-store": [
      "warn"
    ]
  }
}
// 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:

// .eslintrc [Legacy Config]
{
  "extends": ["plugin:pinia/recommended"]
}
// 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:

// .eslintrc [Legacy Config]
{
  "extends": ["plugin:pinia/all"]
}
// eslint.config.js
import pinia from 'eslint-plugin-pinia'

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

Rules

πŸ’Ό 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-storeNever export an initialized named or default store.βœ… βœ…πŸŒ 🌐
no-duplicate-store-idsDisallow duplicate store ids.βœ… βœ…πŸŒ 🌐
no-return-global-propertiesDisallows returning globally provided properties from Pinia stores.βœ… βœ…πŸŒ 🌐
no-store-to-refs-in-storeDisallow use of storeToRefs inside defineStoreβœ… βœ…πŸŒ 🌐
prefer-single-store-per-fileEncourages defining each store in a separate file.🌐 🌐
prefer-use-store-naming-conventionEnforces the convention of naming stores with the prefix use followed by the store name.🌐 🌐 βœ… βœ…
require-setup-store-properties-exportIn setup stores all state properties must be exported.βœ… βœ…πŸŒ 🌐

Credits

Licence

MIT Licence Β© 2024

Contributing

Please check the Contributing file.

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

0.3.0

10 months ago

0.4.1

10 months ago

0.4.0

10 months ago

0.3.1

10 months ago

0.2.0

12 months ago

0.1.13

1 year ago

0.1.11

1 year ago

0.1.12

1 year ago

0.1.10

1 year ago

0.1.8

1 year ago

0.1.9

1 year ago

0.1.7

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago