Skip to content

Conversation

lumirlumir
Copy link
Owner

@lumirlumir lumirlumir commented Jul 26, 2025

This pull request refactors the textlint-rule-allowed-uris module to simplify its structure, improve maintainability, and transition type definitions from JavaScript to TypeScript. The changes include consolidating imports, removing redundant code, and updating the implementation to use simpler data structures.

Refactoring and Simplification:

  • src/textlint-rule-allowed-uris.js: Consolidated imports and replaced the use of getUriTypesLink and getUriTypesImage with inline objects for Link and Image nodes, simplifying the logic. Adjusted Definition and Html node handling to directly use arrays instead of UriTypes class. [1] [2]

  • src/utils/get-uri-types/get-uri-types.js: Removed the UriTypes class and replaced it with plain arrays for URI type handling. Simplified getUriTypesDefinition and getUriTypesHtml functions to directly return arrays.

  • src/utils/get-uri-types/get-uri-types.test.js: Updated tests to reflect the removal of the UriTypes class, ensuring direct comparison with arrays. Removed tests for getUriTypesLink and getUriTypesImage as they are no longer used. [1] [2] [3]

Transition to TypeScript:

  • src/types/index.js: Removed JavaScript type definitions.

  • src/utils/types.ts: Introduced TypeScript interfaces (UriType and Options) to define common types for the module, improving type safety and clarity.

File Structure Updates:

@github-actions github-actions bot added 🏷️ scope: * Auto-generated label based on Conventional Commits specification for GitHub release notes 🏷️ type: refactor Auto-generated label based on Conventional Commits specification for GitHub release notes labels Jul 26, 2025
Copy link

Labels have been automatically applied based on the Conventional Commits specification.🏷️

Copy link

codecov bot commented Jul 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.34%. Comparing base (f36fbeb) to head (bf5ab98).
⚠️ Report is 1 commits behind head on main.

@@            Coverage Diff             @@
##             main     #303      +/-   ##
==========================================
- Coverage   98.90%   98.34%   -0.56%     
==========================================
  Files          10        7       -3     
  Lines         365      242     -123     
  Branches        1        1              
==========================================
- Hits          361      238     -123     
  Misses          4        4              
Files with missing lines Coverage Δ
src/textlint-rule-allowed-uris.js 100.00% <100.00%> (ø)
...tion-node-uri-type/get-definition-node-uri-type.js 92.72% <100.00%> (ø)
src/utils/get-uri-types/get-uri-types.js 100.00% <100.00%> (ø)
src/utils/theme.js 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f36fbeb...bf5ab98. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lumirlumir lumirlumir marked this pull request as ready for review July 26, 2025 06:38
@Copilot Copilot AI review requested due to automatic review settings July 26, 2025 06:38
Copy link
Contributor

@Copilot Copilot AI left a 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 PR refactors the textlint-rule-allowed-uris module to simplify its architecture by removing the UriTypes class and transitioning from JavaScript type definitions to TypeScript interfaces. The changes aim to improve maintainability and reduce complexity while preserving the same functionality.

Key changes include:

  • Removal of the UriTypes class wrapper in favor of plain arrays
  • Consolidation of utility functions and elimination of redundant exports
  • Migration from JSDoc typedefs to TypeScript interfaces for better type safety

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/uri-types/uri-types.js Removed the UriTypes class entirely
src/utils/uri-types/uri-types.test.js Removed all tests for the deleted UriTypes class
src/utils/uri-types/index.js Removed export of deleted UriTypes class
src/utils/types.ts Added TypeScript interfaces to replace JSDoc type definitions
src/utils/theme.js Moved from nested directory and added whitespace formatting
src/utils/get-uri-types/get-uri-types.js Simplified functions to return arrays instead of UriTypes instances
src/utils/get-uri-types/get-uri-types.test.js Updated tests to work with arrays instead of UriTypes objects
src/textlint-rule-allowed-uris.js Updated to use inline objects and direct array returns

@lumirlumir lumirlumir merged commit 007cc94 into main Jul 26, 2025
10 checks passed
@lumirlumir lumirlumir deleted the refactor-simplify-logics branch July 26, 2025 06:43
lumirlumir added a commit that referenced this pull request Jul 27, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ scope: * Auto-generated label based on Conventional Commits specification for GitHub release notes 🏷️ type: refactor Auto-generated label based on Conventional Commits specification for GitHub release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant