Skip to main content

Lint

Available since
  • kosko v4.1.0

Install

npm install @kosko/plugin-lint

Usage

Enable the plugin with the recommended preset.

[[plugins]]
name = "@kosko/plugin-lint"
config.extends = ["@kosko/plugin-lint/presets/recommended"]

Enable specific rules.

[[plugins]]
name = "@kosko/plugin-lint"

[plugins.config.rules.no-missing-namespace]
severity = "error"

[plugins.config.rules.ban-image]
severity = "error"
config.images = ["*:latest"]

Configuration

extends

Load configuration from another file. The value could be a package name or a path to a JavaScript or JSON file.

Examples

# Preset
extends = ["@kosko/plugin-lint/presets/recommended"]

# Local file
extends = ["./lint-config.js"]

rules

Configure a lint rule. Every rule has two properties: config and severity. The config property is specific to each rule, and the severity property can be one of the following values:

  • "off", 0, false - Disable the rule. (Default)
  • "warning", "warn", 1 - Enable the rule as a warning. When the rule is violated, a warning will be reported, but the validation won't fail.
  • "error", 2, true - Enable the rule as an error. When the rule is violated, an error will be reported, and the validation will fail.

Examples

[rules.ban-image]
severity = "error"
config.images = ["*:latest"]

Preset

Currently there is only one preset available: @kosko/plugin-lint/presets/recommended. This preset contains rules with Rec badge.

You can enable it by adding extends to the configuration.

[[plugins]]
name = "@kosko/plugin-lint"
config.extends = ["@kosko/plugin-lint/presets/recommended"]

Caveats

  • This plugin does not validate manifests against OpenAPI schema. That is what kubernetes-models does. See validation for more details.
  • This plugin only executes when validation is enabled.
  • Rules with All badge are disabled when components is provided in kosko generate or kosko validate command, because these rules need to access all components to validate.