Browser Plugin
Flint’s browser plugin includes rules targeted to code that runs in browsers and browser-like environments.
npm install @flint.fyi/plugin-browser
pnpm install @flint.fyi/plugin-browser
yarn install @flint.fyi/plugin-browser
Presets
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 { 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:
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], }, ],});
logical
Section titled “logical”Rules that find bugs and enforce good browser and DOM practices for most-to-all JavaScript and TypeScript files.
import { browser } from "@flint.fyi/browser";import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: browser.presets.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 { 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
.
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 { browser } from "@flint.fyi/browser";import { defineConfig, ts } from "flint";
export default defineConfig({ use: [ { files: ts.files.all, rules: browser.presets.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 { 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%)