Skip to content

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.

Flint’s YAML plugin provides the following presets:

PresetRecommendedDescription
logical✅ AlwaysCommon rules for finding bugs and enforcing good logical practices in YAML files.
logicalStrict☑️ When ReadyAdditional rules for finding bugs and enforcing good logical practices in YAML files.
stylistic✅ AlwaysCommon rules for consistent styling and best stylistic practices in YAML files.
stylisticStrict☑️ When ReadyAdditional 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:

flint.config.ts
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:

flint.config.ts
import { defineConfig, yaml } from "flint";
export default defineConfig({
use: [
{
files: yaml.files.all,
rules: [yaml.presets.logicalStrict, yaml.presets.stylisticStrict],
},
],
});

Rules that find bugs and enforce good YAML practices for most-to-all YAML files.

flint.config.ts
import { defineConfig, yaml } from "flint";
export default defineConfig({
use: [
{
files: yaml.files.all,
rules: yaml.presets.logical,
},
],
});

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.

flint.config.ts
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.

Rules that enforce consistent styling and best stylistic practices for most-to-all YAML files.

flint.config.ts
import { defineConfig, yaml } from "flint";
export default defineConfig({
use: [
{
files: yaml.files.all,
rules: yaml.presets.stylistic,
},
],
});

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.

flint.config.ts
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: 9 of 11 (81.8%)
Flint RulePreset
emptyDocumentsReports empty YAML documents that contain only document markers.logical
emptyMappingKeysReports empty mapping keys.logical
emptyMappingValuesReports empty mapping values.logical
emptySequenceEntriesReports empty sequence entries.logical
stringMappingKeysEnforces mapping keys to be strings.logical (strict)
blockMappingsPrefer block-style mappings over flow-style mappings.stylistic
blockSequencesPrefer block style sequences over flow style sequences.stylistic
irregularWhitespacestylistic
fileExtensionsstylistic (strict)
numericTrailingZerosReports trailing zeros in numeric values.stylistic (strict)
plainScalarsPrefer plain style scalars over quoted scalars.stylistic (strict)

Flint’s YAML plugin provides the following file selector:

  • all: **/*.{yaml,yml}
Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.