Skip to content

Commit fa6ad5c

Browse files
authored
Fixed some rule documents. (#1244)
1 parent 874589e commit fa6ad5c

File tree

4 files changed

+31
-26
lines changed

4 files changed

+31
-26
lines changed

docs/.vuepress/components/eslint-code-block.vue

+11-14
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
},
3333
rules: {
3434
type: Object,
35-
default () {
35+
default() {
3636
return {}
3737
}
3838
},
@@ -46,7 +46,7 @@ export default {
4646
}
4747
},
4848
49-
data () {
49+
data() {
5050
return {
5151
linter: null,
5252
preprocess: processors['.vue'].preprocess,
@@ -59,7 +59,7 @@ export default {
5959
},
6060
6161
computed: {
62-
config () {
62+
config() {
6363
return {
6464
globals: {
6565
// ES2015 globals
@@ -98,33 +98,30 @@ export default {
9898
}
9999
},
100100
101-
code () {
101+
code() {
102102
return `${this.computeCodeFromSlot(this.$slots.default).trim()}\n`
103103
},
104104
105-
height () {
105+
height() {
106106
const lines = this.code.split('\n').length
107107
return `${Math.max(120, 19 * lines)}px`
108108
}
109109
},
110110
111111
methods: {
112-
computeCodeFromSlot (nodes) {
112+
computeCodeFromSlot(nodes) {
113113
if (!Array.isArray(nodes)) {
114114
return ''
115115
}
116-
return nodes.map(node =>
117-
node.text || this.computeCodeFromSlot(node.children)
118-
).join('')
116+
return nodes
117+
.map((node) => node.text || this.computeCodeFromSlot(node.children))
118+
.join('')
119119
}
120120
},
121121
122-
async mounted () {
122+
async mounted() {
123123
// Load linter.
124-
const [
125-
{ default: Linter },
126-
{ parseForESLint }
127-
] = await Promise.all([
124+
const [{ default: Linter }, { parseForESLint }] = await Promise.all([
128125
import('eslint4b/dist/linter'),
129126
import('espree').then(() => import('vue-eslint-parser'))
130127
])

docs/rules/no-arrow-functions-in-watch.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default {
4040
/* ... */
4141
}
4242
],
43-
'e.f': function (val, oldVal) { /* ... */ }
43+
'e.f': function (val, oldVal) { /* ... */ },
4444
4545
/* ✗ BAD */
4646
foo: (val, oldVal) => {

docs/rules/no-deprecated-events-api.md

+8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ export default {
2626
this.$emit('start')
2727
}
2828
}
29+
</script>
30+
```
31+
32+
</eslint-code-block>
2933

34+
<eslint-code-block :rules="{'vue/no-deprecated-events-api': ['error']}">
35+
36+
```vue
37+
<script>
3038
/* ✓ GOOD */
3139
import mitt from 'mitt'
3240
const emitter = mitt()

docs/rules/no-template-target-blank.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ This rule disallows using `target="_blank"` attribute without `rel="noopener nor
1616
```vue
1717
<template>
1818
<!-- ✓ Good -->
19-
<a link="http://example.com" target="_blank" rel="noopener noreferrer">link</a>
19+
<a href="http://example.com" target="_blank" rel="noopener noreferrer">link</a>
2020
2121
<!-- ✗ BAD -->
22-
<a link="http://example.com" target="_blank" >link</a>
22+
<a href="http://example.com" target="_blank" >link</a>
2323
</temlate>
2424
```
2525

@@ -46,10 +46,10 @@ This rule disallows using `target="_blank"` attribute without `rel="noopener nor
4646
```vue
4747
<template>
4848
<!-- ✓ Good -->
49-
<a link="http://example.com" target="_blank" rel="noopener noreferrer">link</a>
49+
<a href="http://example.com" target="_blank" rel="noopener noreferrer">link</a>
5050
5151
<!-- ✗ BAD -->
52-
<a link="http://example.com" target="_blank" rel="noopener">link</a>
52+
<a href="http://example.com" target="_blank" rel="noopener">link</a>
5353
</temlate>
5454
```
5555

@@ -62,26 +62,26 @@ This rule disallows using `target="_blank"` attribute without `rel="noopener nor
6262
```vue
6363
<template>
6464
<!-- ✓ Good -->
65-
<a link="http://example.com" target="_blank" rel="noopener">link</a>
65+
<a href="http://example.com" target="_blank" rel="noopener">link</a>
6666
6767
<!-- ✗ BAD -->
68-
<a link="http://example.com" target="_blank" >link</a>
68+
<a href="http://example.com" target="_blank" >link</a>
6969
</temlate>
7070
```
7171

7272
</eslint-code-block>
7373

7474
### `{ "enforceDynamicLinks": "always" }` (default)
7575

76-
<eslint-code-block :rules="{'vue/no-template-target-blank': ['error', { enforceDynamicLinks: 'never' }]}">
76+
<eslint-code-block :rules="{'vue/no-template-target-blank': ['error', { enforceDynamicLinks: 'always' }]}">
7777

7878
```vue
7979
<template>
8080
<!-- ✓ Good -->
81-
<a :link="link" target="_blank" rel="noopener noreferrer">link</a>
81+
<a :href="link" target="_blank" rel="noopener noreferrer">link</a>
8282
8383
<!-- ✗ BAD -->
84-
<a :link="link" target="_blank">link</a>
84+
<a :href="link" target="_blank">link</a>
8585
</temlate>
8686
```
8787

@@ -94,10 +94,10 @@ This rule disallows using `target="_blank"` attribute without `rel="noopener nor
9494
```vue
9595
<template>
9696
<!-- ✓ Good -->
97-
<a :link="link" target="_blank">link</a>
97+
<a :href="link" target="_blank">link</a>
9898
9999
<!-- ✗ BAD -->
100-
<a link="http://example.com" target="_blank" >link</a>
100+
<a href="http://example.com" target="_blank" >link</a>
101101
</temlate>
102102
```
103103

0 commit comments

Comments
 (0)