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: 1 of 11 (9%)
Flint RulePreset
emptyDocumentslogical
emptyMappingKeysReports empty mapping keys.logical
emptyMappingValueslogical
emptySequenceEntrieslogical
stringMappingKeyslogical (strict)
blockMappingsstylistic
blockSequencesstylistic
irregularWhitespacestylistic
fileExtensionsstylistic (strict)
numericTrailingZerosstylistic (strict)
plainScalarsstylistic (strict)

Flint’s YAML plugin provides the following file selector:

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