Skip to content

Commit 67df3dd

Browse files
committed
feat(check-examples): add no-multiple-empty-lines by default
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).
1 parent 3b5e301 commit 67df3dd

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

.README/rules/check-examples.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ decreasing precedence:
107107
to be desired in sample code as with the code file convention.
108108
* `no-console` - This rule is unlikely to have inadvertent temporary debugging
109109
within examples.
110+
* `no-multiple-empty-lines` - This rule may be problematic for projects which
111+
use an initial newline just to start an example. Also, projects may wish to
112+
use extra lines within examples just for easier illustration
113+
purposes.
110114
* `no-undef` - Many variables in examples will be `undefined`.
111115
* `no-unused-vars` - It is common to define variables for clarity without always
112116
using them within examples.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ decreasing precedence:
751751
to be desired in sample code as with the code file convention.
752752
* `no-console` - This rule is unlikely to have inadvertent temporary debugging
753753
within examples.
754+
* `no-multiple-empty-lines` - This rule may be problematic for projects which
755+
use an initial newline just to start an example. Also, projects may wish to
756+
use extra lines within examples just for easier illustration
757+
purposes.
754758
* `no-undef` - Many variables in examples will be `undefined`.
755759
* `no-unused-vars` - It is common to define variables for clarity without always
756760
using them within examples.
@@ -922,7 +926,7 @@ function quux2 () {
922926
function quux2 () {
923927

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

927931
/**
928932
* @example const i = 5;

src/rules/checkExamples.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export default iterateJsdoc(({
6969
// Unlikely to have inadvertent debugging within examples
7070
'no-console': 0,
7171

72+
// Often wish to start `@example` code after newline; also may use
73+
// empty lines for spacing
74+
'no-multiple-empty-lines': 0,
75+
7276
// Many variables in examples will be `undefined`
7377
'no-undef': 0,
7478

test/rules/assertions/checkExamples.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,6 @@ export default {
376376
}
377377
`,
378378
errors: [
379-
{
380-
line: 3,
381-
message: '@example error (no-multiple-empty-lines): Too many blank lines at the beginning of file. Max of 0 allowed.',
382-
},
383379
{
384380
line: 4,
385381
message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).',

0 commit comments

Comments
 (0)