-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(*)!: migrate to ESM #301
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #301 +/- ##
==========================================
- Coverage 98.94% 98.90% -0.05%
==========================================
Files 10 10
Lines 379 365 -14
Branches 1 1
==========================================
- Hits 375 361 -14
Misses 4 4
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
63aa17e
to
5e052db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request migrates the entire codebase from CommonJS to ES Modules (ESM), modernizing the module system to align with current JavaScript standards and improve compatibility with modern tooling.
Key changes include:
- Adding
"type": "module"
to package.json to specify ES Modules environment - Converting all
require()
statements toimport
andmodule.exports
toexport
/export default
- Adding explicit
.js
file extensions to all import paths as required by ESM - Using
createRequire
andimport.meta
for compatibility with Node.js built-ins in test files
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
package.json | Added "type": "module" to enable ES Modules |
src/textlint-rule-allowed-uris.js | Main rule file converted to ESM with updated imports and default export |
src/types/index.js | Updated to use default export instead of module.exports |
src/utils/*/index.js | Index files converted to use ES Module re-exports |
src/utils/*/*.js | Utility files migrated to ESM syntax with explicit .js extensions |
tests/*.test.js | Test files updated to use ESM imports and Node.js compatibility helpers |
…github.com/lumirlumir/textlint-rule-allowed-urls into refactor-migrate-to-ultrahtml-from-cheerio
Labels have been automatically applied based on the Conventional Commits specification.🏷️ |
…or`) (#308) ## Release Information: `v2.0.0` New release of `lumirlumir/npm-textlint-rule-allowed-uris` has arrived! :tada: This PR bumps the package versions from `v1.1.1` to `v2.0.0` (`major`). See [Actions](https://github.com/lumirlumir/npm-textlint-rule-allowed-uris/actions/runs/16551356197) for more details. | Info | Value | | ----------- | -------------------------- | | Repository | `lumirlumir/npm-textlint-rule-allowed-uris` | | SEMVER | `major` | | Pre ID | `canary` | | Short SHA | 90ae620 | | Old Version | `v1.1.1` | | New Version | `v2.0.0` | <!-- Release notes generated using configuration in .github/release.yml at main --> ## What's Changed ### 💥 BREAKING CHANGES * refactor(*)!: migrate to ESM by @lumirlumir in #301 * feat(*)!: drop async logic and add `checkUnusedDefinitions` option by @lumirlumir in #305 ### ✨ Features * feat(*): support `textlint` v15 by @lumirlumir in #306 ### 🐛 Bug Fixes * fix(*): incorrect error location and refactor by @lumirlumir in #304 ### 🧰 Chores * chore(sync-server): update `dependabot.yml` by @lumirlumir in #280 * chore(*): move `FUNDING.yml` to `.github` repository by @lumirlumir in #290 ### 📝 Documentation * docs(*): remove `PULL_REQUEST_TEMPLATE.md` in favor of centralized template by @lumirlumir in #293 * docs(*): update `README.md` by @lumirlumir in #307 ### ♻️ Code Refactoring * refactor(*): migrate type declarations to use `@import` syntax by @lumirlumir in #276 * refactor(*): improve structure and clarity of URI type retrieval functions by @lumirlumir in #296 * refactor(*): simplify and cleanup logics by @lumirlumir in #303 ### ⬆️ Dependency Updates * chore(deps): bump cheerio from 1.0.0 to 1.1.0 by @dependabot[bot] in #266 * chore(deps-dev): bump the bananass group across 1 directory with 2 updates by @dependabot[bot] in #265 * chore(deps-dev): bump @types/node from 22.15.29 to 24.0.0 by @dependabot[bot] in #269 * chore(deps-dev): bump @types/node from 24.0.0 to 24.0.1 by @dependabot[bot] in #270 * chore(deps-dev): bump lint-staged from 16.1.0 to 16.1.2 by @dependabot[bot] in #271 * chore(deps-dev): bump eslint from 9.28.0 to 9.29.0 by @dependabot[bot] in #272 * chore(deps-dev): bump concurrently from 9.1.2 to 9.2.0 by @dependabot[bot] in #274 * chore(deps-dev): bump prettier from 3.5.3 to 3.6.0 by @dependabot[bot] in #275 * chore(deps-dev): bump @types/node from 24.0.1 to 24.0.4 by @dependabot[bot] in #277 * chore(deps-dev): bump prettier from 3.6.0 to 3.6.1 by @dependabot[bot] in #278 * chore(deps-dev): bump @babel/core from 7.27.4 to 7.27.7 in the babel group across 1 directory by @dependabot[bot] in #279 * chore(deps-dev): bump eslint from 9.29.0 to 9.30.0 by @dependabot[bot] in #282 * chore(deps-dev): bump @types/node from 24.0.4 to 24.0.7 by @dependabot[bot] in #281 * chore(deps-dev): bump prettier from 3.6.1 to 3.6.2 by @dependabot[bot] in #283 * chore(deps-dev): bump eslint from 9.30.0 to 9.30.1 by @dependabot[bot] in #286 * chore(deps-dev): bump @types/node from 24.0.7 to 24.0.10 by @dependabot[bot] in #285 * chore(deps-dev): bump the babel group across 1 directory with 3 updates by @dependabot[bot] in #287 * chore(deps-dev): bump the bananass group across 1 directory with 2 updates by @dependabot[bot] in #289 * chore(deps-dev): bump @types/node from 24.0.10 to 24.0.12 by @dependabot[bot] in #288 * chore(deps-dev): bump eslint from 9.30.1 to 9.31.0 by @dependabot[bot] in #292 * chore(deps-dev): bump editorconfig-checker from 6.0.1 to 6.1.0 by @dependabot[bot] in #295 * chore(deps): bump cheerio from 1.1.0 to 1.1.2 by @dependabot[bot] in #299 * chore(deps-dev): bump the bananass group across 1 directory with 2 updates by @dependabot[bot] in #302 **Full Changelog**: v1.1.1...v2.0.0
This pull request migrates the codebase from CommonJS to ES Modules, modernizing the module system and improving compatibility with current JavaScript standards. The changes include updating import/export syntax, refactoring test files, and ensuring all module references use the
.js
extension explicitly.Migration to ES Modules:
package.json
: Added"type": "module"
to specify the project as an ES Modules environment.require
statements toimport
and replacedmodule.exports
withexport
orexport default
across multiple files:src/textlint-rule-allowed-uris.js
: Updated imports and changed the export of the main function toexport default
. [1] [2] [3]src/types/index.js
: Changedmodule.exports
toexport default
.src/utils/*
): Updated imports and exports inget-definition-node-uri-type
,get-uri-types
,theme
, anduri-types
. [1] [2] [3] [4] [5] [6] [7]Test File Updates:
import
statements and updated module references:src/utils/get-definition-node-uri-type/get-definition-node-uri-type.test.js
: Replacedrequire
withimport
.src/utils/get-uri-types/get-uri-types.test.js
: Updated imports for utility functions.src/utils/uri-types/uri-types.test.js
: Migrated to ES Modules syntax.tests/textlint-rule-allowed-uris.test.js
: Refactored to useimport
andcreateRequire
for compatibility with ES Modules.Explicit
.js
Extensions:.js
extension to comply with ES Modules requirements:src/textlint-rule-allowed-uris.js
,src/utils/get-uri-types/get-uri-types.js
,src/utils/theme/theme.js
, and other files. [1] [2] [3] [4]These changes collectively modernize the codebase, aligning it with current JavaScript standards and improving maintainability.