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 {
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
} from "flint";
export default
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
({
ConfigDefinition.use: ConfigUseDefinition[]

Specifies the files to be linted alongside the rules and settings to lint with.

@seehttps://flint.fyi/configuration#use flint.fyi/configuration#use

use
: [
{
ConfigUseDefinition.files: AnyLevelDeep<FilesValue>

A list of glob patterns describing which file(s) to lint.

@seehttps://flint.fyi/configuration#files flint.fyi/configuration#files

files
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.files: Record<"all", FilesValue>

Selectors of files this plugin suggests applying its rules to.

@seehttps://flint.fyi/glossary#files flint.fyi/glossary#files

files
.
all: FilesValue
all
,
ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>

Any number of rules and/or presets of rules to enable for those files.

@seehttps://flint.fyi/configuration#rules flint.fyi/configuration#rules

rules
: [
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
logical: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
logical
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
stylistic: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
stylistic
],
},
],
});

If you are experienced with both YAML and linting, Flint recommends using the logicalStrict and stylisticStrict presets:

flint.config.ts
import {
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
} from "flint";
export default
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
({
ConfigDefinition.use: ConfigUseDefinition[]

Specifies the files to be linted alongside the rules and settings to lint with.

@seehttps://flint.fyi/configuration#use flint.fyi/configuration#use

use
: [
{
ConfigUseDefinition.files: AnyLevelDeep<FilesValue>

A list of glob patterns describing which file(s) to lint.

@seehttps://flint.fyi/configuration#files flint.fyi/configuration#files

files
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.files: Record<"all", FilesValue>

Selectors of files this plugin suggests applying its rules to.

@seehttps://flint.fyi/glossary#files flint.fyi/glossary#files

files
.
all: FilesValue
all
,
ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>

Any number of rules and/or presets of rules to enable for those files.

@seehttps://flint.fyi/configuration#rules flint.fyi/configuration#rules

rules
: [
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
logicalStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
logicalStrict
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
stylisticStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
stylisticStrict
],
},
],
});

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

flint.config.ts
import {
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
} from "flint";
export default
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
({
ConfigDefinition.use: ConfigUseDefinition[]

Specifies the files to be linted alongside the rules and settings to lint with.

@seehttps://flint.fyi/configuration#use flint.fyi/configuration#use

use
: [
{
ConfigUseDefinition.files: AnyLevelDeep<FilesValue>

A list of glob patterns describing which file(s) to lint.

@seehttps://flint.fyi/configuration#files flint.fyi/configuration#files

files
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.files: Record<"all", FilesValue>

Selectors of files this plugin suggests applying its rules to.

@seehttps://flint.fyi/glossary#files flint.fyi/glossary#files

files
.
all: FilesValue
all
,
ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>

Any number of rules and/or presets of rules to enable for those files.

@seehttps://flint.fyi/configuration#rules flint.fyi/configuration#rules

rules
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
logical: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
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 {
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
} from "flint";
export default
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
({
ConfigDefinition.use: ConfigUseDefinition[]

Specifies the files to be linted alongside the rules and settings to lint with.

@seehttps://flint.fyi/configuration#use flint.fyi/configuration#use

use
: [
{
ConfigUseDefinition.files: AnyLevelDeep<FilesValue>

A list of glob patterns describing which file(s) to lint.

@seehttps://flint.fyi/configuration#files flint.fyi/configuration#files

files
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.files: Record<"all", FilesValue>

Selectors of files this plugin suggests applying its rules to.

@seehttps://flint.fyi/glossary#files flint.fyi/glossary#files

files
.
all: FilesValue
all
,
ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>

Any number of rules and/or presets of rules to enable for those files.

@seehttps://flint.fyi/configuration#rules flint.fyi/configuration#rules

rules
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
logicalStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
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 {
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
} from "flint";
export default
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
({
ConfigDefinition.use: ConfigUseDefinition[]

Specifies the files to be linted alongside the rules and settings to lint with.

@seehttps://flint.fyi/configuration#use flint.fyi/configuration#use

use
: [
{
ConfigUseDefinition.files: AnyLevelDeep<FilesValue>

A list of glob patterns describing which file(s) to lint.

@seehttps://flint.fyi/configuration#files flint.fyi/configuration#files

files
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.files: Record<"all", FilesValue>

Selectors of files this plugin suggests applying its rules to.

@seehttps://flint.fyi/glossary#files flint.fyi/glossary#files

files
.
all: FilesValue
all
,
ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>

Any number of rules and/or presets of rules to enable for those files.

@seehttps://flint.fyi/configuration#rules flint.fyi/configuration#rules

rules
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
stylistic: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
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 {
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
,
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
} from "flint";
export default
function defineConfig(definition: ConfigDefinition): Config

Defines a new linter configuration for a Flint config file.

@seehttps://flint.fyi/configuration flint.fyi/configuration

defineConfig
({
ConfigDefinition.use: ConfigUseDefinition[]

Specifies the files to be linted alongside the rules and settings to lint with.

@seehttps://flint.fyi/configuration#use flint.fyi/configuration#use

use
: [
{
ConfigUseDefinition.files: AnyLevelDeep<FilesValue>

A list of glob patterns describing which file(s) to lint.

@seehttps://flint.fyi/configuration#files flint.fyi/configuration#files

files
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.files: Record<"all", FilesValue>

Selectors of files this plugin suggests applying its rules to.

@seehttps://flint.fyi/glossary#files flint.fyi/glossary#files

files
.
all: FilesValue
all
,
ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>

Any number of rules and/or presets of rules to enable for those files.

@seehttps://flint.fyi/configuration#rules flint.fyi/configuration#rules

rules
:
const yaml: Plugin<RuleAbout, "all", [Rule<{
readonly description: "Prefer block-style mappings over flow-style mappings.";
readonly id: "blockMappings";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "preferBlock", AnyOptionalSchema>, Rule<{
readonly description: "Prefer block style sequences over flow style sequences.";
readonly id: "blockSequences";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
url: string;
}, object, object, "flowSequence", AnyOptionalSchema>, ... 6 more ..., Rule<...>]>
yaml
.
Plugin<RuleAbout, "all", [Rule<{ readonly description: "Prefer block-style mappings over flow-style mappings."; readonly id: "blockMappings"; readonly presets: ["stylistic", "stylisticStrict"]; } & { ...; }, object, object, "preferBlock", AnyOptionalSchema>, ... 7 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">

Preset lists of rules to enable on files.

@seehttps://flint.fyi/glossary#preset flint.fyi/glossary#preset

presets
.
stylisticStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
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 ❤️‍🔥 around the world by the Flint team and contributors.