Skip to content

feat(textlint)!: convert textlint-rule-preset-alma to esm - #263

Merged
literat merged 2 commits into
mainfrom
feat/textlint-preset-alma-esm
Sep 11, 2026
Merged

literat merged 2 commits into
mainfrom
feat/textlint-preset-alma-esm

Conversation

@literat

@literat literat commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Description

textlint v15 loads rules, filters, and presets through dynamic import() (see @textlint/config-loader / @textlint/resolver), so a preset package no longer has to be CommonJS. This converts @alma-oss/textlint-rule-preset-alma to native ESM ("type": "module") to match, rather than carrying require()/module.exports for no reason now that the runtime supports better.

Two of the preset's rule dependencies (textlint-rule-common-misspellings, textlint-rule-write-good) ship a TS-compiled CJS module with a double exports.default wrapper; the ESM import unwraps that the same way the old require(...).default did, so rule behavior is unchanged. Verified with the package's own test suite (node --test, 8/8 passing) and a real textlint --preset @alma-oss/textlint-rule-preset-alma run against a sample file.

Additional context

This is a breaking change: the package is now ESM-only and can no longer be require()'d directly from a CommonJS script. Consumption via textlint's own preset resolution (--preset flag or the rules key in .textlintrc.js) is unaffected, and no other file in this repo requires the package directly.

Follow-up (out of scope here): the preset's own rule dependencies are still CommonJS upstream — converting those to ESM would be a separate change in each of their own repos.

Related issues

None.

Copilot AI lite review requested due to automatic review settings September 11, 2026 09:23
@github-actions github-actions Bot added the feature New feature or request label Sep 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Update the peer dependency range for the supported textlint v15 runtime or provide a CommonJS entry point.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Converts the Alma textlint preset from CommonJS to native ESM for textlint v15.

Changes:

  • Enables ESM packaging and exports.
  • Updates rule and test imports.
  • Preserves CommonJS dependency interoperability.
File summaries
File Summary
packages/textlint-rule-preset-alma/rules/terminology.js Converts terminology rule imports and exports to ESM.
packages/textlint-rule-preset-alma/package.json Enables ESM; Critical: the textlint: ^12.2.2 peer range is incompatible with the v15 runtime.
packages/textlint-rule-preset-alma/index.js Converts the preset entrypoint to ESM.
packages/textlint-rule-preset-alma/__tests__/terminology.test.js Updates terminology tests for ESM.
packages/textlint-rule-preset-alma/__tests__/comment-filtering.test.js Updates filtering tests for ESM.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/textlint-rule-preset-alma/package.json
Copilot AI review requested due to automatic review settings September 11, 2026 09:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The ESM-only package is incompatible with its declared textlint ^12.2.2 peer range; update the metadata or provide a compatible entry point.

Review details

Suppressed comments (1)

packages/textlint-rule-preset-alma/package.json:14

  • Adding "type": "module" makes the package incompatible with its declared textlint peer range: ^12.2.2 excludes the v15 runtime this PR targets, and the v12 CommonJS loading path cannot consume this new ESM-only entry point. Update the peer range to the supported v15 version (and the workspace metadata) or provide a v12-compatible entry point.
  "type": "module",
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 09:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The textlint peer dependency range remains at ^12.2.2 and should be updated for the ESM/textlint v15 requirement.

Review details

Suppressed comments (1)

packages/textlint-rule-preset-alma/package.json:14

  • This makes the published package ESM-only, but peerDependencies.textlint still advertises ^12.2.2 (package.json:48-50). That range is inconsistent with the v15 dynamic-import resolver required to load this entry point: npm consumers using textlint 15 can receive an unsatisfied-peer error, while consumers on textlint 12 are still advertised as supported even though they cannot load the ESM package. Update the peer range (for example, to ^15.0.0) as part of this breaking change.
  "type": "module",
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Update the textlint peer dependency to accurately encode supported compatibility.

Review details

Suppressed comments (1)

packages/textlint-rule-preset-alma/package.json:14

  • Making the package ESM-only means the textlint 12 CommonJS loading path advertised by peerDependencies.textlint: ^12.2.2 is no longer supported, while the v15 runtime used by this change is outside that range. Please update the peer dependency to the supported textlint v15 range (or otherwise encode the actual compatibility boundary) in the same breaking change.
  "type": "module",
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 10:15
  * textlint v15 loads rules, filters, and presets via dynamic import(),
    so the preset can now be authored as native esm instead of commonjs
  * unwraps the two rule dependencies that ship a ts-compiled `exports.default`
    wrapper (common-misspellings, write-good) the same way the old require()
    calls did, so behavior is unchanged
  * test files converted to esm import syntax to match `"type": "module"`

BREAKING CHANGE: the package is now esm-only (`"type": "module"`). It can no
longer be loaded with `require()` from a commonjs script — only consumption
via textlint's own preset resolution (`--preset` / .textlintrc `rules` key)
is supported, which is unaffected.
  * aligns every import in the preset with `import { default as x } from '...'`
    instead of mixing bare default imports with a manual `.default` unwrap
@literat
literat force-pushed the feat/textlint-preset-alma-esm branch from fd55470 to a74af96 Compare September 11, 2026 10:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 10:19
@literat
literat marked this pull request as ready for review September 11, 2026 10:20
@literat
literat requested a review from a team as a code owner September 11, 2026 10:20
@literat
literat merged commit ec64c5e into main Sep 11, 2026
4 checks passed
@literat
literat deleted the feat/textlint-preset-alma-esm branch September 11, 2026 10:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants