In D6692, I updated all imports to include `.js` extensions to satisfy Webpack 5 and Node.js 19. To make sure we don't regress on this, in this diff I introduce an ESLint rule for enforcing extensions for all imports.
Most of the changes in this diff are the result of ordering changes after adding the new ESLint rule. These ordering changes occurred whether I put the new `import/extensions` rule before or after the `import/order` rule. Unfortunately, this will pollute Git history, but I don't think it's a big enough deal to merit further investigation.
Unfortunately, I had to keep the import order changes in the same diff as the more meaningful changes... whichever way I split it, the CI would fail on the intermediate diff. To make this diff easier to review, I'll highlight the relevant changes with inline comments.
As part of this, the ESLint rule identified some places that the codemod script in D6692 didn't catch. They include:
1. Places where we use CommonJS `require` instead of `import`
2. Imports from within packages. In D6692, I updated places that just needed a `.js` extension (eg. `lodash/fp/merge.js`). But in some cases it was more complicated... I either couldn't find a file at all (eg. `electron/main`), or found that there was a `package.json` inside the directory instead of an `index.js`. I ended up adding `eslint-disable` macros to hide the cases that were hard to update, or following the `package.json` indirection to find the real file in the easier cases
- Note that I could've configured the ESLint rule with `ignorePackages` instead of `always`, but I opted not to do this after testing it against my Webpack 5 branch and finding that Webpack wanted imports from within packages to be fully qualifed
Depends on D6693