Skip to content

Commit 9344af8

Browse files
authored
Check symbols before GOOD/BAD comments in docs (#1880)
1 parent 309cace commit 9344af8

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

Diff for: docs/rules/no-restricted-class.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ in the rule configuration.
3535
<div :class="'forbidden'" />
3636
<div :class="'forbidden ' + someString" />
3737
<div :class="[someString, 'forbidden']" />
38-
<!-- GOOD -->
38+
<!-- GOOD -->
3939
<div class="allowed-class" />
4040
</template>
4141

Diff for: docs/rules/no-restricted-custom-event.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This rule takes a list of strings, where each string is a custom event name or p
3131
<template>
3232
<!-- ✗ BAD -->
3333
<input @input="$emit('input', $event.target.value)">
34-
<!-- GOOD -->
34+
<!-- GOOD -->
3535
<input @input="$emit('update:value', $event.target.value)">
3636
</template>
3737
<script>

Diff for: docs/rules/no-use-computed-property-like-method.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ export default {
320320
this.computedReturnPropsFunction
321321
this.computedReturnPropsFunction()
322322
/* ✗ BAD */
323-
/* Nope. everything is GOOD!! */
323+
/* Nope. everything is good!! */
324324
}
325325
}
326326
}

Diff for: tools/update-docs.js

+20
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,25 @@ ${
223223

224224
return this
225225
}
226+
227+
checkGoodBadSymbols() {
228+
const lines = this.content.split('\n')
229+
for (const [lineNumber, line] of lines.entries()) {
230+
const lineNumberFilePath = `${this.filePath}:${lineNumber + 1}`
231+
232+
if (line.includes('GOOD') && !line.includes('✓ GOOD')) {
233+
throw new Error(
234+
`Expected '✓ GOOD' instead of '${line}' in '${lineNumberFilePath}'`
235+
)
236+
}
237+
238+
if (line.includes('BAD') && !line.includes('✗ BAD')) {
239+
throw new Error(
240+
`Expected '✗ BAD' instead of '${line}' in '${lineNumberFilePath}'`
241+
)
242+
}
243+
}
244+
}
226245
}
227246

228247
for (const rule of rules) {
@@ -234,4 +253,5 @@ for (const rule of rules) {
234253
.adjustCodeBlocks()
235254
.write()
236255
.checkHeadings()
256+
.checkGoodBadSymbols()
237257
}

0 commit comments

Comments
 (0)