Repository navigation
fix(no-export): check for exports global - #1988
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the no-export ESLint rule so test files that use CommonJS-style exports are detected more reliably, expanding checks beyond just module.exports usage.
Changes:
- Extend the rule’s MemberExpression handling to recognize the global
exportsidentifier (while still ignoring locally shadowed bindings via scope resolution). - Add tests for
exports.*assignment patterns and expand valid examples to ensure non-exports member chains aren’t flagged.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/rules/no-export.ts |
Expands export detection logic to include global exports and adjusts MemberExpression gating. |
src/rules/__tests__/no-export.test.ts |
Adds coverage for exports.* usage and new valid cases to prevent false positives. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
17
to
21
| 'module.somethingElse = "foo";', | ||
| 'my.exports.myThing = "valid";', | ||
| 'report.myThing = "valid";', | ||
| 'export const myThing = "valid"', | ||
| 'export default function () {}', |
Comment on lines
+104
to
+117
| { | ||
| code: 'exports["invalid"] = function() {}; ; test("a test", () => { expect(1).toBe(1);});', | ||
| errors: [{ endColumn: 19, column: 1, messageId: 'unexpectedExport' }], | ||
| }, | ||
| { | ||
| code: dedent` | ||
| exports.invalid = function () {}; | ||
|
|
||
| describe('a test', () => { | ||
| expect(1).toBe(1); | ||
| }); | ||
| `, | ||
| errors: [{ endColumn: 16, column: 1, messageId: 'unexpectedExport' }], | ||
| }, |
Comment on lines
53
to
+57
| if (object.type === AST_NODE_TYPES.MemberExpression) { | ||
| ({ object, property } = object); | ||
| } | ||
|
|
||
| if (object.type !== AST_NODE_TYPES.Identifier) { |
Comment on lines
72
to
76
| if ( | ||
| property.type === AST_NODE_TYPES.Identifier && | ||
| /^exports?$/u.test(property.name) | ||
| object.name === 'exports' || | ||
| (property.type === AST_NODE_TYPES.Identifier && | ||
| /^exports?$/u.test(property.name)) | ||
| ) { |
G-Rath
force-pushed
the
no-exports-exports
branch
from
July 27, 2026 04:12
9035975 to
272d7f9
Compare
G-Rath
force-pushed
the
no-exports-exports
branch
from
August 27, 2026 19:08
272d7f9 to
ba1e806
Compare
Co-authored-by: eryue0220 <eryue0220@gmail.com>
G-Rath
force-pushed
the
no-exports-exports
branch
from
August 27, 2026 19:24
ba1e806 to
c4cab29
Compare
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 27, 2026
## [29.16.3](v29.16.2...v29.16.3) (2026-08-27) ### Bug Fixes * **no-export:** check for `exports` global ([#1988](#1988)) ([f506cb2](f506cb2))
|
🎉 This PR is included in version 29.16.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Resolves #1986