Skip to content

Commit

Permalink
Check symbols before GOOD/BAD comments in docs (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
FloEdelmann authored May 7, 2022
1 parent 309cace commit 9344af8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/rules/no-restricted-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ in the rule configuration.
<div :class="'forbidden'" />
<div :class="'forbidden ' + someString" />
<div :class="[someString, 'forbidden']" />
<!-- GOOD -->
<!-- GOOD -->
<div class="allowed-class" />
</template>
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-restricted-custom-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This rule takes a list of strings, where each string is a custom event name or p
<template>
<!-- ✗ BAD -->
<input @input="$emit('input', $event.target.value)">
<!-- GOOD -->
<!-- GOOD -->
<input @input="$emit('update:value', $event.target.value)">
</template>
<script>
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-use-computed-property-like-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export default {
this.computedReturnPropsFunction
this.computedReturnPropsFunction()
/* ✗ BAD */
/* Nope. everything is GOOD!! */
/* Nope. everything is good!! */
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions tools/update-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,25 @@ ${

return this
}

checkGoodBadSymbols() {
const lines = this.content.split('\n')
for (const [lineNumber, line] of lines.entries()) {
const lineNumberFilePath = `${this.filePath}:${lineNumber + 1}`

if (line.includes('GOOD') && !line.includes('✓ GOOD')) {
throw new Error(
`Expected '✓ GOOD' instead of '${line}' in '${lineNumberFilePath}'`
)
}

if (line.includes('BAD') && !line.includes('✗ BAD')) {
throw new Error(
`Expected '✗ BAD' instead of '${line}' in '${lineNumberFilePath}'`
)
}
}
}
}

for (const rule of rules) {
Expand All @@ -234,4 +253,5 @@ for (const rule of rules) {
.adjustCodeBlocks()
.write()
.checkHeadings()
.checkGoodBadSymbols()
}

0 comments on commit 9344af8

Please sign in to comment.