eslint-plugin-yaml

Lint YAML files using ESLint

Downloads
191K
Stars
10
Committers
2

eslint-plugin-yaml

Lint YAML files

Installation

You'll first need to install ESLint:

Next, install eslint-plugin-yaml:

npm install eslint-plugin-yaml --save-dev

Usage

Eslint 9 and above

Add the following to eslint.config.cjs:

const pluginYaml = require("eslint-plugin-yaml").default

module.exports = [pluginYaml.configs.recommended]

or to eslint.config.mjs:

import pluginYaml from "eslint-plugin-yaml"

export default [pluginYaml.configs.recommended]

Eslint 8 and below

Add the following to the overrides section of .eslintrc for yaml files:

"overrides" : [
    {
      "files": ["**/*.yaml", "**/*.yml"],
      "plugins": ["yaml"],
      "extends": ["plugin:yaml/legacy"]
    }
]

and run it for all the files:

eslint .

or:

eslint example.yaml

See spec folder for an example of eslint config file.

Eslint 8 and below (alternative)

or add yaml to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["yaml"],
  "extends": ["plugin:yaml/legacy"]
}

You can run ESLint on individual YAML files or you can use the --ext flag to add YAML files to the list.

eslint . --ext .yaml --ext .js
eslint example.yaml