Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check-types can't decide on object vs. Object<> #860

Closed
DamienCassou opened this issue Mar 28, 2022 · 3 comments
Closed

check-types can't decide on object vs. Object<> #860

DamienCassou opened this issue Mar 28, 2022 · 3 comments

Comments

@DamienCassou
Copy link

Expected behavior

I'm trying to update to version 38.1.0 but I have an issue with "object" arguments. I expect one of the following to be correct.

Either the lowercase "object":

 * @param {object<string, string>} spec - Foo.

but I get

  20:0  error  Invalid JSDoc @param "spec" type "object"; prefer: "Object<>"  jsdoc/check-types

or the uppercase object:

 * @param {Object<string, string>} spec - Foo.

but I get

  20:0  error  Invalid JSDoc @param "spec" type "Object"; prefer: "object"  jsdoc/check-types

Actual behavior

I'm very happy having to make my jsdoc uniform, but the check-type rule has to decide whether it wants uppercase or lowercase object, it can't be both :-).

ESLint Config

{
  "env": {},
  "globals": {},
  "parser": null,
  "parserOptions": {},
  "plugins": [
    "jsdoc"
  ],
  "rules": {
    "jsdoc/check-types": [
      "error"
    ]
  },
  "settings": {},
  "ignorePatterns": []
}

ESLint sample

/**
 * Does something.
 *
 * @param {object<string,string>} spec - Foo.
 */
function foo(spec) {
    return spec;
}

foo()

Environment

  • Node version: 16.14.2
  • ESLint version: v8.12.0
  • eslint-plugin-jsdoc version: 38.1.0
@gajus
Copy link
Owner

gajus commented Mar 28, 2022

🎉 This issue has been resolved in version 38.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Mar 28, 2022
@brettz9
Copy link
Collaborator

brettz9 commented Mar 28, 2022

Apologies, hadn't caught that plain jsdoc mode had another check still present insisting on object in all cases.

In the new fixed release, it should be upper-case when there is a child type, e.g., Object<string, SomeType>, and lower case when by itself (object). This will ensure better compatibility with TypeScript if you ever switch to that mode.

@DamienCassou
Copy link
Author

@brettz9: There is nothing to apologize for. You are doing a very good job. Thank you so much for fixing this issue so quickly!

crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Mar 31, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | devDependencies | minor | [`38.0.8` -> `38.1.3`](https://renovatebot.com/diffs/npm/eslint-plugin-jsdoc/38.0.8/38.1.3) |

---

### Release Notes

<details>
<summary>gajus/eslint-plugin-jsdoc</summary>

### [`v38.1.3`](https://github.com/gajus/eslint-plugin-jsdoc/releases/v38.1.3)

[Compare Source](gajus/eslint-plugin-jsdoc@v38.1.2...v38.1.3)

##### Bug Fixes

-   **`check-types`, `no-undefined-types`:** safer optional chaining ([63a96ee](gajus/eslint-plugin-jsdoc@63a96ee))

### [`v38.1.2`](https://github.com/gajus/eslint-plugin-jsdoc/releases/v38.1.2)

[Compare Source](gajus/eslint-plugin-jsdoc@v38.1.1...v38.1.2)

##### Bug Fixes

-   **`check-types`:** proper use of optional chaining; fixes [#&#8203;861](gajus/eslint-plugin-jsdoc#861) ([7dbdd9f](gajus/eslint-plugin-jsdoc@7dbdd9f))

### [`v38.1.1`](https://github.com/gajus/eslint-plugin-jsdoc/releases/v38.1.1)

[Compare Source](gajus/eslint-plugin-jsdoc@v38.1.0...v38.1.1)

##### Bug Fixes

-   **`check-types`:** for `jsdoc` mode, avoid objecting to upper-case; fixes [#&#8203;860](gajus/eslint-plugin-jsdoc#860) ([d11d271](gajus/eslint-plugin-jsdoc@d11d271))

### [`v38.1.0`](https://github.com/gajus/eslint-plugin-jsdoc/releases/v38.1.0)

[Compare Source](gajus/eslint-plugin-jsdoc@v38.0.8...v38.1.0)

##### Features

-   unless the user supplies their own `object` type `preferredTypes`, prefer `object` for plain objects and otherwise prefer `Object<>`; fixes [#&#8203;800](gajus/eslint-plugin-jsdoc#800) ([#&#8203;855](gajus/eslint-plugin-jsdoc#855)) ([0f27282](gajus/eslint-plugin-jsdoc@0f27282))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1262
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants