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

new rule: no-mismatched-extensions #303

Open
boneskull opened this issue Aug 23, 2023 · 0 comments
Open

new rule: no-mismatched-extensions #303

boneskull opened this issue Aug 23, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed rules related to rules or linting

Comments

@boneskull
Copy link
Owner

boneskull commented Aug 23, 2023

This rule would determine the package type (ESM or CJS) via package.json, then check all the sources within to assert they are using the proper extensions.

e.g:

const isESM = isESMPkg(pkgJson);
let cjsExtensions: Set<string>;
let esmExtensions: Set<string>;
if (isESM) {
  cjsExtensions = new Set(['.cjs'])
  esmExtensions = new Set(['.js', '.mjs'])
} else {
  cjsExtensions = new Set(['.js', '.cjs'])
  esmExtensions = new Set(['.mjs'])
}
@boneskull boneskull added enhancement New feature or request help wanted Extra attention is needed rules related to rules or linting labels Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed rules related to rules or linting
Projects
None yet
Development

No branches or pull requests

1 participant