Skip to content

feat(eslint): add initial no-default-export-components rule#110266

Merged
JoshuaKGoldberg merged 6 commits intomasterfrom
lint-no-default-export-components
Mar 12, 2026
Merged

feat(eslint): add initial no-default-export-components rule#110266
JoshuaKGoldberg merged 6 commits intomasterfrom
lint-no-default-export-components

Conversation

@JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Mar 9, 2026

Adds a @sentry/no-default-export-components rule that reports on export defaults of things that seem to be React components.

It intentionally ignores any file where:

  • Another module import('...')s the file, which might indicate using a lazy import of a .default
  • Existing named imports exist in the file, which I left out to not deal with naming mismatches/conflicts in fixing

Most of the corresponding fixes were in #110263, which this PR was stacked on. A few more violations were added to master since that PR was generated and are now fixed in this PR. This PR also adds detection for class components and fixes those new violations.

There are still ~1.2k export default \w+s in static/app excluding mocks. Collecting more of them will mean adding in more logic to the fixers / lint rule / prompts, which I'd like to propose as a followup.

Fixes ENG-7006.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 9, 2026
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the default-to-named-exports-most-straightforward-component branch from 1bbce7f to bea68e2 Compare March 9, 2026 22:39
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the lint-no-default-export-components branch from e7233f7 to 3f99e7c Compare March 9, 2026 22:40
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the lint-no-default-export-components branch from 3f99e7c to aeafbfd Compare March 9, 2026 22:45
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the default-to-named-exports-most-straightforward-component branch from bea68e2 to 092f72f Compare March 9, 2026 22:46
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the lint-no-default-export-components branch from aeafbfd to 56c1f7e Compare March 9, 2026 22:47
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the default-to-named-exports-most-straightforward-component branch from 092f72f to 6bd47c6 Compare March 9, 2026 22:48
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the lint-no-default-export-components branch from 56c1f7e to 5548d74 Compare March 9, 2026 22:49
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the default-to-named-exports-most-straightforward-component branch 2 times, most recently from a1cc39e to 60329bc Compare March 10, 2026 11:55
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the lint-no-default-export-components branch from 5548d74 to 7da9723 Compare March 10, 2026 12:52
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 10, 2026
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@linear-code
Copy link

linear-code bot commented Mar 10, 2026

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review March 10, 2026 12:58
@JoshuaKGoldberg JoshuaKGoldberg requested review from a team as code owners March 10, 2026 12:58
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the lint-no-default-export-components branch from e8010be to 33aa9f4 Compare March 11, 2026 20:26
@JoshuaKGoldberg JoshuaKGoldberg removed request for a team March 11, 2026 20:27
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

node.superClass !== null &&
node.superClass.type === AST_NODE_TYPES.Identifier &&
node.superClass.name.includes('Component')
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Class component detection misses MemberExpression superclass patterns

Low Severity

The ClassDeclaration branch only checks node.superClass.type === AST_NODE_TYPES.Identifier, so classes using extends React.Component or extends React.PureComponent (which produce a MemberExpression node, not an Identifier) won't be detected as components. The .name.includes('Component') check also matches non-component classes whose superclass name happens to contain "Component" as a substring, which is overly broad in one direction while missing the MemberExpression pattern entirely.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't do that here, this is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants