Customizing Conformance
Learn how to manage and configure your Conformance rules.Conformance is available on Enterprise plans
The Conformance framework may be customized so that you can manage rules for different workspaces in your repository or to pass configuration to the rules.
To customize Conformance, first define a conformance.config.jsonc
file in the root of your directory.
Both conformance.config.jsonc
and conformance.config.json
are supported,
and both support JSONC (JSON with JavaScript-style comments). We recommend
using the .jsonc
extension as it helps other tools (for example, VS Code) to
provide syntax highlighting and validation.
To view Conformance metrics in the Vercel dashboard, you need to be using at least version 1.7.0 of the Conformance CLI and also to add your team ID and repository ID to the Conformance configuration file.
- Instructions for finding your team ID can be found here.
- To find your repository ID, visit
https://vercel.com/{team name}/~/repos/{repository name}/settings
and copy the ID from theRepo ID
section.
{
"configuration": {
"repositoryId": "",
"teamId": "",
},
}
To enable all Conformance rules by default, add the defaultRules
field to the
top level configuration
section of the config file:
{
"configuration": {
"defaultRules": "all",
},
}
Each Conformance override accepts a restrictTo
parameter which controls what
workspaces the configuration will apply to. If no restrictTo
is specified,
then the configuration will apply globally to every workspace.
{
"overrides": [
{
// NOTE: No `restrictTo` is specified here so this applies globally.
"rules": {},
},
],
}
Conformance configuration can be applied to specific workspaces using either
the name of the workspace or the directory of the workspace on the restrictTo
field:
- Use the
workspaces
field, which accepts a list of workspace names:conformance.config.jsonc{ "overrides": [ { "restrictTo": { "workspaces": ["eslint-config-custom"], }, "rules": {}, }, ], }
- Use the
directories
field to specify a directory. All workspaces that live under that directory will be matched:This will matchconformance.config.json{ "overrides": [ { "restrictTo": { "directories": ["configs/"], }, "rules": {}, }, ], }
configs/tsconfig
andconfigs/eslint-config-custom
. - Set the
root
field to true to match the root of the repository:conformance.config.jsonc{ "overrides": [ { "restrictTo": { "root": true, }, "rules": {}, }, ], }
If multiple overrides are specified that affect the same workspace, the configurations will be unioned together. If there are conflicts between the overrides, the last specified value will be used.
To enable or disable a Conformance rule, use the rules
field. This
field is an object literal where the keys are the name of the rule and the
values are booleans or another object literal containing a rule-specific
configuration.
For example, this configuration will disable the TYPESCRIPT_CONFIGURATION
rule:
{
"overrides": [
{
"rules": {
"TYPESCRIPT_CONFIGURATION": false,
},
},
],
}
All rules are enabled by default unless explicitly disabled in the config.
Some Conformance rules can be configured to alter behavior based on the project
settings. Instead of a boolean
being provided in the rules
configuration,
an object literal could be passed with the configuration for that rule.
For example, this configuration will require a specific list of ESLint plugins in every workspace:
{
"overrides": [
{
"rules": {
"ESLINT_CONFIGURATION": {
"requiredPlugins": ["@typescript-eslint"],
},
},
},
],
}
If you want to specify additional information or link to project-specific documentation, you can add custom error messages to the output of any conformance rule. These messages can be added globally to all rules or on a per-rule basis.
To add an error message to the output of all rules, add globalErrorMessage
to
the configuration
section of the override:
{
"overrides": [
{
"configuration": {
"globalErrorMessage": "See link_to_docs for more information.",
},
},
],
}
To add an error message to the output of one
specific rule, add an entry for that test to the additionalErrorMessages
field:
{
"overrides": [
{
"configuration": {
"additionalErrorMessages": {
"TYPESCRIPT_CONFIGURATION": "Please see project_link_to_typescript_docs for more information.",
},
},
},
],
}
Was this helpful?