Start

Configuration basics

The config file jscpd reads, the handful of keys most projects set, and how to check what a run will use.

Most projects need five or six settings, and they belong in a file next to the code so that every run, local or in CI, uses the same ones. This page is that file; the config file reference has every key and the details of how files and flags combine.

Where the file lives

jscpd looks in the current working directory, in this order, and takes the first match:

  1. .jscpd.json
  2. .config/jscpd.json or .config/.jscpd.json (5.1.0+)
  3. the jscpd key of package.json

It does not look inside the paths it scans, so jscpd packages/api from the repository root reads the root's file. -c path/to/file.json names a file explicitly, from anywhere, and a flag on the command line wins over any file.

The keys to set first

Keys are the CLI flags in camelCase. A flag given on the command line overrides the same key in the file.

.jscpd.json
{
  "threshold": 3,
  "ignore": ["**/node_modules/**", "**/dist/**", "**/*.min.js"],
  "format": ["javascript", "typescript", "python"],
  "minTokens": 50,
  "minLines": 5,
  "reporters": ["console", "html"],
  "output": "report"
}
KeyWhat it decidesStart with
thresholdThe duplication percentage above which the run exits 1A little above today's value, then lower it
ignoreGlobs for files that never count: generated code, vendored code, fixturesWhatever your linter ignores
formatThe formats to scan, by name from jscpd --listYour programming languages; leave out json, yaml, markdown unless you mean them
minTokens, minLinesHow small a clone can beThe defaults, 50 and 5; raise them if the report is noisy
reporters, outputWhich reports to write and whereconsole plus html for reading, json for scripts, sarif for GitHub code scanning

Files that .gitignore lists are skipped already; noGitignore: true turns that off.

Check what a run would use

Terminal
jscpd --debug

The command prints the merged configuration (file plus flags) as JSON and exits without scanning. The keys appear in snake_case there (min_tokens for minTokens). If a value you set is not in the output, the key is misspelled: jscpd warns about keys it does not know and ignores them.

Next

  • Everything about the file, package.json, inline jscpd:ignore markers and ignore patterns: the config file.
  • Every flag with its default: CLI options.
  • Fail the build on new clones only: baseline.