YAML Plugin
Rules for linting .yaml/.yml files containing arbitrary data in the Yet Another Markup Language (YAML) format.
This plugin comes packaged with the flint npm package.
Presets
Section titled “Presets”Flint’s YAML plugin provides the following presets:
| Preset | Recommended | Description |
|---|---|---|
logical | ✅ Always | Common rules for finding bugs and enforcing good logical practices in YAML files. |
logicalStrict | ☑️ When Ready | Additional rules for finding bugs and enforcing good logical practices in YAML files. |
stylistic | ✅ Always | Common rules for consistent styling and best stylistic practices in YAML files. |
stylisticStrict | ☑️ When Ready | Additional rules for consistent styling and best stylistic practices in YAML files. |
If you are just getting started with linting, Flint recommends using the logical and stylistic presets:
import { defineConfig, yaml } from "flint";
export default defineConfig({ use: [ { files: yaml.files.all, rules: [yaml.presets.logical, yaml.presets.stylistic], }, ],});If you are experienced with both YAML and linting, Flint recommends using the logicalStrict and stylisticStrict presets:
import { defineConfig, yaml } from "flint";
export default defineConfig({ use: [ { files: yaml.files.all, rules: [yaml.presets.logicalStrict, yaml.presets.stylisticStrict], }, ],});logical
Section titled “logical”Rules that find bugs and enforce good YAML practices for most-to-all YAML files.
import { defineConfig, yaml } from "flint";
export default defineConfig({ use: [ { files: yaml.files.all, rules: yaml.presets.logical, }, ],});logicalStrict
Section titled “logicalStrict”Additional logical rules that enforce best practices which are not always straightforward to implement. These rules are recommended for projects where a majority of developers are experienced with both YAML and using a linter.
import { defineConfig, yaml } from "flint";
export default defineConfig({ use: [ { files: yaml.files.all, rules: yaml.presets.logicalStrict, }, ],});This preset’s rules are a superset of those in logical.
stylistic
Section titled “stylistic”Rules that enforce consistent styling and best stylistic practices for most-to-all YAML files.
import { defineConfig, yaml } from "flint";
export default defineConfig({ use: [ { files: yaml.files.all, rules: yaml.presets.stylistic, }, ],});stylisticStrict
Section titled “stylisticStrict”Additional stylistic rules that enforce best practices which are not always straightforward to implement. These rules are recommended for projects where a majority of developers are experienced with both YAML and using a linter.
import { defineConfig, yaml } from "flint";
export default defineConfig({ use: [ { files: yaml.files.all, rules: yaml.presets.stylisticStrict, }, ],});This preset’s rules are a superset of those in stylistic.
Implemented: 1 of 11 (9%)
| Flint Rule | Preset |
|---|---|
emptyDocuments | logical |
emptyMappingKeysReports empty mapping keys. | logical |
emptyMappingValues | logical |
emptySequenceEntries | logical |
stringMappingKeys | logical (strict) |
blockMappings | stylistic |
blockSequences | stylistic |
irregularWhitespace | stylistic |
fileExtensions | stylistic (strict) |
numericTrailingZeros | stylistic (strict) |
plainScalars | stylistic (strict) |
Selectors
Section titled “Selectors”Flint’s YAML plugin provides the following file selector:
all:**/*.{yaml,yml}