Skip to content

Browser Plugin

Flint’s browser plugin includes rules targeted to code that runs in browsers and browser-like environments.

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 { browser } from "@flint.fyi/browser";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: [browser.presets.logical, browser.presets.stylistic],
},
],
});

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

flint.config.ts
import { browser } from "@flint.fyi/browser";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: [browser.presets.logicalStrict, browser.presets.stylisticStrict],
},
],
});

Rules that find bugs and enforce good browser and DOM practices for most-to-all JavaScript and TypeScript files.

flint.config.ts
import { browser } from "@flint.fyi/browser";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: browser.presets.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 { browser } from "@flint.fyi/browser";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: browser.presets.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 { browser } from "@flint.fyi/browser";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: browser.presets.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 { browser } from "@flint.fyi/browser";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: browser.presets.stylisticStrict,
},
],
});

This preset’s rules are a superset of those in stylistic.

Implemented: 2 of 14 (14.2%)
Flint NamePresetBiome Rule(s)Deno Lint Rule(s)ESLint Rule(s)Oxlint Rule(s)
alertsLogicalnoAlertno-alerteslint/no-alert
implicitGlobalsLogicalno-implicit-globals
removeEventListenerExpressionsLogicalunicorn/no-invalid-remove-event-listenerunicorn/no-invalid-remove-event-listener
scriptUrlsLogicalno-script-urleslint/no-script-url
documentCookiesLogical (Strict)noDocumentCookieunicorn/no-document-cookieunicorn/no-document-cookie
eventClassesLogical (Strict)unicorn/prefer-event-targetunicorn/prefer-event-target
eventListenerSubscriptionsLogical (Strict)unicorn/prefer-add-event-listenerunicorn/prefer-add-event-listener
nodeAppendMethodsLogical (Strict)unicorn/prefer-dom-node-appendunicorn/prefer-dom-node-append
nodeDatasetAttributesLogical (Strict)unicorn/prefer-dom-node-datasetunicorn/prefer-dom-node-dataset
nodeModificationMethodsLogical (Strict)unicorn/prefer-modern-dom-apisunicorn/prefer-modern-dom-apis
nodeRemoveMethodsLogical (Strict)unicorn/prefer-dom-node-removeunicorn/prefer-dom-node-remove
nodeTextContentsLogical (Strict)unicorn/prefer-dom-node-text-contentunicorn/prefer-dom-node-text-content
classListTogglesStylisticunicorn/prefer-classlist-toggle
nodeQueryMethodsStylistic (Strict)unicorn/prefer-query-selectorunicorn/prefer-query-selector
Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.