Gutenberg: Eslint rule for JSDoc alignment

Created on 1 Sep 2020  路  5Comments  路  Source: WordPress/gutenberg

Is your feature request related to a problem? Please describe.

Currently, there is no Eslint plugin for check JSDoc alignment (at least I didn't find one in my researches 馃榿), as recommended in the WordPress standards.

Describe the solution you'd like

We created a new plugin to check JSDoc alignments (eslint-plugin-jsdoc-alignment). As it can be useful by WordPress community in general, @nerrad gave a good idea to add it to the @wordpress/eslint-plugin. So, before proceeding, it'd be good to discuss the approach to be used for that.

Things to consider:

  • It can be very helpful to the WordPress community, as it checks a WordPress standard not covered currently by @wordpress/eslint-plugin.
  • It can also be used by other projects (without WordPress) that want to use JSDoc with the lines aligned.
  • This plugin was designed to be used along with eslint-plugin-jsdoc because it checks only the alignment between the lines.

Describe alternatives you've considered

1) We could add it to the eslint-plugin/configs installing the current package. In some moment we can also open a new PR for eslint-plugin-jsdoc and when they accept, we could uninstall the package and just update the configuration to use the new rule from eslint-plugin-jsdoc.
2) We could migrate the rule to eslint-plugin/rules and add to the eslint-plugin/configs. I particularly don't like that, because it makes the plugin restrict only to eslint-plugin.
3) We could migrate the eslint-plugin-jsdoc-alignment to be a Gutenberg package (we could also make it for the other current Gutenberg generic rules), and install it in the eslint-plugin/configs. So devs that want use only some specific rule, can install it separately.

IMHO, the option 1 looks the more "organized", looking to the future with the contribution being accepted by eslint-plugin-jsdoc. It doesn't exclude the option to transform the other Gutenberg generic rules to Gutenberg packages.

[Package] ESLint plugin [Type] Build Tooling

Most helpful comment

We discussed this a bit in the Core JavaScript office hours today. Agreement was the best next step is to try to contribute this as a new rule to the eslint-plugin-jsdoc package.

All 5 comments

I lean towards option 1 as well assuming the pr is created for the upstream project. Otherwise, if this is something WP specific and/or it doesn't look like the upstream repo will accept, I think it would be good to add a custom rule in the @wordpress/eslint-plugin package.

We discussed this a bit in the Core JavaScript office hours today. Agreement was the best next step is to try to contribute this as a new rule to the eslint-plugin-jsdoc package.

@aduth left a follow up comment pointing out this prettier plugin that might be able to enforce alignment for us: https://www.npmjs.com/package/prettier-plugin-jsdoc

@aduth left a follow up comment pointing out this prettier plugin that might be able to enforce alignment for us: https://www.npmjs.com/package/prettier-plugin-jsdoc

Cool! Thank you for the suggestion! I tried install it in the Sensei LMS repo, but trying to reformat all code, some errors happened. I created a note here to dig into that in the future. =)

If someone is interested in follow, I created a PR https://github.com/gajus/eslint-plugin-jsdoc/pull/636 for the eslint-plugin-jsdoc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasmussen picture jasmussen  路  3Comments

aaronjorbin picture aaronjorbin  路  3Comments

moorscode picture moorscode  路  3Comments

mhenrylucero picture mhenrylucero  路  3Comments

nylen picture nylen  路  3Comments