Skip to content

JSDoc/GCC/TypeScript mode #356

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

Closed
13 tasks done
brettz9 opened this issue Jul 23, 2019 · 10 comments
Closed
13 tasks done

JSDoc/GCC/TypeScript mode #356

brettz9 opened this issue Jul 23, 2019 · 10 comments

Comments

@brettz9
Copy link
Collaborator

brettz9 commented Jul 23, 2019

#354 proposes adding a mode setting for allowing different behavior between TypeScript, Closure, and regular jsdoc. This setting could be used for other tweaks:

  • Avoid parseClosureTemplateTag in no-undefined-types except for closure
  • Toggle check-syntax behavior (report non-GCC when in closure mode)
  • Start checking module for namepaths (see "todo" in jsdocUtils.js source), but only for "jsdoc" (and "closure"?) mode (TS doesn't support)
  • valid-types
    • valid-types - Ensure tags with optional type (tagsWithOptionalTypePosition) only allow for package, private, protected, public, and static if in closure mode.
    • valid-types - Only allow @extends {SomeType} with brackets if in closure mode.
    • valid-types - Only allow @typedef {SomeType} (without a name) in closure mode.
    • Report name on @interface in Closure
  • Don't check optional name on @interface in Closure
  • For check-tag-names, avoid allowing @template except in closure and typescript
  • For check-tag-names, add other GCC tags for closure mode (GCC specific tags support #306)
  • check-tag-names to prefer other defaults with tagNamePreference (return over returns)
  • See about getting jsdoctypeparser (e.g., see Typescript types should parse correctly jsdoctypeparser/jsdoctypeparser#50 on TypeScript support) to support different modes so long as jsdoc/TypeScript/Closure differ in the formats supported (might have comments which are used to build alternate versions of the peg file, e.g., stripping out those for TypeScript or Closure only). One explicitly desired rule to be avoided for closure per Disallow {[string]} array notation #495 is to disallow tuples. Might also have a tolerant version (the default?) which accepted all forms though (?).

Might accept a version in an array along with the mode string in case jsdoc, Closure, or TypeScript make breaking changes or add more features.

@l1bbcsg
Copy link
Contributor

l1bbcsg commented Aug 8, 2019

check-syntax is another important rule to tweak. Currently it tweaks agains GCC style, but in gcc mode it could have the opposite behavior.

check-types rule, preferredTypes and tagNamePreference settings could use different defaults in GCC mode, i.e. prefer return over returns.

@brettz9
Copy link
Collaborator Author

brettz9 commented Aug 10, 2019

Thanks, @l1bbcsg , I've amended the original post to include check-syntax, but I mentioned check-tag-names instead of check-types in relation to tagNamePreference; do you have an example of a type that differs from gcc if check-types also should toggle behavior?

@l1bbcsg
Copy link
Contributor

l1bbcsg commented Aug 12, 2019

One case I can think of is that Function and function both could be used in GCC code and have different meaning.

Technically, Boolean and boolean are also different types, but I can't think of any real-world scenario where you could find a difference.

You can look into GCC types in details here: Types in the Closure Type System

@brettz9
Copy link
Collaborator Author

brettz9 commented Aug 20, 2019

Both Function and function could be used in regular jsdoc as well, though in regular jsdoc, there is no function() (with parentheses). The fact that regular jsdoc should not handle function() type syntax is reflected already in the to-do for getting jsdoctypeparser to support different modes and setting such a mode.

Re: real world differences between Boolean and boolean, typeof treats them differently: typeof new Boolean(true) === 'object' vs. typeof true === 'boolean'. The rule check-types prefers boolean since use of Object-wrapped primitives is generally frowned upon. I don't see that this should differ between regular jsdoc and GCC.

@ExE-Boss
Copy link

ExE-Boss commented Sep 27, 2019

@brettz9
Copy link
Collaborator Author

brettz9 commented Sep 27, 2019

Ah, good catch, thanks @ExE-Boss ! Amended...

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 14, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 14, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 14, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 15, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 15, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
@brettz9 brettz9 mentioned this issue Oct 15, 2019
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 17, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 18, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 18, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 20, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 20, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 20, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 24, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 27, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 29, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of gajus#356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit that referenced this issue Oct 29, 2019
… utilize in `getPreferredTagName`, `isValidTag`, `getTagsByType`; fixes part of #356

BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 30, 2019
…ypes` for types in "closure" and "typescript" modes; fixes part of gajus#356

BREAKING CHANGE:

`@template` has no special meaning for regular jsdoc (is not even allowed by default), so don't check in "jsdoc" mode.
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Oct 30, 2019
…ypes` for types in "closure" and "typescript" modes; fixes part of gajus#356

BREAKING CHANGE:

`@template` has no special meaning for regular jsdoc (is not even allowed by default), so don't check in "jsdoc" mode.
@brettz9
Copy link
Collaborator Author

brettz9 commented Jun 20, 2020

Oh, and with #586, combined with a PR to jsdoctypeparser to prevent = except in "closure" and "permissive" modes, this rule's currently sole feature might become obsolete, since valid-types could easily be made (with such a change in jsdoctypeparser) to no longer accept the optional = for "jsdoc" and "typescript" modes (the jsdoctypeparser source also mentions other similar optional types as "deprecated").

Update: On second thought, perhaps jsdoctypeparser should not be changed here since "jsdoc" supports closure types such as the optional = suffix, so I guess this is suitable at the eslint-plugin-jsdoc rule level rather than parser level.

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
…d "typescript" mode; fixes part of gajus#356

"jsdoc" mode or new "permissive" mode will not complain (in preparation for the rule potentially preventing other syntaxes by mode (where jsdoctypeparser does not forbid)).
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
…are type parsing; fixes part of gajus#356; fixes gajus#495

BREAKING CHANGE:

Requires Node 10+

Also:
1. Adds "permissive" mode
2. Checks "param" for valid namepaths
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
…are type parsing; fixes part of gajus#356; fixes gajus#495

BREAKING CHANGE:

Requires Node 10+

Also:
1. Adds "permissive" mode
2. Checks "param" for valid namepaths
3. Refactors to use updated/better Node 10+ syntax/packages
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
… mode; continue checking on jsdoc; fixes part of gajus#356

Also avoids checking namepath on `interface` tag for `no-undefined-types` and `check-types` when in closure mode.
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
…d "typescript" mode; fixes part of gajus#356

"jsdoc" mode or new "permissive" mode will not complain (in preparation for the rule potentially preventing other syntaxes by mode (where jsdoctypeparser does not forbid)).
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
…d "typescript" mode; fixes part of gajus#356

"jsdoc" mode or new "permissive" mode will not complain (in preparation for the rule potentially preventing other syntaxes by mode (where jsdoctypeparser does not forbid)).
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 20, 2020
brettz9 added a commit that referenced this issue Jun 21, 2020
…are type parsing; fixes part of #356; fixes #495 (#586)

BREAKING CHANGE:

Requires Node 10+

Also:
1. Adds "permissive" mode
2. Checks "param" for valid namepaths
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 21, 2020
… mode; continue checking on jsdoc; fixes part of gajus#356

Also avoids checking namepath on `interface` tag for `no-undefined-types` and `check-types` when in closure mode.
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 21, 2020
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 21, 2020
…d "typescript" mode; fixes part of gajus#356

"jsdoc" mode or new "permissive" mode will not complain (in preparation for the rule potentially preventing other syntaxes by mode (where jsdoctypeparser does not forbid)).
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 21, 2020
brettz9 added a commit that referenced this issue Jun 23, 2020
… mode; continue checking on jsdoc; fixes part of #356 (#587)

Also avoids checking namepath on `interface` tag for `no-undefined-types` and `check-types` when in closure mode.
brettz9 added a commit that referenced this issue Jun 23, 2020
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 23, 2020
…d "typescript" mode; fixes part of gajus#356

"jsdoc" mode or new "permissive" mode will not complain (in preparation for the rule potentially preventing other syntaxes by mode (where jsdoctypeparser does not forbid)).
brettz9 added a commit that referenced this issue Jun 23, 2020
…d "typescript" mode; fixes part of #356

"jsdoc" mode or new "permissive" mode will not complain (in preparation for the rule potentially preventing other syntaxes by mode (where jsdoctypeparser does not forbid)).
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 23, 2020
brettz9 added a commit that referenced this issue Jun 23, 2020
…h in non-"typescript" mode; fixes part of #356
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Jun 23, 2020
…`private`), report bracketed type in non-Closure mode; fixes gajus#356

Also reports missing name with `typedef` in non-Closure mode
@brettz9
Copy link
Collaborator Author

brettz9 commented Jun 23, 2020

While I've gone ahead and stopped check-types from reporting Closure optional types when in "closure" mode, an option could be added to force it to be allowed. Other mode-specific changes are also welcome as separate issues, but the initial checklist here is now complete, so is being closed.

Note also that not all of TypeScript is yet supported in jsdoctypeparser, but we do have a mode there now (and which we are using in eslint-plugin-jsdoc) to support TS-specific syntax when in TS mode.

@gajus
Copy link
Owner

gajus commented Jun 23, 2020

🎉 This issue has been resolved in version 28.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Jun 23, 2020
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

4 participants