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.
npm install @flint.fyi/plugin-flintbun install @flint.fyi/plugin-flintdeno install @flint.fyi/plugin-flintpnpm install @flint.fyi/plugin-flintyarn install @flint.fyi/plugin-flintPresets
Section titled “Presets”logical
Section titled “logical”Rules that find bugs and enforce good practices for Flint plugins and rules.
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.
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.
defineConfig({ ConfigDefinition.use: ConfigUseDefinition[]
Specifies the files to be linted alongside the rules and settings to lint with.
use: [ { ConfigUseDefinition.files: AnyLevelDeep<FilesValue>
A list of glob patterns describing which file(s) to lint.
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.
files.all: FilesValue
all, ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>
Any number of rules and/or presets of rules to enable for those files.
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.
presets.logical: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
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 JavaScript/TypeScript and writing plugins for a linter.
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.
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.
defineConfig({ ConfigDefinition.use: ConfigUseDefinition[]
Specifies the files to be linted alongside the rules and settings to lint with.
use: [ { ConfigUseDefinition.files: AnyLevelDeep<FilesValue>
A list of glob patterns describing which file(s) to lint.
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.
files.all: FilesValue
all, ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>
Any number of rules and/or presets of rules to enable for those files.
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.
presets.any
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 Flint plugins.
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.
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.
defineConfig({ ConfigDefinition.use: ConfigUseDefinition[]
Specifies the files to be linted alongside the rules and settings to lint with.
use: [ { ConfigUseDefinition.files: AnyLevelDeep<FilesValue>
A list of glob patterns describing which file(s) to lint.
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.
files.all: FilesValue
all, ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>
Any number of rules and/or presets of rules to enable for those files.
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.
presets.stylistic: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
stylistic, }, ],});Implemented: 5 of 12 (41.6%)
| Flint Rule | Preset |
|---|---|
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 |
ruleDescriptions | logical |
rulePresets | logical |
ruleURLs | logical |
testCaseDuplicatesReports test cases that are identical to previous test cases. | logical |
testCaseOnlies | logical |
unusedMessageIds | logical |
unusedPlaceholders | logical |
messagePhrases | logical (strict) |
testShorthandsTest cases with only a code property can use string shorthand syntax instead of object literal syntax. | stylistic |