Configuration basics
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:
.jscpd.json.config/jscpd.jsonor.config/.jscpd.json(5.1.0+)- the
jscpdkey ofpackage.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.
{
"threshold": 3,
"ignore": ["**/node_modules/**", "**/dist/**", "**/*.min.js"],
"format": ["javascript", "typescript", "python"],
"minTokens": 50,
"minLines": 5,
"reporters": ["console", "html"],
"output": "report"
}
| Key | What it decides | Start with |
|---|---|---|
threshold | The duplication percentage above which the run exits 1 | A little above today's value, then lower it |
ignore | Globs for files that never count: generated code, vendored code, fixtures | Whatever your linter ignores |
format | The formats to scan, by name from jscpd --list | Your programming languages; leave out json, yaml, markdown unless you mean them |
minTokens, minLines | How small a clone can be | The defaults, 50 and 5; raise them if the report is noisy |
reporters, output | Which reports to write and where | console 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
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, inlinejscpd:ignoremarkers and ignore patterns: the config file. - Every flag with its default: CLI options.
- Fail the build on new clones only: baseline.