Skip to content

规则配置

¥Rules configuration

规则由名称和配置数组组成。配置数组包含:

¥Rules are made up by a name and a configuration array. The configuration array contains:

  • 级别 [0..2]0 禁用该规则。对于 1,它将被视为警告;对于 2,它将被视为错误。

    ¥Level [0..2]: 0 disables the rule. For 1 it will be considered a warning for 2 an error.

  • 适用 always|nevernever 反转规则。

    ¥Applicable always|never: never inverts the rule.

  • 值:此规则使用的值。

    ¥Value: value to use for this rule.

规则配置要么是 array 类型,位于以规则名称为键的规则 object 上的键上,要么是函数类型,返回类型为 arrayPromise<array>。这意味着支持以下所有符号。

¥Rule configurations are either of type array residing on a key with the rule's name as key on the rules object or of type function returning type array or Promise<array>. This means all of the following notations are supported.

普通数组

¥Plain array

js
export default {
  // ...
  rules: {
    "header-max-length": [0, "always", 72], 
  },
  // ...
};

返回数组的函数

¥Function returning array

js
export default {
  // ...
  rules: {
    "header-max-length": () => [0, "always", 72], 
  },
  // ...
};

异步函数返回数组

¥Async function returning array

js
export default {
  // ...
  rules: {
    "header-max-length": async () => [0, "always", 72], 
  },
  // ...
};