unified-engine
accepts configuration through options and through
configuration files.
One configuration file can be given through rcPath
, this is loaded
regardless of detectConfig
and rcName
.
Otherwise, configuration files are detected if detectConfig
is turned on, depending on the following options:
- If
rcName
is given,$rcName
(JSON),$rcName.js
(CommonJS or ESM),$rcName.cjs
(CommonJS),$rcName.mjs
(ESM),$rcName.yml
(YAML), and$rcName.yaml
(YAML) are loaded - If
packageField
is given,package.json
(JSON) files are loaded and their$packageField
s are used as configuration
In this case, the first file that is searched for in a directory is used as the configuration. If no file is found, the parent directory is searched, and so on.
An example rc file could look as follows:
{
"settings": {
"bullet": "*",
"ruleRepetition": 3,
"fences": true
},
"plugins": [
"inline-links",
"lint-recommended"
]
}
Another example, rc.js, could look as follows:
exports.plugins = ['./script/natural-language.js', 'lint-recommended', 'license']
exports.settings = {bullet: '*'}
When using ESM (ECMAScript modules), rc.mjs could look as folows:
export default {
plugins: ['./script/natural-language.js', 'lint-recommended', 'license'],
settings: {bullet: '*'}
}
Another example, rc.yaml, could look as follows:
plugins:
- lint
- document
- minify
settings:
verbose: true
quote: "'"
quoteSmart: true
preferUnquoted: true
The following properties are currently used in configuration files.
The settings
field, related to settings
in options
, configures
the parser and compiler of the processor.
{
"settings": {
"emitParseErrors": true
}
}
- Type:
Object
The plugins
field, related to plugins
in options
, has either an
array of plugin names (or paths) or plugin–options tuples, or an object mapping
plugins to their options.
Plugin options can be false
, which specifies that a plugin should not be used.
In all other cases, they are treated as an object, and merged by the cascade.
Thus, it’s possible to specify part of the options from one configuration file,
and overwrite or extend it from another file.
Accepts an array:
{
"plugins": [
"foo",
"bar",
[
"qux",
{"quux": true}
]
]
}
Or an object:
{
"plugins": {
"foo": null,
"bar": {
"baz": "qux"
}
}
}
- Type:
Array<string>
orRecord<string, unknown>