gajus / eslint-plugin-jsdoc

JSDoc specific linting rules for ESLint.
Other
1.09k stars 157 forks source link

Add rule to lint for spacing of type parameters #1143

Open ericcornelissen opened 1 year ago

ericcornelissen commented 1 year ago

Motivation

My motivation for this rule is to enforce consistent spacing for type unions in type parameter, specifically to always have spaces surrounding the |. E.g. string | number, not string|number nor string |number nor string| number. (Obviously, alternative spacing preferences should also be supported).

Current behavior

As far as I can tell this is currently not supported at all.

I also believe this is not within the scope of:

NOTE 2: If this is a feature specifically related to the parsing of types, e.g., supporting some-new+type-syntax (within curly brackets) in:

/**
 * @param {some-new+type-syntax} myName
 */

...then please file instead at https://github.com/simonseyock/jsdoc-type-pratt-parser/issues/

but please let me know if it is and I'll file an issue there

Desired behavior

A new rule to lint for spacing (or formatting more broadly) of type parameters.

I don't believe this would fit in with any of the existing rules, hence I'm suggesting a new rule. Other than that I don't have any strong opinions on it being a new rule.

Alternatives considered

I considered looking up a separate/alternative ESLint plugin for this, but I feel like this plugin is well suited for this.

brettz9 commented 1 month ago

Blocked by https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/134