Migrating from eslint-plugin-react
Complete guide for migrating from eslint-plugin-react to ESLint React
This guide provides a comprehensive comparison between eslint-plugin-react and ESLint React rules to help you migrate your existing configuration.
Index
- Overview
- Rule Comparison Table
- Gradual Migration
- Custom Rules For Missing Rules
checked-requires-onchange-or-readonlyforbid-component-propsforbid-dom-propsforbid-elementsfunction-component-definitionjsx-boolean-valuejsx-fragmentsjsx-handler-namesjsx-max-depthjsx-no-bindjsx-no-duplicate-propsjsx-no-literalsjsx-pascal-casejsx-props-no-spread-multijsx-props-no-spreadingno-adjacent-inline-elementsno-multi-comp
Overview
ESLint React is designed as a modern replacement for eslint-plugin-react with improved performance, better TypeScript support, and more accurate rule implementations.
However, not all rules have direct equivalents, and some behave differently.
Rule Comparison Table
Legend
- 🔧 Fully supported - Rule is supported, and has an auto-fix
- ✅ Mostly supported - Rule is supported but doesn't have an auto-fix
- 🟡 Partial support - Similar but not identical functionality
- ❌ Not supported - No equivalent rule
- ➡️ External plugin - Rule is available in another ESLint plugin
- 🚫 Legacy - Rule is not applicable in modern TypeScript React development (ex: class-based components,
propTypes) - ⚠️ Warning - Rule has been deprecated in
eslint-plugin-react
A variety of rules are marked legacy, but still have equivalent rules. This distinction was done to more accurately assess
migration for React written with function components and no longer use propTypes.
Table
The following table compares all rules from eslint-plugin-react with their ESLint React (or external) equivalents:
ESLint React Column
- Rule names link to ESLint React documentation
- Multiple rules separated by
/indicate alternative approaches - Rules with
+indicate multiple rules that together provide equivalent functionality
Gradual Migration
You can migrate gradually by using both plugins together, using the disableConflictEslintPluginReact ruleset:
import eslintReact from "@eslint-react/eslint-plugin";
import pluginReact from "eslint-plugin-react";
import { defineConfig } from "eslint/config";
export default defineConfig([
// Start with the eslint-plugin-react
{
files: ["**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}"],
extends: [
// Whatever config you had enabled with eslint-plugin-react
pluginReact.configs.flat.recommended,
// Now disable all conflicting rules
eslintReact.configs["disable-conflict-eslint-plugin-react"],
// Now enable the desired rules
eslintReact.configs["recommended-typescript"],
],
},
]);Once you have fully migrated, you can remove eslint-plugin-react entirely and rely solely on ESLint React:
import eslintReact from "@eslint-react/eslint-plugin";
import { defineConfig } from "eslint/config";
export default defineConfig([
{
files: ["**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}"],
extends: [
eslintReact.configs["recommended-typescript"],
],
},
]);Custom Rules For Missing Rules
Some eslint-plugin-react rules don't have built-in equivalents in ESLint React, or you may want to customize their behavior.
You can use @eslint-react/kit to create minimal custom rule implementations directly in your eslint.config.ts.
Install @eslint-react/kit first:
npm install --save-dev @eslint-react/kitBelow are drop-in rule definitions for the most commonly needed rules. Register them via the .use() chain in your config:
import eslintReact from "@eslint-react/eslint-plugin";
import eslintReactKit from "@eslint-react/kit";
import { defineConfig } from "eslint/config";
import {
checkedRequiresOnchangeOrReadonly,
forbidComponentProps,
forbidDomProps,
forbidElements,
functionComponentDefinition,
jsxBooleanValue,
jsxFragments,
jsxHandlerNames,
jsxMaxDepth,
jsxNoBind,
jsxNoDuplicateProps,
jsxNoLiterals,
jsxPascalCase,
jsxPropsNoSpreadMulti,
jsxPropsNoSpreading,
noAdjacentInlineElements,
noMultiComp,
} from "./eslint.config.rules";
export default defineConfig([
{
files: ["**/*.{ts,tsx}"],
extends: [
eslintReact.configs["recommended-typescript"],
eslintReactKit()
.use(checkedRequiresOnchangeOrReadonly)
.use(forbidComponentProps, { forbidden: ["className", "style"] })
.use(forbidDomProps, { forbidden: ["style", "className"] })
.use(jsxFragments)
.use(jsxHandlerNames, { eventHandlerPrefix: "handle", eventHandlerPropPrefix: "on" })
.use(jsxMaxDepth, { max: 3 })
.use(jsxNoDuplicateProps)
.use(jsxNoLiterals, { noStrings: true, allowedStrings: ["allowed"] })
.use(jsxPascalCase)
.use(jsxPropsNoSpreadMulti)
.use(noAdjacentInlineElements)
.use(noMultiComp)
.use(forbidElements, {
forbidden: new Map([
["button", "Use <Button> from '@/components/ui' instead."],
["input", "Use <Input> from '@/components/ui' instead."],
]),
})
.use(functionComponentDefinition)
.use(jsxBooleanValue)
.use(jsxNoBind)
.use(jsxPropsNoSpreading)
.getConfig(),
],
},
]);checked-requires-onchange-or-readonly
Require onChange or readOnly when using checked on <input>.
import type { RuleDefinition } from "@eslint-react/kit";
/** Require `onChange` or `readOnly` when using `checked` on `<input>`. */
export function checkedRequiresOnchangeOrReadonly(): RuleDefinition {
return (context) => ({
JSXOpeningElement(node) {
const name = node.name.type === "JSXIdentifier" ? node.name.name : null;
if (name !== "input") return;
const attrs = new Set<string>();
for (const attr of node.attributes) {
if (attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier") {
attrs.add(attr.name.name);
}
}
if (!attrs.has("checked")) return;
if (!attrs.has("onChange") && !attrs.has("readOnly")) {
context.report({
node,
message: "`checked` requires `onChange` or `readOnly`.",
});
}
},
});
}forbid-component-props
Forbid certain props on React components (not DOM elements). Only reports on PascalCase elements.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link forbidComponentProps}. */
export type ForbidComponentPropsOptions = {
/** Prop names that are not allowed on React components. */
forbidden: string[];
};
/** Forbid certain props on React components (not DOM elements). */
export function forbidComponentProps({ forbidden }: ForbidComponentPropsOptions): RuleDefinition {
return (context) => ({
JSXAttribute(node) {
const propName = node.name.type === "JSXIdentifier" ? node.name.name : null;
if (propName == null || !forbidden.includes(propName)) return;
const parent = node.parent;
if (parent?.type !== "JSXOpeningElement") return;
const elemName = parent.name.type === "JSXIdentifier" ? parent.name.name : null;
// Only report on components (PascalCase names), not DOM elements
if (elemName == null || elemName[0] !== elemName[0]?.toUpperCase()) return;
context.report({
node,
message: `Prop "${propName}" is forbidden on components.`,
});
},
});
}forbid-dom-props
Forbid certain props on DOM elements (not React components). Only reports on lowercase DOM element names.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link forbidDomProps}. */
export type ForbidDomPropsOptions = {
/** Prop names that are not allowed on DOM elements. */
forbidden: string[];
};
/** Forbid certain props on DOM elements (not React components). */
export function forbidDomProps({ forbidden }: ForbidDomPropsOptions): RuleDefinition {
return (context) => ({
JSXAttribute(node) {
const propName = node.name.type === "JSXIdentifier" ? node.name.name : null;
if (propName == null || !forbidden.includes(propName)) return;
const parent = node.parent;
if (parent?.type !== "JSXOpeningElement") return;
const elemName = parent.name.type === "JSXIdentifier" ? parent.name.name : null;
// Only report on DOM elements (lowercase names), not components
if (elemName == null || elemName[0] !== elemName[0]?.toLowerCase()) return;
context.report({
node,
message: `Prop "${propName}" is forbidden on DOM elements.`,
});
},
});
}forbid-elements
Forbid specific JSX elements. Customize the forbidden map with your project's requirements.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link forbidElements}. */
export type ForbidElementsOptions = {
/** A map from element name to the error message reported when that element is used. */
forbidden: Map<string, string>;
};
/** Forbid specific JSX elements. */
export function forbidElements({ forbidden }: ForbidElementsOptions): RuleDefinition {
return (context) => ({
JSXOpeningElement(node) {
const name = node.name.type === "JSXIdentifier" ? node.name.name : null;
if (name != null && forbidden.has(name)) {
context.report({ node, message: forbidden.get(name)! });
}
},
});
}function-component-definition
Enforce arrow function definitions for function components.
import type { RuleDefinition } from "@eslint-react/kit";
import { merge } from "@eslint-react/kit";
/** Enforce arrow function definitions for function components. */
export function functionComponentDefinition(): RuleDefinition {
return (context, { collect }) => {
const { query, visitor } = collect.components(context);
return merge(
visitor,
{
"Program:exit"(program) {
for (const { node } of query.all(program)) {
if (node.type === "ArrowFunctionExpression") continue;
context.report({
node,
message: "Function components must be defined with arrow functions.",
suggest: [
{
desc: "Convert to arrow function.",
fix(fixer) {
const src = context.sourceCode;
if (node.generator) return null;
const prefix = node.async ? "async " : "";
const typeParams = node.typeParameters ? src.getText(node.typeParameters) : "";
const params = `(${node.params.map((p) => src.getText(p)).join(", ")})`;
const returnType = node.returnType ? src.getText(node.returnType) : "";
const body = src.getText(node.body);
// function Foo(params) { ... } -> const Foo = (params) => { ... };
if (node.type === "FunctionDeclaration" && node.id) {
// dprint-ignore
return fixer.replaceText(node, `const ${node.id.name} = ${prefix}${typeParams}${params}${returnType} => ${body};`);
}
// const Foo = function(params) { ... } -> const Foo = (params) => { ... }
if (node.type === "FunctionExpression" && node.parent.type === "VariableDeclarator") {
// dprint-ignore
return fixer.replaceText(node, `${prefix}${typeParams}${params}${returnType} => ${body}`);
}
// { Foo(params) { ... } } -> { Foo: (params) => { ... } }
if (node.type === "FunctionExpression" && node.parent.type === "Property") {
// dprint-ignore
return fixer.replaceText(node.parent, `${src.getText(node.parent.key)}: ${prefix}${typeParams}${params}${returnType} => ${body}`);
}
return null;
},
},
],
});
}
},
},
);
};
}jsx-boolean-value
Enforce shorthand for boolean JSX attributes (e.g. prefer <C disabled /> over <C disabled={true} />).
import type { RuleDefinition } from "@eslint-react/kit";
/** Enforce shorthand for boolean JSX attributes. */
export function jsxBooleanValue(): RuleDefinition {
return (context) => ({
JSXAttribute(node) {
const { value } = node;
if (value?.type !== "JSXExpressionContainer") return;
if (value.expression.type !== "Literal" || value.expression.value !== true) return;
context.report({
node,
message: "Omit the value for boolean attributes.",
fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]]),
});
},
});
}jsx-fragments
Enforce shorthand syntax for React fragments. Reports when <React.Fragment> is used instead of <>...</>. Allows standard form when key prop is present.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link jsxFragments}. */
export type JsxsFragmentsOptions = {
/** The mode to enforce: "syntax" (default, shorthand) or "element" (standard form). */
mode?: "syntax" | "element";
};
/** Enforce shorthand or standard form for React fragments. */
export function jsxFragments({ mode = "syntax" }: JsxsFragmentsOptions = {}): RuleDefinition {
return (context) => {
function reportSyntaxPreferred(node: TSESTree.JSXOpeningElement, pattern: "React.Fragment" | "Fragment") {
const hasAttributes = node.attributes.length > 0;
if (hasAttributes) return;
context.report({
node,
message: `Use shorthand fragment syntax '<>...</>' instead of '<${pattern}>...</${pattern}'.`,
fix(fixer) {
const closing = node.parent?.closingElement;
if (!closing) return null;
return [fixer.replaceText(node, "<>"), fixer.replaceText(closing, "</>")];
},
});
}
return {
JSXOpeningElement(node) {
const name = node.name;
// Handle standalone <Fragment> (JSXIdentifier)
if (name.type === "JSXIdentifier" && name.name === "Fragment") {
if (mode === "syntax") {
reportSyntaxPreferred(node, "Fragment");
}
return;
}
// Handle <React.Fragment> (JSXMemberExpression)
if (name.type !== "JSXMemberExpression") return;
if (name.object.type !== "JSXIdentifier" || name.object.name !== "React") return;
if (name.property.type !== "JSXIdentifier" || name.property.name !== "Fragment") return;
if (mode === "syntax") {
reportSyntaxPreferred(node, "React.Fragment");
}
},
JSXFragment(node) {
if (mode === "element") {
context.report({
node,
message: "Use '<React.Fragment>...</React.Fragment>' instead of shorthand '<>...</>'.",
fix(fixer) {
return [
fixer.replaceText(node.openingFragment, "<React.Fragment>"),
fixer.replaceText(node.closingFragment, "</React.Fragment>"),
];
},
});
}
},
};
};
}jsx-handler-names
Enforce naming convention for JSX event handler props and the functions they reference.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link jsxHandlerNames}. */
export type JsxHandlerNamesOptions = {
/** Prefix for event handler functions (default: "handle"). */
eventHandlerPrefix?: string;
/** Prefix for event handler props (default: "on"). */
eventHandlerPropPrefix?: string;
/** Whether to check inline functions (default: false). */
checkInlineFunction?: boolean;
};
/** Enforce naming convention for JSX event handlers. */
export function jsxHandlerNames({
eventHandlerPrefix = "handle",
eventHandlerPropPrefix = "on",
checkInlineFunction = false,
}: JsxHandlerNamesOptions = {}): RuleDefinition {
const EVENT_HANDLER_REGEX = new RegExp(`^${eventHandlerPropPrefix}[A-Z]`);
const HANDLER_FUNC_REGEX = new RegExp(`^${eventHandlerPrefix}[A-Z]`);
return (context) => ({
JSXAttribute(node) {
if (node.name.type !== "JSXIdentifier") return;
const propName = node.name.name;
if (!EVENT_HANDLER_REGEX.test(propName)) return;
const value = node.value;
if (!value) return;
if (value.type === "JSXExpressionContainer") {
const expression = value.expression;
if (expression.type === "Identifier") {
const handlerName = expression.name;
if (!HANDLER_FUNC_REGEX.test(handlerName)) {
context.report({
node: expression,
message: `Handler function "${handlerName}" should be named "${eventHandlerPrefix}${
propName.slice(eventHandlerPropPrefix.length)
}..."`,
});
}
return;
}
if (expression.type === "ArrowFunctionExpression" || expression.type === "FunctionExpression") {
if (checkInlineFunction) {
context.report({
node: expression,
message:
`Inline function handlers are not allowed for "${propName}". Extract it to a named "${eventHandlerPrefix}${
propName.slice(eventHandlerPropPrefix.length)
}" function.`,
});
}
return;
}
}
},
});
}jsx-max-depth
Enforce a maximum depth for JSX elements.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link jsxMaxDepth}. */
export type JsxMaxDepthOptions = {
/** Maximum allowed depth for JSX elements. */
max: number;
};
/** Enforce JSX maximum depth. */
export function jsxMaxDepth({ max }: JsxMaxDepthOptions): RuleDefinition {
return (context) => ({
JSXElement(node) {
let depth = 0;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let parent: any = node.parent;
while (parent) {
if (parent.type === "JSXElement") {
depth++;
}
parent = parent.parent;
}
if (depth > max) {
context.report({
node,
message: `JSX element exceeds maximum depth of ${max} (found ${depth}).`,
});
}
},
});
}jsx-no-bind
Prevent arrow functions, function expressions, and .bind() in JSX props.
import type { RuleDefinition } from "@eslint-react/kit";
/** Prevent inline functions and `.bind()` in JSX props. */
export function jsxNoBind(): RuleDefinition {
return (context) => ({
JSXAttribute(node) {
const value = node.value;
if (value?.type !== "JSXExpressionContainer") return;
switch (true) {
case value.expression.type === "ArrowFunctionExpression":
case value.expression.type === "FunctionExpression":
context.report({ node, message: "JSX props should not use inline functions." });
break;
case value.expression.type === "CallExpression"
&& value.expression.callee.type === "MemberExpression"
&& value.expression.callee.property.type === "Identifier"
&& value.expression.callee.property.name === "bind":
context.report({ node, message: "JSX props should not use .bind()." });
break;
}
},
});
}jsx-no-duplicate-props
Disallow duplicate properties in JSX elements.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link jsxNoDuplicateProps}. */
export type JsxNoDuplicatePropsOptions = {
/** Whether to ignore case when checking for duplicate props. */
ignoreCase?: boolean;
};
/** Disallow duplicate properties in JSX. */
export function jsxNoDuplicateProps({ ignoreCase = false }: JsxNoDuplicatePropsOptions = {}): RuleDefinition {
return (context) => ({
JSXOpeningElement(node) {
const seen = new Map<string, string>();
for (const attr of node.attributes) {
if (attr.type !== "JSXAttribute") continue;
if (attr.name.type !== "JSXIdentifier") continue;
const name = ignoreCase ? attr.name.name.toLowerCase() : attr.name.name;
if (seen.has(name)) {
context.report({
node: attr,
message: `Duplicate prop "${attr.name.name}" found.`,
});
} else {
seen.set(name, attr.name.name);
}
}
},
});
}jsx-no-literals
Disallow usage of string literals in JSX. By default requires wrapping strings in JSX expressions {'TEXT'}.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link jsxNoLiterals}. */
export type JsxNoLiteralsOptions = {
/** Enforces no string literals used as children, wrapped or unwrapped. */
noStrings?: boolean;
/** An array of unique string values that would otherwise warn, but will be ignored. */
allowedStrings?: string[];
/** When `true` the rule ignores literals used in props. */
ignoreProps?: boolean;
};
/** Disallow usage of string literals in JSX. */
export function jsxNoLiterals(
{ noStrings = false, allowedStrings = [], ignoreProps = true }: JsxNoLiteralsOptions = {},
): RuleDefinition {
const allowedSet = new Set(allowedStrings);
return (context) => ({
Literal(node) {
if (typeof node.value !== "string") return;
const text = node.value.trim();
if (text === "" || allowedSet.has(text)) return;
const parent = node.parent;
if (!parent) return;
if (parent.type === "JSXAttribute") {
if (!ignoreProps) {
context.report({
node,
message: `String literals are not allowed in JSX props. Use {'${text}'} instead.`,
});
}
return;
}
if (parent.type === "JSXExpressionContainer") return;
if (parent.type === "JSXElement" || parent.type === "JSXFragment") {
if (noStrings) {
context.report({
node,
message: `String literals are not allowed as JSX children.`,
});
} else {
context.report({
node,
message: `String literals should be wrapped in JSX expression: {'${text}'}`,
});
}
}
},
JSXText(node) {
const text = node.value.trim();
if (text === "" || allowedSet.has(text)) return;
if (noStrings) {
context.report({
node,
message: `String literals are not allowed as JSX children.`,
});
} else {
context.report({
node,
message: `String literals should be wrapped in JSX expression: {'${text}'}`,
});
}
},
});
}jsx-pascal-case
Enforce PascalCase for user-defined JSX components. DOM elements like <div> are ignored.
import type { RuleDefinition } from "@eslint-react/kit";
/** Options for {@link jsxPascalCase}. */
export type JsxPascalCaseOptions = {
/** Allow all-uppercase component names like `<XML />`. */
allowAllCaps?: boolean;
/** Allow leading underscores in component names like `<_Component />`. */
allowLeadingUnderscore?: boolean;
};
/** Enforce PascalCase for user-defined JSX components. */
export function jsxPascalCase(
{ allowAllCaps = false, allowLeadingUnderscore = false }: JsxPascalCaseOptions = {},
): RuleDefinition {
return (context) => ({
JSXOpeningElement(node) {
const name = node.name;
if (name.type !== "JSXIdentifier") return;
const componentName = name.name;
// Check for leading underscore (before lowercase check since "_".toLowerCase() === "_")
if (componentName.startsWith("_")) {
if (!allowLeadingUnderscore) {
context.report({
node: name,
message: `Component name "${componentName}" should not start with an underscore.`,
});
}
return;
}
// Ignore DOM elements (lowercase first letter)
const firstChar = componentName[0];
if (firstChar === undefined) return;
if (firstChar === firstChar.toLowerCase()) return;
// Check for all caps
if (componentName === componentName.toUpperCase()) {
if (!allowAllCaps) {
context.report({
node: name,
message: `Component name "${componentName}" should use PascalCase, not all uppercase.`,
});
}
return;
}
// Check PascalCase: first letter uppercase, rest can be mixed but no underscores
const pascalCaseRegex = /^[A-Z][a-zA-Z0-9]*$/;
if (!pascalCaseRegex.test(componentName)) {
context.report({
node: name,
message: `Component name "${componentName}" should be in PascalCase.`,
});
}
},
});
}jsx-props-no-spread-multi
Disallow spreading the same expression multiple times in a JSX element.
import type { RuleDefinition } from "@eslint-react/kit";
/** Disallow JSX prop spreading the same identifier multiple times. */
export function jsxPropsNoSpreadMulti(): RuleDefinition {
return (context) => ({
JSXOpeningElement(node) {
const seen = new Set<string>();
for (const attr of node.attributes) {
if (attr.type !== "JSXSpreadAttribute") continue;
let spreadKey: string;
if (attr.argument.type === "Identifier") {
spreadKey = attr.argument.name;
} else {
spreadKey = context.sourceCode.getText(attr.argument);
}
if (seen.has(spreadKey)) {
context.report({
node: attr,
message: `Spreading the same expression "${spreadKey}" multiple times is not allowed.`,
});
} else {
seen.add(spreadKey);
}
}
},
});
}jsx-props-no-spreading
Disallow JSX props spreading.
import type { RuleDefinition } from "@eslint-react/kit";
/** Disallow JSX props spreading. */
export function jsxPropsNoSpreading(): RuleDefinition {
return (context) => ({
JSXSpreadAttribute(node) {
context.report({
node,
message: "Props spreading is not allowed.",
});
},
});
}no-adjacent-inline-elements
Disallow adjacent inline elements not separated by whitespace.
import type { RuleDefinition } from "@eslint-react/kit";
import type { TSESTree } from "@typescript-eslint/utils";
/** Disallow adjacent inline elements not separated by whitespace. */
export function noAdjacentInlineElements(): RuleDefinition {
/** Set of inline HTML elements. */
const INLINE_ELEMENTS = new Set([
"a",
"abbr",
"acronym",
"b",
"bdi",
"bdo",
"big",
"br",
"cite",
"code",
"dfn",
"em",
"i",
"img",
"input",
"kbd",
"label",
"map",
"object",
"q",
"samp",
"script",
"select",
"small",
"span",
"strong",
"sub",
"sup",
"textarea",
"time",
"tt",
"var",
]);
return (context) => ({
JSXElement(node) {
const children = node.children;
for (let i = 0; i < children.length - 1; i++) {
const current = children[i];
const next = children[i + 1];
if (current?.type !== "JSXElement") continue;
if (current.openingElement.name.type !== "JSXIdentifier") continue;
const currentName = current.openingElement.name.name;
if (!INLINE_ELEMENTS.has(currentName)) continue;
if (next?.type !== "JSXElement") continue;
if (next.openingElement.name.type !== "JSXIdentifier") continue;
const nextName = next.openingElement.name.name;
if (!INLINE_ELEMENTS.has(nextName)) continue;
context.report({
node: current,
message: `Adjacent inline elements "${currentName}" and "${nextName}" should be separated by whitespace.`,
});
}
},
});
}no-multi-comp
Prevent defining more than one component per file.
import type { RuleDefinition } from "@eslint-react/kit";
import { merge } from "@eslint-react/kit";
/** Prevent defining more than one component per file. */
export function noMultiComp(): RuleDefinition {
return (context, { collect }) => {
const { query, visitor } = collect.components(context);
return merge(visitor, {
"Program:exit"(program) {
const components = query.all(program);
for (const { node, name } of components.slice(1)) {
context.report({
node,
message: `Declare only one component per file. Found extra component "${name ?? "anonymous"}".`,
});
}
},
});
};
}