Skip to content

flat/recommended-typescript should default "no-types" to "off" in JS files #1253

Closed
@runarberg

Description

@runarberg

Motivation

I’m writing typescript in JS using JSDoc. When I finished my initial setup and was ready to push I got a syntax error in my jsdoc/valid-types because I was using template literal types. So I switched my mode from jsdoc to typescript like I though I was supposed to and reran the linter. However, I accidentally (out of habit) reran it with --fix which automatically stripped all my type definitions because of the no-types rule.

Current behavior

The jsdoc/no-types rule automatically marks all types as non-passing regardless of whether they are in a .ts or a .js file. This is a dangerous behavior when they are auto-included in the latter case since the @type is the only way to annotate types in .js files

Desired behavior

The flat config for flat/recommended-typescript should have something like a:

{
  files: [**/*.js],
  rules: {
    "jsdoc/no-types": "off",
  },
},

To prevent this rule from destroying all your type definitions.

Alternatives considered

You should at least warn users heavily in the docs what switching modes can do to your code.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions