Skip to content

In typescript mode, only allow 'object' #800

Closed
@thernstig

Description

@thernstig

Motivation

TypeScript Do's and Dont's (https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types) says to never use Object (capital O). So when in typescript mode, only ever object should be allowed as default, and not Object.

The reason is that a ton of users in our project always incorrectly uses Object in JSDoc, when it pretty much always should be object since we use typescript mode, which causes a lot of unnecessary code review comments.

Current behavior

When eslint-plugin-jsdoc is set to "mode": "typescript", then both Object and object is allowed. See https://github.com/gajus/eslint-plugin-jsdoc#check-types.

Desired behavior

When "mode": "typescript" is set, only object should be allowed by default.

Optional: Also object<>, object.<>, Object<> and Object.<> should be disallowed. One can use {s: string, n: number} instead when in typescript mode.

Alternatives considered

I could define this setting:

      "preferredTypes": {
        "Object": "object",
        "Object<>": false,
        "Object.<>": false,
        "object<>": false,
        "object.<>": false
      },

But the problem with that is that pretty much anyone using typescript mode would have to use that setting. It'd be much better to change the default, as that is an absolute "do and don't" to follow.

Those who want to allow Object or Object<> etc. can already do that via preferredTypes.

Slightly related #709.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions