mocha icon indicating copy to clipboard operation
mocha copied to clipboard

🛠️ Repo: Add eslint-plugin-compat or an equivalent

Open boneskull opened this issue 6 years ago • 4 comments

I identified a use case for a custom JSDoc tag in our source.

Let's tag code that exists for the sole purpose of supporting a particular environment. Then, if/when we drop support for that environment, we can easily find what can be culled. Maybe @env?

Example, from lib/utils.js:

/**
 * `process.emitWarning` or a polyfill
 * @env IE11
 */
var doDeprecationWarning = process.emitWarning
  ? function(msg) {
      // Node.js v6+
      process.emitWarning(msg, 'DeprecationWarning');
    }
  : function(msg) {
      // Everything else
      process.nextTick(function() {
        console.warn(msg);
      });
    };

cc @craigtaub @plroebuck for feedback?

boneskull avatar Dec 19 '18 17:12 boneskull

Sounds like a good idea. Should be 1 tag per env, no comma separation.

While we are on the subject think we could do with mandating how to use the tags. Im still not clear on whether to optimise for user access or module documentation.

craigtaub avatar Dec 19 '18 18:12 craigtaub

I hate our API documentation now... Have been looking into possibility of restoring @api tag with custom jsdoc plugin (so it actually means something) and maybe we color methods with that tag differently to imply availability to user code.

plroebuck avatar Jan 21 '19 16:01 plroebuck

@plroebuck

Not only is it information overload, I can't see any reason consumers would need to know about APIs that aren't intended to be used. If you, the developer, want to see this documentation, it's easy to generate locally:

$ node_modules/.bin/jsdoc -c jsdoc.conf.js --private

...and you'll have everything in docs/_dist/api. We could also add something in package-scripts.js to do this.

boneskull avatar Jan 21 '19 21:01 boneskull

This exists in https://github.com/amilajack/eslint-plugin-compat actually.

JoshuaKGoldberg avatar Dec 27 '23 22:12 JoshuaKGoldberg