Skip to content

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.

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

Flint’s browser plugin provides the following presets:

PresetRecommendedDescription
logical✅ AlwaysCommon rules for finding bugs and good practices in browsers and browser-like runtimes.
logicalStrict☑️ When ReadyAdditional rules for finding bugs and good practices in browsers and browser-like runtimes.
stylistic✅ AlwaysCommon rules for consistent styling in browsers and browser-like runtimes.
stylisticStrict☑️ When ReadyAdditional 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:

flint.config.ts
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.

@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 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.

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

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.

@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 JavaScript/TypeScript and linting, Flint recommends using the logicalStrict and stylisticStrict presets:

flint.config.ts
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.

@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 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.

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

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.

@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 browser and DOM practices for most-to-all JavaScript and TypeScript files.

flint.config.ts
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.

@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 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.

@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 using a linter.

flint.config.ts
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.

@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 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.

@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 JavaScript and TypeScript files dealing with browser APIs.

flint.config.ts
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.

@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 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.

@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 JavaScript/TypeScript and using a linter.

flint.config.ts
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.

@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 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.

@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.

Flint RulePreset
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)
Made with ❤️‍🔥 around the world by the Flint team and contributors.