React project
Setting up Markuplint for a React (JSX/TSX) project.
What you need
Install Markuplint with the JSX parser and React spec:
- npm
- Yarn
- pnpm
- Bun
npm install -D markuplint @markuplint/jsx-parser @markuplint/react-spec
yarn add --dev markuplint @markuplint/jsx-parser @markuplint/react-spec
pnpm add -D markuplint @markuplint/jsx-parser @markuplint/react-spec
bun add --dev markuplint @markuplint/jsx-parser @markuplint/react-spec
Configuration
{
"extends": ["markuplint:recommended-react"],
"parser": {
"\\.[jt]sx$": "@markuplint/jsx-parser"
},
"specs": {
"\\.[jt]sx$": "@markuplint/react-spec"
}
}
This configuration:
- Applies the recommended-react preset (includes all base presets + React-specific rules like
no-hard-code-id) - Parses
.jsxand.tsxfiles with the JSX parser - Recognizes React-specific attributes (
key,className,htmlFor, etc.) via the React spec
Elements that React moves to the <head>
React moves <title>, <meta>, <link> and <style> (under the conditions each reference gives, such as precedence and href of <style>) to the document's <head> wherever they are written. The React spec therefore does not check them against the content model of the element that contains them, and defines the attributes that ask React to.
If your React outputs every element where it is written (the reference of each element above says whether the React you use moves it), specify the spec for it, which has neither. It is named for the last major version of React that does not move them:
{
"specs": {
"\\.[jt]sx$": "@markuplint/react-spec/react-18"
}
}
With Pretenders
Scanning needs @markuplint/pretenders, which markuplint does not install:
- npm
- Yarn
- pnpm
- Bun
npm install -D @markuplint/pretenders
yarn add --dev @markuplint/pretenders
pnpm add -D @markuplint/pretenders
bun add --dev @markuplint/pretenders
If you want Markuplint to validate your custom components as if they were native HTML elements, add the Pretenders configuration. We recommend using automatic scanning — it discovers component-to-element mappings from your source files, so you don't need to maintain them manually:
{
"extends": ["markuplint:recommended-react"],
"parser": {
"\\.[jt]sx$": "@markuplint/jsx-parser"
},
"specs": {
"\\.[jt]sx$": "@markuplint/react-spec"
},
"pretenders": {
"scan": [
{
"files": "./src/components/**/*.tsx"
}
]
}
}
The scan feature was introduced in v5. It replaces the need to manually list every component mapping — just point it at your component directory and Markuplint handles the rest.