fix(linting): single-export-per-file false positives on @fusionElement pattern - #5187
Merged
Conversation
…pattern Fixes #5185 - Barrel exemption (index.ts/.tsx/.mts/.cts) now always applies, even when options.match overrides the matcher. - A companion const/let (e.g. a tag string) that only parameterizes an export default class no longer counts as a competing export.
🦋 Changeset detectedLatest commit: 62f8cec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fixes #5185.
The
single-export-per-filerule flagged the standard@fusionElementcustom-element registration pattern:with
'_' is the 2nd export in this file, even though the file conceptually only exports one thing (thetagconst purely parameterizes the default class). Verified identically across ~30 packages infusion-web-components.Also, the
index.tsbarrel exemption only applied whenoptions.matchwas left unconfigured — any repo (likefusion-web-components) supplying its ownmatch/ignorePatternsconfig lost that exemption and got flagged on every barrel file.What
packages/linting/rules/src/single-export-per-file/index.ts:index.ts,index.tsx,index.mts,index.cts) are now always exempt, ANDed with anyoptions.matchoverride rather than being replaced by it.competingExports(): when a file has anexport default class ... {}, companion top-levelconst/letexports are dropped from the competing-exports count before the one-symbol check runs.export class Foo {}+export default Foo;(re-export, not a genuine 2nd export) continues to report 0 violations, and that a genuinely competing export alongside the pattern still gets flagged.Validation
npx vitest run packages/linting/rules/src/__tests__/single-export-per-file.test.ts— 19/19 passing.pnpm exec biome lint+pnpm exec fusion-lint linton both changed files — clean.patchfor@equinor/fusion-framework-lint-rules).