A for-fun plugin that checks if multiline comments are in a certain format (haiku, iambic pentameter, etc.)
This projects uses a variation on the syllable-counting function in this stackoverflow thread. It turns out that the english language is complicated and counting syllables is hard, so it doesn't always count the correct number of syllables. It gets close enough for this to be pretty fun though.
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-comment-syllables
:
npm install eslint-plugin-comment-syllables --save-dev
Add comment-syllables
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["comment-syllables"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"comment-syllables/haiku-comments": 2
}
}
comment-syllables/haiku-comments
: checks that multiline comments using/* */
syntax are haikus- checks that multiline comments are 3 lines long
- checks that the first line has 5 syllables
- checks that the second line has 7 syllables
- checks that the third line has 5 syllables