Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ts): ban cjs exports in ts file #167

Merged
merged 1 commit into from May 19, 2023
Merged

Conversation

zanminkian
Copy link
Contributor

@zanminkian zanminkian commented Apr 10, 2023

Description

Ban cjs exports in ts file.

if (true)
  module.exports = {}

module.exports = {}

if (true)
  exports.a = 1

exports.a = 1

function f() {
  exports.a = 1
}

const a = {
  exports: {
    tmp: 'hi',
  },
}

a.exports.tmp = 'hello'

export = 'abc'

export default 'hello'

export const tmp = 'world'

Copy this content to test.

Linked Issues

Additional context

@zanminkian zanminkian force-pushed the zmj-exports branch 4 times, most recently from 6e141ea to b5b8caa Compare April 10, 2023 17:43
@zanminkian
Copy link
Contributor Author

It's ready to be reviewed.

@antfu
Copy link
Owner

antfu commented Apr 11, 2023

I am not sure if I'd like to take that complicity. Ideally, I would prefer to have it defined in a plugin and enable as a rule.

@zanminkian
Copy link
Contributor Author

I would prefer to have it defined in a plugin and enable as a rule

It's better.

I don't have to much experience on eslint plugin. I will look into it on weekends.

@zanminkian zanminkian force-pushed the zmj-exports branch 3 times, most recently from ae79900 to 614534d Compare April 16, 2023 11:52
@zanminkian
Copy link
Contributor Author

Hi @antfu. Refactored to plugin rules. Please take a review.

@zanminkian zanminkian force-pushed the zmj-exports branch 4 times, most recently from 7b5befa to a7a2e85 Compare April 26, 2023 07:31
@zanminkian
Copy link
Contributor Author

It's ready.

@zanminkian zanminkian requested a review from antfu April 26, 2023 07:46
@zanminkian
Copy link
Contributor Author

Hi @antfu , can you review this PR? After merging this PR, this eslint-config preset will force user to use ESM in ts file. This is the last step, because require statement has already been blocked in ts file.

Let's make ESM greater.

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.

None yet

2 participants