Repository navigation
chore(eslint.config): add scoped ESLint blocks to detect CommonJS and ESM mistakes - #6980
ravitejapioneerblaze-code wants to merge 1 commit into
Conversation
|
✅ All commits on this PR have a verified signature. Thanks! |
|
No actionable comments were generated in the recent review. ℹ️ Recent review info
📝 Summary
Pre-merge checks:
|
20bdbe3 to
7958a61
Compare
7958a61 to
7364df0
Compare
7364df0 to
2ebdd04
Compare
2ebdd04 to
370c3a1
Compare
|
Hi team, the commit is now verified, and the Snyk step in circle-uswds is failing with an enrichment error (SNYK-CLI-0000) that looks unrelated to this change. Could someone re-run the workflow? |
370c3a1 to
046721e
Compare
Summary
Restructured eslint.config.mjs into scoped blocks so ESLint can
distinguish CommonJS files from ESM files and catch the most common
mistake during the CommonJS-to-ESM migration — named imports from a
module that only has a default export.
Breaking change
This is not a breaking change.
Related issue
Closes #6849
Problem statement
eslint.config.mjs was setting languageOptions.sourceType: "module" for
every file in packages/ while also injecting Node's require/module
globals for the same files. This meant ESLint could not distinguish a
CommonJS file from an ESM file and could not catch the most common
conversion mistake.
Solution
Added two new scoped config blocks:
ESM source block — applies to packages//*.js and packages//*.mjs
(excluding packages/usa-icon/src/usa-icons.config.js which is a
Node-side build config). Adds:
as a migration progress signal (flipped to error in final cleanup USWDS - JS: Migration cleanup -- delete the Storybook CJS-to-ESM transform plugin, tighten lint rules, fix stale docs #6869)
Node-tooling block — applies to gulpfile.js, tasks/**/*.js,
.storybook/main.js, .storybook/test-runner.js, svgo.config.js, webpack.twig.config.js, and
packages/usa-icon/src/usa-icons.config.js. Explicitly sets
sourceType: "commonjs" and disables ESM-only rules for files meant to
stay CommonJS permanently.
Major changes
Testing and review
npm run lint:js passes with only the expected import/extensions warnings
on extensionless relative require() calls in packages/ — no new errors.