eslint-plugin-vue-setup-order 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +38 -51
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # eslint-plugin-vue-setup-order
2
2
 
3
- [![npm version](https://badge.fury.io/js/eslint-plugin-vue-setup-order.svg)](https://www.npmjs.com/package/eslint-plugin-vue-setup-order)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ ESLint plugin to enforce a consistent order of statements within the Vue 3 `<script setup>` block.
5
4
 
6
- ESLint plugin to enforce consistent order of statements in Vue 3 `<script setup>`.
7
-
8
- ## 📦 Installation
5
+ ## Installation
9
6
 
10
7
  ```bash
11
8
  npm install -D eslint-plugin-vue-setup-order
@@ -15,7 +12,7 @@ pnpm add -D eslint-plugin-vue-setup-order
15
12
  yarn add -D eslint-plugin-vue-setup-order
16
13
  ```
17
14
 
18
- ## 🚀 Usage
15
+ ## Configuration
19
16
 
20
17
  ### ESLint Flat Config (ESLint 9+)
21
18
 
@@ -25,7 +22,7 @@ import vueSetupOrder from 'eslint-plugin-vue-setup-order';
25
22
 
26
23
  export default [
27
24
  vueSetupOrder.configs.flat.recommended,
28
- // or manually:
25
+ // Or manual configuration:
29
26
  {
30
27
  plugins: {
31
28
  'vue-setup-order': vueSetupOrder,
@@ -44,50 +41,50 @@ export default [
44
41
  module.exports = {
45
42
  plugins: ['vue-setup-order'],
46
43
  extends: ['plugin:vue-setup-order/recommended'],
47
- // or manually:
44
+ // Or manual configuration:
48
45
  rules: {
49
46
  'vue-setup-order/order': 'error',
50
47
  },
51
48
  };
52
49
  ```
53
50
 
54
- ## 📋 Expected Order
51
+ ## Default Order
55
52
 
56
- The plugin enforces the following order in `<script setup>`:
53
+ The plugin enforces the following default sequence:
57
54
 
58
- 1. Imports - import statements
59
- 2. Type declarations - type, interface, enum (TypeScript)
60
- 3. Define macros - defineProps, defineEmits, defineOptions, defineSlots, defineExpose, defineModel
61
- 4. Composables - useXxx() calls (useRouter, useStore, custom composables)
62
- 5. Reactive state - ref, reactive, shallowRef, etc.
63
- 6. Computed - computed properties
64
- 7. Watchers - watch, watchEffect
65
- 8. Lifecycle hooks - onMounted, onBeforeMount, etc.
66
- 9. Functions - function declarations and arrow functions
67
- 10. Provide - provide calls
55
+ 1. **Imports**: All `import` statements.
56
+ 2. **Type Declarations**: TypeScript `type`, `interface`, and `enum` declarations.
57
+ 3. **Define Macros**: `defineProps`, `defineEmits`, `defineOptions`, `defineSlots`, `defineExpose`, `defineModel`, and `withDefaults`.
58
+ 4. **Composables**: Function calls following the `useXxx` pattern (e.g., `useRouter`, `useStore`).
59
+ 5. **Reactive State**: Vue reactivity APIs such as `ref`, `reactive`, and `shallowRef`.
60
+ 6. **Computed Properties**: `computed` declarations.
61
+ 7. **Watchers**: `watch` and `watchEffect` calls.
62
+ 8. **Lifecycle Hooks**: `onMounted`, `onBeforeMount`, and other lifecycle functions.
63
+ 9. **Functions**: Regular function declarations and arrow functions.
64
+ 10. **Provide**: `provide` calls.
68
65
 
69
- ## Examples
66
+ ## Examples
70
67
 
71
- ### Incorrect
68
+ ### Incorrect
72
69
 
73
70
  ```vue
74
71
  <script setup>
75
72
  import { ref, computed } from 'vue';
76
73
 
77
74
  function increment() {
78
- // function before ref
75
+ // Error: function declared before reactive state
79
76
  count.value++;
80
77
  }
81
78
 
82
79
  const count = ref(0);
83
80
 
84
- onMounted(() => {}); // lifecycle before computed
81
+ onMounted(() => {}); // Error: lifecycle hook before computed property
85
82
 
86
83
  const doubled = computed(() => count.value * 2);
87
84
  </script>
88
85
  ```
89
86
 
90
- ### Correct
87
+ ### Correct
91
88
 
92
89
  ```vue
93
90
  <script setup lang="ts">
@@ -121,11 +118,11 @@ The plugin enforces the following order in `<script setup>`:
121
118
  </script>
122
119
  ```
123
120
 
124
- ## ⚙️ Options
121
+ ## Options
125
122
 
126
- ### `groupBlankLines`
123
+ ### groupBlankLines
127
124
 
128
- Add blank lines between different categories (default: `true`).
125
+ Ensures blank lines are present between different categories. Defaults to `true`.
129
126
 
130
127
  ```javascript
131
128
  {
@@ -135,20 +132,20 @@ Add blank lines between different categories (default: `true`).
135
132
  }
136
133
  ```
137
134
 
138
- ### `order`
135
+ ### order
139
136
 
140
- Customize the order of categories. You can specify a custom array of category names to enforce your preferred order.
137
+ Allows customization of the category sequence. Provide an array of category names to define your preferred order.
141
138
 
142
139
  **Available categories:**
143
140
 
144
- - `import` - Import statements
145
- - `types` - TypeScript type declarations (type, interface, enum)
146
- - `defineProps`, `defineEmits`, `defineOptions`, `defineSlots`, `defineExpose`, `defineModel`, `withDefaults` - Vue define macros
147
- - `composable` - Composable functions (useXxx)
148
- - `ref`, `reactive`, `computed`, `watch`, `watchEffect` - Vue reactivity APIs
149
- - `onMounted`, `onBeforeMount`, etc. - Lifecycle hooks
150
- - `function` - Function declarations
151
- - `provide` - Provide calls
141
+ * `import`
142
+ * `types` (type, interface, enum)
143
+ * `defineProps`, `defineEmits`, `defineOptions`, `defineSlots`, `defineExpose`, `defineModel`, `withDefaults`
144
+ * `composable` (useXxx)
145
+ * `ref`, `reactive`, `computed`, `watch`, `watchEffect`
146
+ * `onMounted`, `onBeforeMount`, etc.
147
+ * `function`
148
+ * `provide`
152
149
 
153
150
  **Example: Custom order**
154
151
 
@@ -173,24 +170,14 @@ Customize the order of categories. You can specify a custom array of category na
173
170
  }
174
171
  ```
175
172
 
176
- **Example: Functions before reactive state**
177
-
178
- ```javascript
179
- {
180
- 'vue-setup-order/order': ['error', {
181
- order: ['import', 'types', 'defineProps', 'function', 'ref', 'computed']
182
- }]
183
- }
184
- ```
185
-
186
- ## 🔧 Auto-fix
173
+ ## Auto-fix
187
174
 
188
- This rule supports auto-fix! Run ESLint with `--fix` flag:
175
+ This rule supports automatic fixing. Run ESLint with the `--fix` flag to resolve ordering issues:
189
176
 
190
177
  ```bash
191
178
  npx eslint --fix "src/**/*.vue"
192
179
  ```
193
180
 
194
- ## 📄 License
181
+ ## License
195
182
 
196
183
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-vue-setup-order",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "ESLint plugin to enforce consistent order of statements in Vue 3 <script setup>",
5
5
  "keywords": [
6
6
  "eslint",