Skip to content

Chore: update docs of require-direct-export.md and v-on-function-call.md #844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions docs/rules/require-direct-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,51 @@ description: require the component to be directly exported
# vue/require-direct-export
> require the component to be directly exported

## Rule Details
## :book: Rule Details

This rule aims to require that the component object be directly exported.

:-1: Examples of **incorrect** code:
<eslint-code-block :rules="{'vue/require-direct-export': ['error']}">

```js
```vue
<script>
/* ✓ GOOD */
export default {
name: 'ComponentA',
data() {
return {
state: 1
}
}
}
</script>
```

</eslint-code-block>

<eslint-code-block :rules="{'vue/require-direct-export': ['error']}">

```vue
<script>
const ComponentA = {
name: 'ComponentA',
data() {
return {
state: 1
}
}
name: 'ComponentA',
data() {
return {
state: 1
}
}
}

/* ✗ BAD */
export default ComponentA
</script>
```

:+1: Examples of **correct** code:
</eslint-code-block>

```js
export default {
name: 'ComponentA',
data() {
return {
state: 1
}
}
}
```
## :wrench: Options

Nothing.

## :mag: Implementation

Expand Down
90 changes: 52 additions & 38 deletions docs/rules/v-on-function-call.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,80 @@ description: enforce or forbid parentheses after method calls without arguments

## :book: Rule Details

:-1: Example of **incorrect** code for this rule:

```html
<button v-on:click="closeModal()">
Close
</button>
This rule aims to enforce to bind methods to `v-on` or call methods on `v-on` when without arguments.

<eslint-code-block fix :rules="{'vue/v-on-function-call': ['error']}">

```vue
<template>
<!-- ✓ GOOD -->
<button v-on:click="closeModal">
Close
</button>

<!-- ✗ BAD -->
<button v-on:click="closeModal()">
Close
</button>
</template>
```

:+1: Example of **correct** code for this rule:

```html
<button v-on:click="closeModal">
Close
</button>
```
</eslint-code-block>

## :wrench: Options

Default is set to `never`.

```
'vue/v-on-function-call': [2, 'always'|'never']
```json
{
"vue/v-on-function-call": ["error", "always"|"never"]
}
```

### `"always"` - Always use parentheses in `v-on` directives

:-1: Example of **incorrect** code:
<eslint-code-block fix :rules="{'vue/v-on-function-call': ['error', 'always']}">

```html
<button v-on:click="closeModal">
Close
</button>
```
```vue
<template>
<!-- ✓ GOOD -->
<button v-on:click="closeModal()">
Close
</button>

:+1: Example of **correct** code:

```html
<button v-on:click="closeModal()">
Close
</button>
<!-- ✗ BAD -->
<button v-on:click="closeModal">
Close
</button>
</template>
```

</eslint-code-block>

### `"never"` - Never use parentheses in `v-on` directives for method calls without arguments

:-1: Example of **incorrect** code:

```html
<button v-on:click="closeModal()">
Close
</button>
```
<eslint-code-block fix :rules="{'vue/v-on-function-call': ['error', 'never']}">

:+1: Example of **correct** code:
```vue
<template>
<!-- ✓ GOOD -->
<button v-on:click="closeModal">
Close
</button>
<button v-on:click="closeModal(arg)">
Close
</button>

```html
<button v-on:click="closeModal">
Close
</button>
<!-- ✗ BAD -->
<button v-on:click="closeModal()">
Close
</button>
</template>
```

</eslint-code-block>

## :mag: Implementation

- [Rule source](https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/v-on-function-call.js)
Expand Down