Search code examples
javascriptjslintjshinteslintstatic-code-analysis

Treat the use of @author as code style violation


Goal:

Issue a warning in case an @author tag is used anywhere inside the .js files in the project.

Question:

Is it something that jshint or other static code check tools can help with? If not, what options do I have?

Description:

I completely agree with Paul's answer at Javadoc @author tag good practices thread and treat @author tag as an unnecessary noise.

And, in the Python world, I've seen people checking for the tag usage. For example, Openstack Style Guidelines explicitly state not use @author tag. They have developed a set of custom flake8 checks which include:

[H105] Don’t use author tags.

Now, I'm trying to solve the same problem in JavaScript.

Example (this should not pass a code quality check):

/**
 * @author John Smith <john@smith.com>
 */

'use strict';

Solution

  • No, jshint can't do that. Just do a grep across the sources looking for @author. If you want you could put that in a git pre-commit hook. Or, you could hack JSDoc to error out when creating docs if it encounters @author.