Skip to content

JSX Plugin

Flint’s JSX plugin includes rules targeted to code that renders JSX.

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

Flint’s JSX plugin provides the following presets:

PresetRecommendedDescription
logical✅ AlwaysCommon rules for finding bugs and enforcing good logical practices for JSX.
logicalStrict☑️ When ReadyAdditional rules for finding bugs and enforcing good logical practices for JSX.
stylistic✅ AlwaysCommon rules for consistent styling and best JSX stylistic practices for JSX.

If you are just getting started with linting, Flint recommends using the logical and stylistic presets:

flint.config.ts
import { jsx } from "@flint.fyi/plugin-jsx";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: jsx.files.all,
rules: [jsx.presets.logical, jsx.presets.stylistic],
},
],
});

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

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

Rules that find bugs and enforce best practices and catch common pitfalls around JSX for most-to-all JavaScript and TypeScript files.

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

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

Rules that enforce consistent JSX styling and best JSX stylistic practices for most-to-all JavaScript and TypeScript files.

flint.config.ts
import { jsx } from "@flint.fyi/plugin-jsx";
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: jsx.files.all,
rules: jsx.presets.stylistic,
},
],
});
Implemented: 3 of 43 (6.9%)
Flint NamePresetBiome Rule(s)Deno Lint Rule(s)ESLint Rule(s)Oxlint Rule(s)
accessKeysLogicaljsx-a11y/no-access-keyjsx-a11y/no-access-key
altTextLogicaljsx-a11y/alt-textjsx_a11y/alt-text
anchorContentLogicaljsx-a11y/anchor-contentjsx_a11y/anchor-has-content
anchorValidityLogicaljsx-a11y/anchor-is-validjsx_a11y/anchor-is-valid
ariaActiveDescendantTabIndexLogicaljsx-a11y/aria-activedescendant-has-tabindexjsx_a11y/aria-activedescendant-has-tabindex
ariaPropsLogicaljsx-a11y/aria-propsjsx_a11y/aria-props
ariaPropTypesLogicaljsx-a11y/aria-proptypes
ariaRolesLogicaljsx-a11y/aria-rolejsx_a11y/aria-role
ariaUnsupportedElementsLogicaljsx-a11y/aria-unsupported-elementsjsx_a11y/aria-unsupported-elements
autocompleteLogicaljsx-a11y/autocomplete-validjsx_a11y/autocomplete-valid
autoFocusPropsLogicaljsx-a11y/no-autofocusjsx_a11y/no-autofocus
clickEventKeyEventsLogicaljsx-a11y/click-events-have-key-eventsjsx_a11y/click-events-have-key-events
distractingElementsLogicaljsx-a11y/no-distracting-elementsjsx_a11y/no-distracting-elements
duplicatePropsLogicaljsx-no-duplicate-props
duplicateSpreadsLogicaljsx-props-no-spread-multi
headingContentsLogicaljsx-a11y/heading-has-content
htmlLangsLogicaljsx-a11y/html-has-langjsx_a11y/html-has-lang
iframeTitlesLogicaljsx-a11y/iframe-has-titlejsx_a11y/iframe-has-title
imageAltRedundancyLogicaljsx-a11y/img-redundant-altjsx_a11y/img-redundant-alt
interactiveElementNonInteractiveRolesLogicaljsx-a11y/no-interactive-element-to-noninteractive-role
interactiveElementsFocusableLogicaljsx-a11y/interactive-elements-focusable
labelAssociatedControlsLogicaljsx-a11y/label-has-associated-controljsx_a11y/label-has-associated-control
mediaCaptionsLogicaljsx-a11y/media-has-captionjsx_a11y/media-has-caption
mouseEventKeyEventsLogicaljsx-a11y/mouse-events-have-key-eventsjsx_a11y/mouse-events-have-key-events
nonInteractiveElementInteractionsLogicaljsx-a11y/no-noninteractive-element-interactions
nonInteractiveElementInteractiveRolesLogicaljsx-a11y/no-noninteractive-element-to-interactive-role
nonInteractiveElementTabIndexesLogicaljsx-a11y/no-noninteractive-tabindexjsx_a11y/no-noninteractive-tabindex
roleRedundanciesLogicaljsx-a11y/no-redundant-rolesjsx_a11y/no-redundant-roles
roleRequiredAriaPropsLogicaljsx-a11y/role-has-required-aria-propsjsx_a11y/role-has-required-aria-props
ruleSupportedAriaPropsLogicaljsx-a11y/role-supports-aria-propsjsx_a11y/role-supports-aria-props
scopePropsLogicaljsx-a11y/scopejsx_a11y/scope
staticElementInteractionsLogicaljsx-a11y/no-static-element-interactions
svgTitlesLogicalnoSvgWithoutTitle
tabIndexPositiveValuesLogicaljsx-a11y/tabindex-no-positivejsx_a11y/tabindex-no-positive
anchorAmbiguousTextLogical (Strict)jsx-a11y/anchor-ambiguous-textjsx-a11y/anchor-ambiguous-text
ariaHiddenFocusablesLogical (Strict)jsx-a11y/no-aria-hidden-on-focusablejsx_a11y/no-aria-hidden-on-focusable
langValidityLogical (Strict)jsx-a11y/langjsx_a11y/lang
roleTagsLogical (Strict)jsx-a11y/prefer-tag-over-rolejsx_a11y/prefer-tag-over-role
validElementChildrenLogical (Strict)jsx-void-dom-elements-no-children
booleanValuesStylisticjsx-boolean-value
bracedStatementsStylisticjsx-curly-braces
unescapedEntitiesStylisticjsx-no-unescaped-entities
unnecessaryFragmentsStylisticjsx-no-useless-fragment

Flint’s JSX plugin provides the following file selector:

  • all: **/*.{jsx,tsx}
Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.