Skip to content

Latest commit

 

History

History
149 lines (110 loc) · 3.04 KB

configure.md

File metadata and controls

149 lines (110 loc) · 3.04 KB

Configuration

unified-engine accepts configuration through options and through configuration files.

Explicit configuration

One configuration file can be given through rcPath, this is loaded regardless of detectConfig and rcName.

Implicit configuration

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 $packageFields 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.

Example

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

Schema

The following properties are currently used in configuration files.

settings

The settings field, related to settings in options, configures the parser and compiler of the processor.

{
  "settings": {
    "emitParseErrors": true
  }
}
  • Type: Object
plugins

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> or Record<string, unknown>