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

Rule that validates exports field #289

Open
mightyiam opened this issue Jun 14, 2020 · 3 comments
Open

Rule that validates exports field #289

mightyiam opened this issue Jun 14, 2020 · 3 comments
Labels
enhancement 👑 New feature or request

Comments

@mightyiam
Copy link

I have made a mistake specifying values of the exports field. I have used absolute paths. That doesn't seem to be valid. Would a rule regarding validity of the exports field be welcome?

@tclindner
Copy link
Owner

tclindner commented Jun 14, 2020

Most certainly! Are you interested in opening a PR?

@tclindner tclindner added the enhancement 👑 New feature or request label Jun 14, 2020
@mightyiam
Copy link
Author

Yes, please. Any special advice for this rule?

@dzearing
Copy link

dzearing commented Jan 26, 2022

I have some advice on things to validate for this rule:

  • For each file path, validate the file exists
  • For each path that has an "import" conditional, validate the source is ESM and not commonjs.
  • For each path that has a "require" conditional, validate the source is commonjs and not esm.
  • Validate invalid conditional situations (import and require are mutually exclusive, same with development vs production)
  • For each path that has neither import or require conditions, validate that .js files match the module type specified in type, or if it is missing or not set to type="module", validate .js files are commonjs. (I think)
  • If "types" are present in a dictionary, validate they are the first key (I read about this here; https://nodejs.org/api/packages.html#community-conditions-definitions)

I recognize this issue is pretty old but @mightyiam if you still have plans to implement this, hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 👑 New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants