-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,78 @@ | ||
# eslint-plugin-vue-sort-components | ||
A plugin for ESLint to keep order of component names | ||
# `eslint-plugin-vue-sort-components` | ||
|
||
A plugin for ESLint to keep order of component names. | ||
|
||
## Installation | ||
|
||
```shell | ||
$ npm install --save-dev eslint @jay-es/eslint-plugin-vue-sort-components | ||
``` | ||
|
||
or | ||
|
||
```shell | ||
$ yarn add -dev @jay-es/eslint-plugin-vue-sort-components | ||
``` | ||
|
||
## Usage | ||
|
||
Add `plugin:@jay-es/vue-sort-components/recommended` to the extends section of your `.eslintrc` configuration file. | ||
|
||
```js | ||
{ | ||
"extends": [ | ||
// ... | ||
"plugin:@jay-es/vue-sort-components/recommended" | ||
] | ||
} | ||
``` | ||
|
||
### Custom Configuration | ||
|
||
Add `@jay-es/vue-sort-components` to the plugins section of your `.eslintrc` configuration file. | ||
|
||
```js | ||
{ | ||
"plugins": ["@jay-es/vue-sort-components"] | ||
} | ||
``` | ||
|
||
Then configure the rule under the rules section. | ||
|
||
```js | ||
{ | ||
"rules": { | ||
"@jay-es/vue-sort-components/vue-sort-components": "error" | ||
} | ||
} | ||
``` | ||
|
||
## Rule Details | ||
|
||
This rule checks property definitions of object expressions named `components` and verifies that all keys are sorted alphabetically. | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
export default defineComponent({ | ||
components: { Foo, Bar, Baz }, | ||
}); | ||
|
||
// not only in Vue-specific context | ||
const myObject = { | ||
components: { Foo, Bar, Baz }, | ||
}; | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
export default defineComponent({ | ||
components: { Bar, Baz, Foo }, | ||
}); | ||
|
||
// not only in Vue-specific context | ||
const myObject = { | ||
components: { Bar, Baz, Foo }, | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters