Configuration
Configuration must be defined in TOML format in one of the next files:
.project-config.toml
pyproject.toml (inside a
[tool.project-config]
table)A custom file passing
-c
/--config
argument in the command line.
Tip
You can use the project-config init
command to initialize a minimal
configuration and JSON5 style file.
project-config init
style = ["style.json5"]
cache = "5 minutes"
{
rules: [
{
files: [".project-config.toml"],
JMESPathsMatch: [
["type(style)", "array"],
["op(length(style), '>', `0`)", true, "set(@, 'style', ['style.json5'])"],
["type(cache)", "string", "set(@, 'cache', '5 minutes')"],
[
"regex_match('(\\d+ ((seconds?)|(minutes?)|(hours?)|(days?)|(weeks?)))|(never)$', cache)",
true,
"5 minutes",
],
]
}
]
}
style
(string or string[])
It is the unique mandatory field. At least one style with one rule must
be specified to run project-config
.
It can be a string or an array of strings, always pointing existent resources. Valid resource types are:
Local files with relative paths like foo.json5 or ./bar.yaml.
Github schema URIs in the form
gh://<user>/<project>(@tag)?/<path/to/file.ext>
likegh://mondeja/project-config-styles/python/version/min-37.json5
. The@
syntax is used to pin a GIT reference (commit, tag, branch) and is optional, if is not specified the main branch of the repository will be used.Raw URLs like
https://raw.githubusercontent.com/mondeja/project-config-styles/master/python/base.json5
.
The rules of the styles are applied in the same order that they are defined.
cache
(string)
Cache expiration time for all online resources fetched. Default value is
"5 minutes"
. Must follow the format cache = "<integer> <time-unit>"
.
Time unit can be one of these (plural or singular, it doesn’t matter):
seconds / second
minutes / minute
hours / hour
days / day
weeks / week
Also accept the next string to not use the cache at all.
never
Tip
You can also disable the cache passing the CLI option --no-cache
/
--nocache
or setting the PROJECT_CONFIG_USE_CACHE
environment
variable to "false"
.
See also
You can use the command project-config show cache
to output
the location of project-config’s cache directory.
cli
(object)
Configures the CLI execution. It avoids you to pass the same CLI arguments to the project-config command.
See also
cli.rootdir
(string)
Root directory of the project. Corresponds to the project-config --rootdir optional CLI argument.
cli.reporter
(string)
Reporter to use. Corresponds to the NAME:FORMAT
part of the
project-config --reporter optional CLI argument.
cli.color
(boolean)
Specifies if your want the output to be colored. Corresponds to the project-config --no-color optional CLI argument.
cli.colors
(object)
Custom colors used in the output of the CLI. Corresponds to the color=
argument of the project-config --reporter optional CLI argument.
cli.only_hints
(boolean)
Specifies if you want to only show the hints rather than the full error messages if rules have them. As default disabled.
Example
style = ["style.json5"]
cache = "5 minutes"
[cli]
color = false
reporter = "json"
rootdir = "src"
only_hints = true
[tool.project-config]
style = ["style.json5"]
cache = "5 minutes"
[tool.project-config.cli]
color = false
reporter = "json"
rootdir = "src"
only_hints = true