Skip to content

Commit ab14982

Browse files
authored
fix(jsdoc/examples/rules and jsdoc/default-expressions/rules configs): add @Stylistic, @typescript-eslint, and eslint-plulgin-n equivalents to default disabled rules (#1504)
1 parent 76b8406 commit ab14982

File tree

5 files changed

+90
-23
lines changed

5 files changed

+90
-23
lines changed

.README/rules/check-examples.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,37 +135,40 @@ by decreasing precedence:
135135

136136
### Rules Disabled by Default Unless `noDefaultExampleRules` is Set to `true`
137137

138-
* `eol-last` - Insisting that a newline "always" be at the end is less likely
139-
to be desired in sample code as with the code file convention.
138+
* `eol-last` (and `@stylistic/eol-last`) - Insisting that a newline "always"
139+
be at the end is less likely to be desired in sample code as with the code
140+
file convention.
140141
* `no-console` - This rule is unlikely to have inadvertent temporary debugging
141142
within examples.
142-
* `no-multiple-empty-lines` - This rule may be problematic for projects which
143+
* `no-multiple-empty-lines` (and `@stylistic/no-multiple-empty-lines`) - This
144+
rule may be problematic for projects which
143145
use an initial newline just to start an example. Also, projects may wish to
144146
use extra lines within examples just for easier illustration
145147
purposes.
146148
* `no-undef` - Many variables in examples will be `undefined`.
147149
* `no-unused-vars` - It is common to define variables for clarity without
148150
always using them within examples.
149-
* `padded-blocks` - It can generally look nicer to pad a little even if one's
150-
code follows more stringency as far as block padding.
151+
* `padded-blocks` (and `@stylistic/padded-blocks`) - It can generally look
152+
nicer to pad a little even if one's code follows more stringency as far
153+
as block padding.
151154
* `jsdoc/require-file-overview` - Shouldn't check example for jsdoc blocks.
152155
* `jsdoc/require-jsdoc` - Wouldn't expect jsdoc blocks within jsdoc blocks.
153156
* `import/no-unresolved` - One wouldn't generally expect example paths to
154157
resolve relative to the current JavaScript file as one would with real code.
155158
* `import/unambiguous` - Snippets in examples are likely too short to always
156159
include full import/export info.
157-
* `node/no-missing-import` - See `import/no-unresolved`.
158-
* `node/no-missing-require` - See `import/no-unresolved`.
160+
* `node/no-missing-import` (and `n/no-missing-import`) - See `import/no-unresolved`.
161+
* `node/no-missing-require` (and `n/no-missing-require`) - See `import/no-unresolved`.
159162

160163
For `checkDefaults`, `checkParams`, and `checkProperties`, the following
161164
expression-oriented rules will be used by default as well:
162165

163-
* `quotes` - Will insist on "double".
164-
* `semi` - Will insist on "never".
166+
* `quotes` (and `@stylistic/quotes`) - Will insist on "double".
167+
* `semi` (and `@stylistic/semi`) - Will insist on "never".
165168
* `strict` - Disabled.
166169
* `no-empty-function` - Disabled.
167170
* `no-new` - Disabled.
168-
* `no-unused-expressions` - Disabled.
171+
* `no-unused-expressions` (and `@typescript-eslint/no-unused-expressions`) - Disabled.
169172
* `chai-friendly/no-unused-expressions` - Disabled.
170173

171174
### Options for checking other than `@example` (`checkDefaults`, `checkParams`, or `checkProperties`)

docs/rules/check-examples.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,37 +162,40 @@ by decreasing precedence:
162162
<a name="check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
163163
### Rules Disabled by Default Unless <code>noDefaultExampleRules</code> is Set to <code>true</code>
164164

165-
* `eol-last` - Insisting that a newline "always" be at the end is less likely
166-
to be desired in sample code as with the code file convention.
165+
* `eol-last` (and `@stylistic/eol-last`) - Insisting that a newline "always"
166+
be at the end is less likely to be desired in sample code as with the code
167+
file convention.
167168
* `no-console` - This rule is unlikely to have inadvertent temporary debugging
168169
within examples.
169-
* `no-multiple-empty-lines` - This rule may be problematic for projects which
170+
* `no-multiple-empty-lines` (and `@stylistic/no-multiple-empty-lines`) - This
171+
rule may be problematic for projects which
170172
use an initial newline just to start an example. Also, projects may wish to
171173
use extra lines within examples just for easier illustration
172174
purposes.
173175
* `no-undef` - Many variables in examples will be `undefined`.
174176
* `no-unused-vars` - It is common to define variables for clarity without
175177
always using them within examples.
176-
* `padded-blocks` - It can generally look nicer to pad a little even if one's
177-
code follows more stringency as far as block padding.
178+
* `padded-blocks` (and `@stylistic/padded-blocks`) - It can generally look
179+
nicer to pad a little even if one's code follows more stringency as far
180+
as block padding.
178181
* `jsdoc/require-file-overview` - Shouldn't check example for jsdoc blocks.
179182
* `jsdoc/require-jsdoc` - Wouldn't expect jsdoc blocks within jsdoc blocks.
180183
* `import/no-unresolved` - One wouldn't generally expect example paths to
181184
resolve relative to the current JavaScript file as one would with real code.
182185
* `import/unambiguous` - Snippets in examples are likely too short to always
183186
include full import/export info.
184-
* `node/no-missing-import` - See `import/no-unresolved`.
185-
* `node/no-missing-require` - See `import/no-unresolved`.
187+
* `node/no-missing-import` (and `n/no-missing-import`) - See `import/no-unresolved`.
188+
* `node/no-missing-require` (and `n/no-missing-require`) - See `import/no-unresolved`.
186189

187190
For `checkDefaults`, `checkParams`, and `checkProperties`, the following
188191
expression-oriented rules will be used by default as well:
189192

190-
* `quotes` - Will insist on "double".
191-
* `semi` - Will insist on "never".
193+
* `quotes` (and `@stylistic/quotes`) - Will insist on "double".
194+
* `semi` (and `@stylistic/semi`) - Will insist on "never".
192195
* `strict` - Disabled.
193196
* `no-empty-function` - Disabled.
194197
* `no-new` - Disabled.
195-
* `no-unused-expressions` - Disabled.
198+
* `no-unused-expressions` (and `@typescript-eslint/no-unused-expressions`) - Disabled.
196199
* `chai-friendly/no-unused-expressions` - Disabled.
197200

198201
<a name="user-content-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-options-for-checking-other-than-example-checkdefaults-checkparams-or-checkproperties"></a>

src/index-cjs.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,15 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
554554
],
555555
name: 'jsdoc/examples/rules',
556556
rules: {
557+
// "always" newline rule at end unlikely in sample code
558+
'@stylistic/eol-last': 0,
559+
// Often wish to start `@example` code after newline; also may use
560+
// empty lines for spacing
561+
'@stylistic/no-multiple-empty-lines': 0,
562+
563+
// Can generally look nicer to pad a little even if code imposes more stringency
564+
'@stylistic/padded-blocks': 0,
565+
557566
// "always" newline rule at end unlikely in sample code
558567
'eol-last': 0,
559568

@@ -568,6 +577,11 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
568577
// The end of a multiline comment would end the comment the example is in.
569578
'jsdoc/require-jsdoc': 0,
570579

580+
// See import/no-unresolved
581+
'n/no-missing-import': 0,
582+
583+
'n/no-missing-require': 0,
584+
571585
// Unlikely to have inadvertent debugging within examples
572586
'no-console': 0,
573587

@@ -577,7 +591,6 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
577591

578592
// Many variables in examples will be `undefined`
579593
'no-undef': 0,
580-
581594
// Common to define variables for clarity without always using them
582595
'no-unused-vars': 0,
583596

@@ -613,6 +626,13 @@ index.configs['default-expressions'] = /** @type {import('eslint').Linter.Config
613626
name: 'jsdoc/default-expressions/rules',
614627
rules: {
615628
...index.configs.examples[1].rules,
629+
'@stylistic/quotes': [
630+
'error', 'double',
631+
],
632+
'@stylistic/semi': [
633+
'error', 'never',
634+
],
635+
'@typescript-eslint/no-unused-expressions': 0,
616636
'chai-friendly/no-unused-expressions': 0,
617637
'no-empty-function': 0,
618638
'no-new': 0,

src/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,15 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
560560
],
561561
name: 'jsdoc/examples/rules',
562562
rules: {
563+
// "always" newline rule at end unlikely in sample code
564+
'@stylistic/eol-last': 0,
565+
// Often wish to start `@example` code after newline; also may use
566+
// empty lines for spacing
567+
'@stylistic/no-multiple-empty-lines': 0,
568+
569+
// Can generally look nicer to pad a little even if code imposes more stringency
570+
'@stylistic/padded-blocks': 0,
571+
563572
// "always" newline rule at end unlikely in sample code
564573
'eol-last': 0,
565574

@@ -574,6 +583,11 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
574583
// The end of a multiline comment would end the comment the example is in.
575584
'jsdoc/require-jsdoc': 0,
576585

586+
// See import/no-unresolved
587+
'n/no-missing-import': 0,
588+
589+
'n/no-missing-require': 0,
590+
577591
// Unlikely to have inadvertent debugging within examples
578592
'no-console': 0,
579593

@@ -583,7 +597,6 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
583597

584598
// Many variables in examples will be `undefined`
585599
'no-undef': 0,
586-
587600
// Common to define variables for clarity without always using them
588601
'no-unused-vars': 0,
589602

@@ -619,6 +632,13 @@ index.configs['default-expressions'] = /** @type {import('eslint').Linter.Config
619632
name: 'jsdoc/default-expressions/rules',
620633
rules: {
621634
...index.configs.examples[1].rules,
635+
'@stylistic/quotes': [
636+
'error', 'double',
637+
],
638+
'@stylistic/semi': [
639+
'error', 'never',
640+
],
641+
'@typescript-eslint/no-unused-expressions': 0,
622642
'chai-friendly/no-unused-expressions': 0,
623643
'no-empty-function': 0,
624644
'no-new': 0,

src/rules/checkExamples.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ const countChars = (str, ch) => {
3737

3838
/** @type {import('eslint').Linter.RulesRecord} */
3939
const defaultMdRules = {
40+
// "always" newline rule at end unlikely in sample code
41+
'@stylistic/eol-last': 0,
42+
43+
// Often wish to start `@example` code after newline; also may use
44+
// empty lines for spacing
45+
'@stylistic/no-multiple-empty-lines': 0,
46+
47+
// Can generally look nicer to pad a little even if code imposes more stringency
48+
'@stylistic/padded-blocks': 0,
49+
4050
// "always" newline rule at end unlikely in sample code
4151
'eol-last': 0,
4252

@@ -51,13 +61,16 @@ const defaultMdRules = {
5161
// The end of a multiline comment would end the comment the example is in.
5262
'jsdoc/require-jsdoc': 0,
5363

64+
// See import/no-unresolved
65+
'n/no-missing-import': 0,
66+
'n/no-missing-require': 0,
67+
5468
// Unlikely to have inadvertent debugging within examples
5569
'no-console': 0,
5670

5771
// Often wish to start `@example` code after newline; also may use
5872
// empty lines for spacing
5973
'no-multiple-empty-lines': 0,
60-
6174
// Many variables in examples will be `undefined`
6275
'no-undef': 0,
6376

@@ -66,6 +79,7 @@ const defaultMdRules = {
6679

6780
// See import/no-unresolved
6881
'node/no-missing-import': 0,
82+
6983
'node/no-missing-require': 0,
7084

7185
// Can generally look nicer to pad a little even if code imposes more stringency
@@ -75,6 +89,13 @@ const defaultMdRules = {
7589
/** @type {import('eslint').Linter.RulesRecord} */
7690
const defaultExpressionRules = {
7791
...defaultMdRules,
92+
'@stylistic/quotes': [
93+
'error', 'double',
94+
],
95+
'@stylistic/semi': [
96+
'error', 'never',
97+
],
98+
'@typescript-eslint/no-unused-expressions': 'off',
7899
'chai-friendly/no-unused-expressions': 'off',
79100
'no-empty-function': 'off',
80101
'no-new': 'off',

0 commit comments

Comments
 (0)