Analyzing JavaScript Code

The PMD plugin analyzes Java by default. You can configure it to analyze JavaScript files instead as shown below.

The example assumes that the JavaScript source code is stored in the subdirectory src/main/javascript and enables three built-in rulesets (basic, braces, unnecessary).

Note that you have to make sure that you configure compileSourceRoots and includes, so that PMD finds the JavaScript files.


Note: Configuring compileSourceRoots only works with Maven 3.3.9 and later. For older versions, you'll need to use build-helper-maven-plugin with the add-source goal in order to add the additional source directories, so that PMD finds the JavaScript files.