Skip to content

fix(no-export): check for exports global#1988

Open
G-Rath wants to merge 1 commit into
mainfrom
no-exports-exports
Open

fix(no-export): check for exports global#1988
G-Rath wants to merge 1 commit into
mainfrom
no-exports-exports

Conversation

@G-Rath

@G-Rath G-Rath commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Resolves #1986

Co-authored-by: eryue0220 <eryue0220@gmail.com>
@github-actions

Copy link
Copy Markdown
Fails
🚫

node failed.

Log

Details
Error:  TypeError: ts.transpileModule is not a function
    at typescriptify (/usr/src/danger/dist/runner/runners/utils/transpiler.js:160:21)
    at /usr/src/danger/dist/runner/runners/utils/transpiler.js:235:44
    at /usr/src/danger/dist/runner/runners/inline.js:154:53
    at step (/usr/src/danger/dist/runner/runners/inline.js:56:23)
    at Object.next (/usr/src/danger/dist/runner/runners/inline.js:37:53)
    at /usr/src/danger/dist/runner/runners/inline.js:31:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/src/danger/dist/runner/runners/inline.js:27:12)
    at runDangerfileEnvironment (/usr/src/danger/dist/runner/runners/inline.js:123:132)
    at /usr/src/danger/dist/platforms/GitHub.js:181:38
danger-results://tmp/danger-results-01b60a03.json

Generated by 🚫 dangerJS against 9035975

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 exports identifier (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 thread src/rules/no-export.ts
Comment on lines 53 to +57
if (object.type === AST_NODE_TYPES.MemberExpression) {
({ object, property } = object);
}

if (object.type !== AST_NODE_TYPES.Identifier) {
Comment thread src/rules/no-export.ts
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))
) {
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.

2 participants