Config reference
scan and backfill read scout.config.json from the current directory, or the file named by their --config flag. The file is plain JSON: comments and trailing commas are errors.
The smallest valid config is an empty object. With it, the scan reads every JavaScript, TypeScript and Vue file below the config folder:
{}
The config folder is the folder that holds the config file. Relative paths in the config resolve against it, whatever directory you run scan or backfill from. The one exception is aliases; see Paths.
Fields
Common fields
| Field | Type | Default | Behavior |
|---|---|---|---|
include | array of non-empty strings, at least one | ["**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,vue}"]: every .js, .jsx, .ts, .tsx, .mjs, .cjs, .mts, .cts and .vue file below the config folder | Glob patterns for the files to scan. |
exclude | array of non-empty strings | [] | Glob patterns for files to leave out, even when include matches them. A path with no glob characters, such as apps/playground, leaves out that folder or file. |
repoId | non-empty string | derived; see Repo identity | The repo id the scan is recorded under. --repo-id replaces it. |
The scan skips:
- test, spec and story files (
*.test.*,*.spec.*,*.stories.*), files in__tests__folders, type declaration files (*.d.ts,*.d.mts,*.d.cts) and anything innode_modules, even when anincludepattern names them; - files and folders whose names start with a dot, such as
.next, unless anincludepattern names them, for examplesrc/.generated/*.tsx; - files ignored by
.gitignore, unlessgitignoreisfalse; - a folder below the config folder that holds its own git repository, such as a submodule or another clone, even when an
includepattern points into it.
When an exclude entry has no glob characters and nothing exists at that path, the scan warns and carries on.
Upload fields
Only needed when you upload scans to a dashboard.
| Field | Type | Default | Behavior |
|---|---|---|---|
host | non-empty string | none | Dashboard that scan and backfill upload to and the auth commands sign in to. --host and SCOUTUI_HOST win over it; it wins over your default host. See Host resolution. init writes it when you give a dashboard address. |
branch | non-empty string | the remote's default branch | Branch the dashboard tracks. Without it, scan and backfill follow the remote's default branch as the clone recorded it (<remote>/HEAD). init writes it when it can tell which branch that is. |
Backfill fields
Only backfill reads this field. scan ignores it, and init never writes it.
| Field | Type | Default | Behavior |
|---|---|---|---|
install | non-empty string | none: backfill works out the install from the lockfile | Command backfill runs at each commit to install dependencies, through the shell, from the top of the repository. It replaces backfill's own install, nuxt prepare included, so for a Nuxt app the command must prepare the app too. Example: "yarn install --immutable". |
Import resolution fields
Rarely needed. Set these only when imports go through path aliases the scan can't find on its own. See Resolve imports in a monorepo.
| Field | Type | Default | Behavior |
|---|---|---|---|
tsconfigPath | non-empty string | none: the scan looks for a tsconfig itself | tsconfig whose compilerOptions.paths are used, following extends. Absolute, or relative to the config folder. If the file can't be read, the scan prints a warning naming it and carries on without it. |
aliases | object: each key an import pattern, each value an array of non-empty strings | none | Import aliases that aren't in a tsconfig, such as ones only in a bundler config. |
How aliases entries match:
- A key without
*matches only that exact import. A*in the key matches any text, for example"~/*"matches~/components/Card. In each value,*is replaced by the text it matched. - Values are tried in order, and the first one that points at an existing file wins. When more than one key matches, keys are tried in the order they appear in the file.
- A value can leave out the file extension, or point at a folder that holds an
indexfile. aliasesare tried before tsconfigpaths. If no value points at an existing file, the scan falls back to tsconfigpaths.
"aliases": {
"~/*": ["./src/*"],
"@acme/ui-legacy": ["./vendor/ui-legacy/index.ts"]
}
Other fields
| Field | Type | Default | Behavior |
|---|---|---|---|
$schema | string | none | Lets editors validate the file and suggest fields. init sets it to https://unpkg.com/@scoutui/cli/schema/config.schema.json. The scan ignores it. |
gitignore | boolean | true | true skips files ignored by the repo's .gitignore files. false scans them too, for example to include untracked work. |
No other keys are allowed; an unknown or misspelled key is an error. See Validation errors.
Paths
What each path in the config is relative to:
| Field | Relative to |
|---|---|
include, exclude | The config folder. |
tsconfigPath | The config folder. |
aliases values | The monorepo root when scan prints Monorepo root: <dir>, otherwise the config folder. |
scan prints Monorepo root: when the config folder is one of a monorepo's workspace packages. Resolve imports in a monorepo shows the same alias written both ways.
Repo identity
The repo id comes from the first of these that is set:
| Order | Source | Example |
|---|---|---|
| 1 | --repo-id <value> | --repo-id storefront gives storefront |
| 2 | repoId in the config | "repoId": "storefront" gives storefront |
| 3 | The last part of the remote's URL, without .git. The remote is the one git config scout.remote names, else upstream when there is one, else the only remote, else origin. | git@github.com:acme/checkout.git gives checkout |
| 4 | The name of the config folder | A config in apps/web gives web, even when you run scan from the repo root |
init writes repoId for you, from the owner and name in the same remote's URL: git@github.com:acme/checkout.git gives acme/checkout.
Validation errors
A config error stops scan or backfill before it scans. <path> is the config path you gave, ./scout.config.json by default, and <folder> is the config folder.
| Problem | Message |
|---|---|
| No file at the config path | Couldn't find ./scout.config.json. Run scout init to create one, or pass --config <path>. With --config, it names that path instead. |
| The file isn't valid JSON | <path> isn't valid JSON. Fix it and try again. With --debug, the next line says where the parser stopped. |
| A field that isn't in Fields, such as a misspelled name | <path> has a field Scout doesn't use: "<field>". Remove it and try again. With several, it names every one. |
| Anything else the schema rejects | Each field it rejects and what's wrong, such as "include" in <path> can't be an empty list. Fix it and try again. |
On a dry run (scout scan --dry-run), scout-scan.json in the config folder links to a file outside it | scout-scan.json in <folder> links to a file outside that folder, so the scan won't write it. Delete the link and try again. |