diff --git a/docs/rules/no-multi-comp.md b/docs/rules/no-multi-comp.md
index fb61677f87..1e38c10a10 100644
--- a/docs/rules/no-multi-comp.md
+++ b/docs/rules/no-multi-comp.md
@@ -69,7 +69,7 @@ class HelloJohn extends React.Component {
module.exports = HelloJohn;
```
-### `ignorePrivate`
+### `ignoreInternal`
When `true` the rule will ignore components which are not exported, which allows you to define components that are consumed only within the same file.
This ensures there is only one entry point for a React component without limiting the structural content of the file.
diff --git a/lib/rules/no-multi-comp.js b/lib/rules/no-multi-comp.js
index 8da20e02b5..b07251d465 100644
--- a/lib/rules/no-multi-comp.js
+++ b/lib/rules/no-multi-comp.js
@@ -39,7 +39,7 @@ module.exports = {
default: false,
type: 'boolean',
},
- ignorePrivate: {
+ ignoreInternal: {
default: false,
type: 'boolean',
},
@@ -51,7 +51,7 @@ module.exports = {
create: Components.detect((context, components, utils) => {
const configuration = context.options[0] || {};
const ignoreStateless = configuration.ignoreStateless || false;
- const ignorePrivate = configuration.ignorePrivate || false;
+ const ignoreInternal = configuration.ignoreInternal || false;
const exportedComponents = new Set(); // Track exported components
const validIdentifiers = new Set(['ArrowFunctionExpression', 'Identifier', 'FunctionExpression']);
@@ -109,7 +109,7 @@ module.exports = {
* @returns {boolean} True if the component is exported or exportOnly is false
*/
function isPrivate(component) {
- return ignorePrivate && exportedComponents.has(findComponentIdentifierFromComponent(component));
+ return ignoreInternal && exportedComponents.has(findComponentIdentifierFromComponent(component));
}
const rule = {
@@ -123,8 +123,8 @@ module.exports = {
.slice(1)
.forEach((component) => {
report(context,
- ignorePrivate ? messages.onlyOneExportedComponent : messages.onlyOneComponent,
- ignorePrivate ? 'onlyOneExportedComponent' : 'onlyOneComponent',
+ ignoreInternal ? messages.onlyOneExportedComponent : messages.onlyOneComponent,
+ ignoreInternal ? 'onlyOneExportedComponent' : 'onlyOneComponent',
{
node: component.node,
});
@@ -132,14 +132,15 @@ module.exports = {
},
};
- if (ignorePrivate) {
- rule.ExportNamedDeclaration = (node) => {
- exportedComponents.add(getExportedComponentName(node));
- };
-
- rule.ExportDefaultDeclaration = (node) => {
- exportedComponents.add(getExportedComponentName(node));
- };
+ if (ignoreInternal) {
+ Object.assign(rule, {
+ ExportNamedDeclaration(node) {
+ exportedComponents.add(getExportedComponentName(node));
+ },
+ ExportDefaultDeclaration(node) {
+ exportedComponents.add(getExportedComponentName(node));
+ },
+ });
}
return rule;
diff --git a/tests/lib/rules/no-multi-comp.js b/tests/lib/rules/no-multi-comp.js
index 2a8b2611d7..b39e2a07ff 100644
--- a/tests/lib/rules/no-multi-comp.js
+++ b/tests/lib/rules/no-multi-comp.js
@@ -270,14 +270,14 @@ ruleTester.run('no-multi-comp', rule, {
const ComponentOne = () => <>>;
const ComponentTwo = () => <>>;
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
export const ComponentOne = () => <>>;
const ComponentTwo = () => <>>;
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -285,7 +285,7 @@ ruleTester.run('no-multi-comp', rule, {
const ComponentTwo = () => <>>;
module.exports = { ComponentOne };
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -293,7 +293,7 @@ ruleTester.run('no-multi-comp', rule, {
const ComponentTwo = () => <>>;
export default ComponentOne;
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -301,7 +301,7 @@ ruleTester.run('no-multi-comp', rule, {
const ComponentTwo = () => <>>;
export default ComponentOne;
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -309,7 +309,7 @@ ruleTester.run('no-multi-comp', rule, {
function ComponentTwo() { return <>> };
export default ComponentOne;
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -317,7 +317,7 @@ ruleTester.run('no-multi-comp', rule, {
export class ComponentOne extends Component() { render() { return <>>; }};
function ComponentTwo() { return <>> };
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -326,7 +326,7 @@ ruleTester.run('no-multi-comp', rule, {
function ComponentTwo() { return <>> };
export default ComponentOne;
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -334,14 +334,14 @@ ruleTester.run('no-multi-comp', rule, {
const ComponentTwo = () => <>>;
export { ComponentOne };
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
export function ComponentOne() { return <>>; }
function ComponentTwo() { return <>>; }
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -349,7 +349,7 @@ ruleTester.run('no-multi-comp', rule, {
const ComponentTwo = () => <>>;
module.exports = ComponentOne;
`,
- options: [{ ignorePrivate: true }],
+ options: [{ ignoreInternal: true }],
},
{
code: `
@@ -357,7 +357,7 @@ ruleTester.run('no-multi-comp', rule, {
const ComponentTwo = () => <>>;
export default function() { return