Skip to content

Flint Plugin

Rules for writing third-party Flint plugins and custom rules. Meta!
This plugin is provided in a standalone @flint.fyi/plugin-flint npm package.

Terminal window
npm install @flint.fyi/plugin-flint

Rules that find bugs and enforce good practices for Flint plugins and rules.

flint.config.ts
import {
const flint: Plugin<RuleAbout, string | undefined, [Rule<{
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
readonly id: "getStartSourceFile";
readonly presets: ["logical"];
}, object, object, "missingSourceFile", undefined>, Rule<{
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
readonly id: "invalidCodeLines";
readonly presets: ["logical"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic")[];
url: string;
}, object, object, "singleLineTest", AnyOptionalSchema>, ... 4 more ..., Rule<...>]>
flint
} from "@flint.fyi/plugin-flint";
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 ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
} 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 ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
.
Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{ readonly description: "Reports getter and setter accessors for the same property that are not adjacent."; readonly id: "accessorPairGroups"; readonly presets: [...]; } & { ...; }, object, object, "notGrouped", AnyOptionalSchema>, ... 291 more ..., Rule<...>]>.files: Record<"all" | "javascript" | "typescript", 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 flint: Plugin<RuleAbout, string | undefined, [Rule<{
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
readonly id: "getStartSourceFile";
readonly presets: ["logical"];
}, object, object, "missingSourceFile", undefined>, Rule<{
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
readonly id: "invalidCodeLines";
readonly presets: ["logical"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic")[];
url: string;
}, object, object, "singleLineTest", AnyOptionalSchema>, ... 4 more ..., Rule<...>]>
flint
.
Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Requires passing `sourceFile` to `getStart()` for better performance."; readonly id: "getStartSourceFile"; readonly presets: [...]; }, object, object, "missingSourceFile", undefined>, ... 5 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "stylistic">

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 JavaScript/TypeScript and writing plugins for a linter.

flint.config.ts
import {
const flint: Plugin<RuleAbout, string | undefined, [Rule<{
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
readonly id: "getStartSourceFile";
readonly presets: ["logical"];
}, object, object, "missingSourceFile", undefined>, Rule<{
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
readonly id: "invalidCodeLines";
readonly presets: ["logical"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic")[];
url: string;
}, object, object, "singleLineTest", AnyOptionalSchema>, ... 4 more ..., Rule<...>]>
flint
} from "@flint.fyi/plugin-flint";
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 ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
} 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 ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
.
Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{ readonly description: "Reports getter and setter accessors for the same property that are not adjacent."; readonly id: "accessorPairGroups"; readonly presets: [...]; } & { ...; }, object, object, "notGrouped", AnyOptionalSchema>, ... 291 more ..., Rule<...>]>.files: Record<"all" | "javascript" | "typescript", 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 flint: Plugin<RuleAbout, string | undefined, [Rule<{
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
readonly id: "getStartSourceFile";
readonly presets: ["logical"];
}, object, object, "missingSourceFile", undefined>, Rule<{
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
readonly id: "invalidCodeLines";
readonly presets: ["logical"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic")[];
url: string;
}, object, object, "singleLineTest", AnyOptionalSchema>, ... 4 more ..., Rule<...>]>
flint
.
Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Requires passing `sourceFile` to `getStart()` for better performance."; readonly id: "getStartSourceFile"; readonly presets: [...]; }, object, object, "missingSourceFile", undefined>, ... 5 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "stylistic">

Preset lists of rules to enable on files.

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

presets
.
any
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 Flint plugins.

flint.config.ts
import {
const flint: Plugin<RuleAbout, string | undefined, [Rule<{
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
readonly id: "getStartSourceFile";
readonly presets: ["logical"];
}, object, object, "missingSourceFile", undefined>, Rule<{
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
readonly id: "invalidCodeLines";
readonly presets: ["logical"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic")[];
url: string;
}, object, object, "singleLineTest", AnyOptionalSchema>, ... 4 more ..., Rule<...>]>
flint
} from "@flint.fyi/plugin-flint";
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 ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
} 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 ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
.
Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{ readonly description: "Reports getter and setter accessors for the same property that are not adjacent."; readonly id: "accessorPairGroups"; readonly presets: [...]; } & { ...; }, object, object, "notGrouped", AnyOptionalSchema>, ... 291 more ..., Rule<...>]>.files: Record<"all" | "javascript" | "typescript", 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 flint: Plugin<RuleAbout, string | undefined, [Rule<{
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
readonly id: "getStartSourceFile";
readonly presets: ["logical"];
}, object, object, "missingSourceFile", undefined>, Rule<{
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
readonly id: "invalidCodeLines";
readonly presets: ["logical"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic")[];
url: string;
}, object, object, "singleLineTest", AnyOptionalSchema>, ... 4 more ..., Rule<...>]>
flint
.
Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Requires passing `sourceFile` to `getStart()` for better performance."; readonly id: "getStartSourceFile"; readonly presets: [...]; }, object, object, "missingSourceFile", undefined>, ... 5 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "stylistic">

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
,
},
],
});
Implemented: 5 of 12 (41.6%)
Flint RulePreset
invalidCodeLinesReports cases for invalid code that isn't formatted across lines.logical
missingPlaceholdersReports context.report() calls missing data for message placeholders.logical
nodePropertyInChecksDisallows using the in operator to check properties on TypeScript nodes.logical
ruleDescriptionslogical
rulePresetslogical
ruleURLslogical
testCaseDuplicatesReports test cases that are identical to previous test cases.logical
testCaseOnlieslogical
unusedMessageIdslogical
unusedPlaceholderslogical
messagePhraseslogical (strict)
testShorthandsTest cases with only a code property can use string shorthand syntax instead of object literal syntax.stylistic
Made with ❤️‍🔥 around the world by the Flint team and contributors.