From d11d271837bd1fad99919024acbd9dc824e18fb1 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 28 Mar 2022 13:08:54 +0800 Subject: [PATCH] fix(`check-types`): for `jsdoc` mode, avoid objecting to upper-case; fixes #860 --- README.md | 11 +++++++++++ src/rules/checkTypes.js | 3 +-- test/rules/assertions/checkTypes.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c0df9aca7..a86e0923e 100644 --- a/README.md +++ b/README.md @@ -5883,6 +5883,17 @@ function a () {} */ function a () {} // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"Object":"object","object.<>":"Object<>","object<>":"Object<>"}}} + +/** + * Does something. + * + * @param {Object} spec - Foo. + */ +function foo(spec) { + return spec; +} + +foo() ```` diff --git a/src/rules/checkTypes.js b/src/rules/checkTypes.js index 39aa9d42f..04483bb31 100644 --- a/src/rules/checkTypes.js +++ b/src/rules/checkTypes.js @@ -196,8 +196,7 @@ export default iterateJsdoc(({ let changedPreferred = preferred; for (const strictNativeType of strictNativeTypes) { if ( - // Todo: Avoid typescript condition if moving to default typescript - strictNativeType === 'object' && mode === 'typescript' && + strictNativeType === 'object' && ( // This is not set to remap with exact type match (e.g., // `object: 'Object'`), so can ignore (including if circular) diff --git a/test/rules/assertions/checkTypes.js b/test/rules/assertions/checkTypes.js index f0d1c031f..e2503809e 100644 --- a/test/rules/assertions/checkTypes.js +++ b/test/rules/assertions/checkTypes.js @@ -3003,5 +3003,19 @@ export default { }, }, }, + { + code: ` + /** + * Does something. + * + * @param {Object} spec - Foo. + */ + function foo(spec) { + return spec; + } + + foo() + `, + }, ], };