-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(*): simplify and cleanup logics #303
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
Labels have been automatically applied based on the Conventional Commits specification.🏷️ |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ 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
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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 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 |
…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 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 ofgetUriTypesLink
andgetUriTypesImage
with inline objects forLink
andImage
nodes, simplifying the logic. AdjustedDefinition
andHtml
node handling to directly use arrays instead ofUriTypes
class. [1] [2]src/utils/get-uri-types/get-uri-types.js
: Removed theUriTypes
class and replaced it with plain arrays for URI type handling. SimplifiedgetUriTypesDefinition
andgetUriTypesHtml
functions to directly return arrays.src/utils/get-uri-types/get-uri-types.test.js
: Updated tests to reflect the removal of theUriTypes
class, ensuring direct comparison with arrays. Removed tests forgetUriTypesLink
andgetUriTypesImage
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
andOptions
) to define common types for the module, improving type safety and clarity.File Structure Updates:
src/utils/theme.js
: Moved and renamed fromsrc/utils/theme/theme.js
, simplifying the directory structure. Updated imports accordingly. [1] [2]src/utils/uri-types/index.js
: Removed redundant export for the deletedUriTypes
class.