Skip to content

Commit 41d45ad

Browse files
committed
fix(valid-types, no-undefined-types, check-types): have mode default to typescript when typescript-eslint/parser is on; fixes gajus#593
1 parent 9aa4e3b commit 41d45ad

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

.README/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ how many line breaks to add when a block is missing.
130130

131131
### Mode
132132

133-
- `settings.jsdoc.mode` - Set to `jsdoc` (the default), `typescript`, or `closure`.
133+
- `settings.jsdoc.mode` - Set to `typescript`, `closure`, or `jsdoc` (the
134+
default unless the `@typescript-eslint` parser is in use in which case
135+
`typescript` will be the default).
134136
Note that if you do not wish to use separate `.eslintrc.*` files for a project
135137
containing both JavaScript and TypeScript, you can also use [`overrides`](https://eslint.org/docs/user-guide/configuring). You may also set to `"permissive"` to
136138
try to be as accommodating to any of the styles, but this is not recommended.

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ how many line breaks to add when a block is missing.
188188
<a name="eslint-plugin-jsdoc-settings-mode"></a>
189189
### Mode
190190

191-
- `settings.jsdoc.mode` - Set to `jsdoc` (the default), `typescript`, or `closure`.
191+
- `settings.jsdoc.mode` - Set to `typescript`, `closure`, or `jsdoc` (the
192+
default unless the `@typescript-eslint` parser is in use in which case
193+
`typescript` will be the default).
192194
Note that if you do not wish to use separate `.eslintrc.*` files for a project
193195
containing both JavaScript and TypeScript, you can also use [`overrides`](https://eslint.org/docs/user-guide/configuring). You may also set to `"permissive"` to
194196
try to be as accommodating to any of the styles, but this is not recommended.
@@ -13691,6 +13693,13 @@ function quux () {}
1369113693
function foo(bar) {}
1369213694
// Settings: {"jsdoc":{"mode":"typescript"}}
1369313695
13696+
/**
13697+
* Foo function.
13698+
*
13699+
* @param {[number, string]} bar - The bar array.
13700+
*/
13701+
function foo(bar) {}
13702+
1369413703
/**
1369513704
* Foo function.
1369613705
*

src/iterateJsdoc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ const getSettings = (context) => {
434434
augmentsExtendsReplacesDocs: context.settings.jsdoc?.augmentsExtendsReplacesDocs,
435435

436436
// Many rules, e.g., `check-tag-names`
437-
mode: context.settings.jsdoc?.mode ?? 'jsdoc',
437+
mode: context.settings.jsdoc?.mode ??
438+
(context.parserPath.includes('@typescript-eslint') ? 'typescript' : 'jsdoc'),
438439
};
439440
/* eslint-enable sort-keys-fix/sort-keys-fix */
440441

test/rules/assertions/validTypes.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,17 @@ export default {
742742
},
743743
},
744744
},
745+
{
746+
code: `
747+
/**
748+
* Foo function.
749+
*
750+
* @param {[number, string]} bar - The bar array.
751+
*/
752+
function foo(bar) {}
753+
`,
754+
parser: require.resolve('@typescript-eslint/parser'),
755+
},
745756
{
746757
code: `
747758
/**

0 commit comments

Comments
 (0)