Browser Plugin
Rules for code that runs in browsers and other environments with DOM (Document Object Model) elements.
This plugin is provided in a standalone @flint.fyi/plugin-browser npm package.
npm install @flint.fyi/plugin-browserbun install @flint.fyi/plugin-browserdeno install @flint.fyi/plugin-browserpnpm install @flint.fyi/plugin-browseryarn install @flint.fyi/plugin-browserPresets
Section titled “Presets”Flint’s browser plugin provides the following presets:
| Preset | Recommended | Description |
|---|---|---|
logical | ✅ Always | Common rules for finding bugs and good practices in browsers and browser-like runtimes. |
logicalStrict | ☑️ When Ready | Additional rules for finding bugs and good practices in browsers and browser-like runtimes. |
stylistic | ✅ Always | Common rules for consistent styling in browsers and browser-like runtimes. |
stylisticStrict | ☑️ When Ready | Additional rules for consistent styling in browsers and browser-like runtimes. |
If you are just getting started with linting, Flint recommends using the logical and stylistic presets:
import { const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser } from "@flint.fyi/browser";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 browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
Preset lists of rules to enable on files.
presets.logical: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
logical, const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
Preset lists of rules to enable on files.
presets.stylistic: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
stylistic], }, ],});If you are experienced with both JavaScript/TypeScript and linting, Flint recommends using the logicalStrict and stylisticStrict presets:
import { const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser } from "@flint.fyi/browser";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 browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
Preset lists of rules to enable on files.
presets.logicalStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
logicalStrict, const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
Preset lists of rules to enable on files.
presets.stylisticStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
stylisticStrict], }, ],});logical
Section titled “logical”Rules that find bugs and enforce good browser and DOM practices for most-to-all JavaScript and TypeScript files.
import { const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser } from "@flint.fyi/browser";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 browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
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 using a linter.
import { const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser } from "@flint.fyi/browser";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 browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
Preset lists of rules to enable on files.
presets.logicalStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
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 JavaScript and TypeScript files dealing with browser APIs.
import { const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser } from "@flint.fyi/browser";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 browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
Preset lists of rules to enable on files.
presets.stylistic: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
stylistic, }, ],});stylisticStrict
Section titled “stylisticStrict”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 JavaScript/TypeScript and using a linter.
import { const browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser } from "@flint.fyi/browser";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 browser: Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: ["logical"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "noAlert", AnyOptionalSchema>, Rule<{ readonly description: "Prefer using classList.toggle() over conditional classList.add() and classList.remove()."; readonly id: "classListToggles"; readonly presets: ["stylistic", "stylisticStrict"];} & { presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[]; url: string;}, object, object, "preferToggle", AnyOptionalSchema>, ... 12 more ..., Rule<...>]>
browser.Plugin<RuleAbout, string | undefined, [Rule<{ readonly description: "Reports uses of the global alert/confirm/prompt dialog APIs."; readonly id: "alerts"; readonly presets: [...]; } & { ...; }, object, object, "noAlert", AnyOptionalSchema>, ... 13 more ..., Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict" | "stylistic" | "stylisticStrict">
Preset lists of rules to enable on files.
presets.stylisticStrict: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
stylisticStrict, }, ],});This preset’s rules are a superset of those in stylistic.
| Flint Rule | Preset |
|---|---|
alertsReports uses of the global alert/confirm/prompt dialog APIs. | logical |
implicitGlobalsPrevents implicit global variable declarations in browser scripts. | logical |
keyboardEventKeysPrefer KeyboardEvent.key over deprecated properties like keyCode, charCode, and which. | logical |
removeEventListenerExpressionsDisallow inline function expressions in removeEventListener calls. | logical |
scriptUrlsReports javascript: URLs that can act as a form of eval. | logical |
windowMessagingTargetOriginRequires specifying the targetOrigin argument when calling window.postMessage(). | logical |
documentCookiesReports uses of document.cookie which can be error-prone and has security implications. | logical (strict) |
eventListenerSubscriptionsPrefer addEventListener over assigning to on* event handler properties. | logical (strict) |
nodeAppendMethodsPrefer modern DOM append/prepend methods over appendChild/insertBefore. | logical (strict) |
nodeDatasetAttributesPrefer using element.dataset over getAttribute/setAttribute for data-* attributes. | logical (strict) |
nodeModificationMethodsPrefer modern DOM APIs like .replaceWith() and .before() over legacy methods like .replaceChild() and .insertBefore(). | logical (strict) |
nodeRemoveMethodsPrefer the modern node.remove() method over the legacy parentNode.removeChild(node) API. | logical (strict) |
nodeTextContentsPrefer textContent over innerText for DOM nodes. | logical (strict) |
classListTogglesPrefer using classList.toggle() over conditional classList.add() and classList.remove(). | stylistic |
nodeQueryMethodsPrefer modern querySelector and querySelectorAll over legacy DOM query methods. | stylistic (strict) |