Skip to content

Commit 71e6ed0

Browse files
committed
refactor: switch default mode to typescript; fixes gajus#834
BREAKING CHANGE: Users must now opt into adding `settings.jsdoc.mode` set to `"jsdoc"` if they want normal JSDoc mode. Note that "typescript" mode does not need to imply use of TypeScript syntax, but rather use of the TypeScript flavor within JSDoc comment blocks which holds the advantages of working in IDEs to draw in third-party module documentation and optionally allowing one to type check one's JavaScript code by TypeScript. There are also tools for building docs with this flavor (e.g., typedoc).
1 parent 60c8d29 commit 71e6ed0

9 files changed

+30
-4
lines changed

docs/rules/check-tag-names.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ function quux (foo) {}
720720
* @template
721721
*/
722722
function quux (foo) {}
723+
// Settings: {"jsdoc":{"mode":"jsdoc"}}
723724
// Message: Invalid JSDoc tag name "internal".
724725

725726
/**

docs/rules/check-types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ function foo(spec) {
11791179
}
11801180

11811181
foo()
1182+
// Settings: {"jsdoc":{"mode":"jsdoc"}}
11821183

11831184
/**
11841185
* @param {object} root

docs/rules/no-undefined-types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ class Foo {
201201
bar (baz) {
202202
}
203203
}
204+
// Settings: {"jsdoc":{"mode":"jsdoc"}}
204205
// Message: The type 'TEMPLATE_TYPE_A' is undefined.
205206

206207
/**

docs/rules/valid-types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ function quux() {
231231
* @this
232232
*/
233233
class Bar {};
234+
// Settings: {"jsdoc":{"mode":"jsdoc"}}
234235
// "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
235236
// Message: Tag @this must have either a type or namepath in "jsdoc" mode.
236237

src/iterateJsdoc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,10 +974,7 @@ const getSettings = (context) => {
974974
exemptDestructuredRootsFromChecks: context.settings.jsdoc?.exemptDestructuredRootsFromChecks,
975975

976976
// Many rules, e.g., `check-tag-names`
977-
mode: context.settings.jsdoc?.mode ??
978-
(context.parserPath?.includes('@typescript-eslint') ||
979-
context.languageOptions?.parser?.meta?.name?.includes('typescript') ?
980-
'typescript' : 'jsdoc'),
977+
mode: context.settings.jsdoc?.mode ?? 'typescript',
981978

982979
// Many rules
983980
contexts: context.settings.jsdoc?.contexts,

test/rules/assertions/checkTagNames.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,11 @@ export default {
858858
message: 'Invalid JSDoc tag name "template".',
859859
},
860860
],
861+
settings: {
862+
jsdoc: {
863+
mode: 'jsdoc',
864+
},
865+
},
861866
},
862867
{
863868
code: `${ONE_CLOSURE_TAGS_COMMENT}\nfunction quux (foo) {}`,

test/rules/assertions/checkTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,6 +3073,11 @@ export default {
30733073
30743074
foo()
30753075
`,
3076+
settings: {
3077+
jsdoc: {
3078+
mode: 'jsdoc',
3079+
},
3080+
},
30763081
},
30773082
{
30783083
code: `

test/rules/assertions/noUndefinedTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ export default {
276276
message: 'The type \'TEMPLATE_TYPE_B\' is undefined.',
277277
},
278278
],
279+
settings: {
280+
jsdoc: {
281+
mode: 'jsdoc',
282+
},
283+
},
279284
},
280285
{
281286
code: `

test/rules/assertions/validTypes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ export default {
251251
allowEmptyNamepaths: false,
252252
},
253253
],
254+
settings: {
255+
jsdoc: {
256+
mode: 'jsdoc',
257+
},
258+
},
254259
},
255260
{
256261
code: `
@@ -887,6 +892,11 @@ export default {
887892
},
888893
],
889894
ignoreReadme: true,
895+
settings: {
896+
jsdoc: {
897+
mode: 'jsdoc',
898+
},
899+
},
890900
},
891901
{
892902
code: `

0 commit comments

Comments
 (0)