Skip to content

TCS-11: Add eslint-plugin-no-barrel-files rule to react config#68

Merged
brettcutt-aligent merged 4 commits into
mainfrom
feature/TCS-11_add-no-barrel-imports-eslint-rule
May 25, 2026
Merged

TCS-11: Add eslint-plugin-no-barrel-files rule to react config#68
brettcutt-aligent merged 4 commits into
mainfrom
feature/TCS-11_add-no-barrel-imports-eslint-rule

Conversation

@brettcutt-aligent
Copy link
Copy Markdown
Contributor

Description of the proposed changes
Adds eslint-plugin-no-barrel-files to the shared react ESLint config so every consuming project picks up barrel-file enforcement without configuring it locally.

  • Before: projects using eslintConfigs.react had no rule against barrel files; export * from … and re-exports of imported variables were silently allowed.

    // components/AddressForm/index.ts — passed lint
    export * from './AddressFields';
    export { default } from './AddressFields';
  • After: any such file errors with no-barrel-files/no-barrel-files (Do not use export all or Do not re-export imported variable), via the plugin's flat/recommended config.

    // components/AddressForm/index.ts — now fails lint
    export * from './AddressFields';
    // ^ 1:1  error  Do not use export all (`export * from ...`)         no-barrel-files/no-barrel-files
    export { default } from './AddressFields';
    // ^ 2:1  error  Do not re-export imported variable (`./AddressFields`)  no-barrel-files/no-barrel-files

    Consumers should import from the source file directly instead:

    import AddressFields, { type AddressFieldsClassNames } from './AddressFields';

Screenshots (if applicable)
Symlinked and tested on the Takeflight project
image

Other solutions considered (if any)

Notes to PR author

⚠️ Please make sure the changes adhere to the guidelines mentioned in our contribution guide.

Notes to reviewers

ℹ️ When you've finished leaving feedback, please add a final comment to the PR tagging the author, letting them know that you have finished leaving feedback

@brettcutt-aligent brettcutt-aligent marked this pull request as ready for review May 22, 2026 01:36
@brettcutt-aligent brettcutt-aligent requested review from a team as code owners May 22, 2026 01:36
The repo's prettier.config.js is a deliberate two-line passthrough that
imports prettierConfig from src and re-exports it as default. This is
the recommended consumer pattern documented in the README, not a real
barrel.

Scope the override to prettier.config.js only so the rule still applies
to every other file in this repo's self-lint.
Copy link
Copy Markdown
Contributor

@kai-nguyen-aligent kai-nguyen-aligent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. However, is there any reason not to apply this to the base config also?

@brettcutt-aligent
Copy link
Copy Markdown
Contributor Author

LGTM. However, is there any reason not to apply this to the base config also?

@nettree the scope of the task is to apply the rule to react, but should we instead apply it to the base?

@nettree
Copy link
Copy Markdown
Contributor

nettree commented May 25, 2026

LGTM. However, is there any reason not to apply this to the base config also?

@nettree the scope of the task is to apply the rule to react, but should we instead apply it to the base?

Sure @brettcutt-aligent

If @kai-nguyen-aligent and @aligent-lturner agree with this rule to be applied to all our TS projects then I'm happy with it

@nettree nettree requested a review from aligent-lturner May 25, 2026 02:00
@aligent-lturner
Copy link
Copy Markdown

LGTM. However, is there any reason not to apply this to the base config also?

@nettree the scope of the task is to apply the rule to react, but should we instead apply it to the base?

Sure @brettcutt-aligent

If @kai-nguyen-aligent and @aligent-lturner agree with this rule to be applied to all our TS projects then I'm happy with it

Fine with me

@nettree
Copy link
Copy Markdown
Contributor

nettree commented May 25, 2026

@brettcutt-aligent let's move this to base :)

Copy link
Copy Markdown
Contributor

@kai-nguyen-aligent kai-nguyen-aligent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nettree
Copy link
Copy Markdown
Contributor

nettree commented May 25, 2026

Awesome, let's go :)

@brettcutt-aligent brettcutt-aligent merged commit 1df309b into main May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants