Skip to content

Commit 34e5910

Browse files
authored
fix(examples configs): disable @typescript-eslint/no-unsed-vars (#1507)
Also: - docs(processor): more on typescript usage
1 parent d137021 commit 34e5910

File tree

7 files changed

+26
-6
lines changed

7 files changed

+26
-6
lines changed

.README/processors.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ For defaults, a couple rules are enabled which are usually useful:
9797

9898
```js
9999
import {getJsdocProcessorPlugin} from 'eslint-plugin-jsdoc';
100-
import {
100+
import ts, {
101101
parser as typescriptEslintParser,
102102
} from 'typescript-eslint';
103103

@@ -129,8 +129,10 @@ export default [
129129
},
130130
processor: 'examples/examples'
131131
},
132+
// Apply your TypeScript config
133+
...ts.configs.recommended,
132134
{
133-
// Target the blocks within TypeScript
135+
// Target the @example blocks within TypeScript
134136
files: [
135137
// `**/*.ts` could also work if you want to share this config
136138
// with other non-@example TypeScript
@@ -144,8 +146,13 @@ export default [
144146
rules: {
145147
// Add the rules you want to apply to @example here
146148
'no-extra-semi': 'error',
149+
147150
// disable problematic rules here, e.g.,
148151
// ...jsdoc.configs.examples[1].rules
152+
153+
// Due to https://github.com/gajus/eslint-plugin-jsdoc/issues/1377 ,
154+
// `typescript-eslint` type-checked rules must currently be disbaled
155+
...ts.configs.disableTypeChecked.rules
149156
}
150157
}
151158
];

.README/rules/check-examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ by decreasing precedence:
146146
use extra lines within examples just for easier illustration
147147
purposes.
148148
* `no-undef` - Many variables in examples will be `undefined`.
149-
* `no-unused-vars` - It is common to define variables for clarity without
149+
* `no-unused-vars` (and `@typescript-eslint/no-unused-vars`) - It is common to define variables for clarity without
150150
always using them within examples.
151151
* `padded-blocks` (and `@stylistic/padded-blocks`) - It can generally look
152152
nicer to pad a little even if one's code follows more stringency as far

docs/processors.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ For defaults, a couple rules are enabled which are usually useful:
101101

102102
```js
103103
import {getJsdocProcessorPlugin} from 'eslint-plugin-jsdoc';
104-
import {
104+
import ts, {
105105
parser as typescriptEslintParser,
106106
} from 'typescript-eslint';
107107

@@ -133,8 +133,10 @@ export default [
133133
},
134134
processor: 'examples/examples'
135135
},
136+
// Apply your TypeScript config
137+
...ts.configs.recommended,
136138
{
137-
// Target the blocks within TypeScript
139+
// Target the @example blocks within TypeScript
138140
files: [
139141
// `**/*.ts` could also work if you want to share this config
140142
// with other non-@example TypeScript
@@ -148,8 +150,13 @@ export default [
148150
rules: {
149151
// Add the rules you want to apply to @example here
150152
'no-extra-semi': 'error',
153+
151154
// disable problematic rules here, e.g.,
152155
// ...jsdoc.configs.examples[1].rules
156+
157+
// Due to https://github.com/gajus/eslint-plugin-jsdoc/issues/1377 ,
158+
// `typescript-eslint` type-checked rules must currently be disbaled
159+
...ts.configs.disableTypeChecked.rules
153160
}
154161
}
155162
];

docs/rules/check-examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ by decreasing precedence:
173173
use extra lines within examples just for easier illustration
174174
purposes.
175175
* `no-undef` - Many variables in examples will be `undefined`.
176-
* `no-unused-vars` - It is common to define variables for clarity without
176+
* `no-unused-vars` (and `@typescript-eslint/no-unused-vars`) - It is common to define variables for clarity without
177177
always using them within examples.
178178
* `padded-blocks` (and `@stylistic/padded-blocks`) - It can generally look
179179
nicer to pad a little even if one's code follows more stringency as far

src/index-cjs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
563563
// Can generally look nicer to pad a little even if code imposes more stringency
564564
'@stylistic/padded-blocks': 0,
565565

566+
'@typescript-eslint/no-unused-vars': 0,
567+
566568
// "always" newline rule at end unlikely in sample code
567569
'eol-last': 0,
568570

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
569569
// Can generally look nicer to pad a little even if code imposes more stringency
570570
'@stylistic/padded-blocks': 0,
571571

572+
'@typescript-eslint/no-unused-vars': 0,
573+
572574
// "always" newline rule at end unlikely in sample code
573575
'eol-last': 0,
574576

src/rules/checkExamples.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ const defaultMdRules = {
4747
// Can generally look nicer to pad a little even if code imposes more stringency
4848
'@stylistic/padded-blocks': 0,
4949

50+
'@typescript-eslint/no-unused-vars': 0,
51+
5052
// "always" newline rule at end unlikely in sample code
5153
'eol-last': 0,
5254

0 commit comments

Comments
 (0)