|
| 1 | +# ESLint |
| 2 | + |
| 3 | +This is an ESLint plugin for `vue-jsx-vapor` to automatically fix code. |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +```sh |
| 8 | +pnpm add @vue-jsx-vapor/eslint |
| 9 | +``` |
| 10 | + |
| 11 | +## Setup |
| 12 | + |
| 13 | +```ts |
| 14 | +// eslint.config.ts |
| 15 | +import vueJsxVapor from '@vue-jsx-vapor/eslint' |
| 16 | + |
| 17 | +export default [ |
| 18 | + vueJsxVapor() |
| 19 | +] |
| 20 | +``` |
| 21 | + |
| 22 | +## define-style |
| 23 | + |
| 24 | +Use `prettier` to format styles in the defineStyle macro. |
| 25 | + |
| 26 | +```ts twoslash |
| 27 | +import vueJsxVapor from '@vue-jsx-vapor/eslint' |
| 28 | + |
| 29 | +export default [ |
| 30 | + vueJsxVapor({ |
| 31 | + rules: { |
| 32 | + 'vue-jsx-vapor/define-style': ['error', { tabWidth: 2 }] |
| 33 | + } |
| 34 | + }) |
| 35 | +] |
| 36 | +``` |
| 37 | + |
| 38 | +## jsx-sort-props |
| 39 | + |
| 40 | +This is a modified version of [@stylistic/jsx/jsx-sort-props](https://eslint.style/rules/jsx/jsx-sort-props), supporting custom reservedFirst and reservedLast options. |
| 41 | + |
| 42 | +```ts twoslash |
| 43 | +import vueJsxVapor from '@vue-jsx-vapor/eslint' |
| 44 | + |
| 45 | +export default [ |
| 46 | + vueJsxVapor({ |
| 47 | + rules: { |
| 48 | + 'vue-jsx-vapor/jsx-sort-props': ['error', { |
| 49 | + reservedFirst: ['v-if', 'v-for'], |
| 50 | + reservedLast: ['v-slot'], |
| 51 | + }] |
| 52 | + } |
| 53 | + }) |
| 54 | +] |
| 55 | +``` |
| 56 | + |
| 57 | +### `reservedFirst` |
| 58 | + |
| 59 | +Defaults to `['v-if', 'v-else-if', 'v-else', 'v-for', 'key', 'ref', 'v-model']` |
| 60 | + |
| 61 | +If given as an array, the array's values will override the default list of reserved props. |
| 62 | +These props will respect the order specified in the array: |
| 63 | + |
| 64 | +```jsx |
| 65 | +// before |
| 66 | +const Before = <App a v-for={i in list} v-if={list} b /> |
| 67 | + |
| 68 | +// after |
| 69 | +const After = <App v-if={list} v-for={i in list} a b /> |
| 70 | +``` |
| 71 | + |
| 72 | +### `reservedLast` |
| 73 | + |
| 74 | +Defaults to `['v-text', 'v-html', 'v-slots', 'v-slot']` |
| 75 | + |
| 76 | +This can be an array option. These props must be listed after all other props. |
| 77 | +These will respect the order specified in the array: |
| 78 | + |
| 79 | +```jsx |
| 80 | +// before |
| 81 | +const Before = <App v-slot={{ foo }} onClick={onClick} /> |
| 82 | + |
| 83 | +// after |
| 84 | +const After = <App onClick={onClick} v-slot={{ foo }} /> |
| 85 | +``` |
0 commit comments