Skip to content

Commit

Permalink
feat(check-examples): add no-multiple-empty-lines by default
Browse files Browse the repository at this point in the history
With initial newlines now being considered as part of the example code, the rule
may be problematic for projects which use an initial newline just to start an example
(and projects may wish to use extra lines within examples just for easier illustration
purposes).
  • Loading branch information
brettz9 committed Dec 1, 2019
1 parent 3b5e301 commit 67df3dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .README/rules/check-examples.md
Expand Up @@ -107,6 +107,10 @@ decreasing precedence:
to be desired in sample code as with the code file convention.
* `no-console` - This rule is unlikely to have inadvertent temporary debugging
within examples.
* `no-multiple-empty-lines` - This rule may be problematic for projects which
use an initial newline just to start an example. Also, projects may wish to
use extra lines within examples just for easier illustration
purposes.
* `no-undef` - Many variables in examples will be `undefined`.
* `no-unused-vars` - It is common to define variables for clarity without always
using them within examples.
Expand Down
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -751,6 +751,10 @@ decreasing precedence:
to be desired in sample code as with the code file convention.
* `no-console` - This rule is unlikely to have inadvertent temporary debugging
within examples.
* `no-multiple-empty-lines` - This rule may be problematic for projects which
use an initial newline just to start an example. Also, projects may wish to
use extra lines within examples just for easier illustration
purposes.
* `no-undef` - Many variables in examples will be `undefined`.
* `no-unused-vars` - It is common to define variables for clarity without always
using them within examples.
Expand Down Expand Up @@ -922,7 +926,7 @@ function quux2 () {
function quux2 () {

}
// Message: @example error (no-multiple-empty-lines): Too many blank lines at the beginning of file. Max of 0 allowed.
// Message: @example warning (id-length): Identifier name 'i' is too short (< 2).

/**
* @example const i = 5;
Expand Down
4 changes: 4 additions & 0 deletions src/rules/checkExamples.js
Expand Up @@ -69,6 +69,10 @@ export default iterateJsdoc(({
// Unlikely to have inadvertent debugging within examples
'no-console': 0,

// Often wish to start `@example` code after newline; also may use
// empty lines for spacing
'no-multiple-empty-lines': 0,

// Many variables in examples will be `undefined`
'no-undef': 0,

Expand Down
4 changes: 0 additions & 4 deletions test/rules/assertions/checkExamples.js
Expand Up @@ -376,10 +376,6 @@ export default {
}
`,
errors: [
{
line: 3,
message: '@example error (no-multiple-empty-lines): Too many blank lines at the beginning of file. Max of 0 allowed.',
},
{
line: 4,
message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).',
Expand Down

0 comments on commit 67df3dd

Please sign in to comment.