Skip to content

Commit

Permalink
first release
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-es committed Jul 11, 2022
1 parent 8deed40 commit a76d631
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 9 deletions.
80 changes: 78 additions & 2 deletions README.md
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 },
};
```
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ module.exports = {
},
configs: {
recommended: {
plugins: ["vue-sort-components"],
plugins: ["@jay-es/vue-sort-components"],
rules: {
"vue-sort-components/vue-sort-components": "error",
"@jay-es/vue-sort-components/vue-sort-components": "error",
},
},
},
Expand Down
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "eslint-plugin-vue-sort-components",
"version": "1.0.0",
"name": "@jay-es/eslint-plugin-vue-sort-components",
"version": "0.1.0",
"description": "A plugin for ESLint to keep order of component names",
"main": "lib/index.js",
"files": [
"README.md",
"lib"
],
"scripts": {
"prepare": "husky install",
"format": "prettier --check ./**/*.js",
Expand All @@ -14,9 +18,15 @@
"type": "git",
"url": "git+https://github.com/jay-es/eslint-plugin-vue-sort-components.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"keywords": [
"eslint",
"vue",
"sort",
"components",
"order"
],
"author": "jay-es",
"license": "MIT",
"bugs": {
"url": "https://github.com/jay-es/eslint-plugin-vue-sort-components/issues"
},
Expand Down

0 comments on commit a76d631

Please sign in to comment.