Skip to content

refactor(types): convert source to TypeScript#47

Merged
chenjiahan merged 1 commit into
masterfrom
chenjiahan/refactor-src-typescript
May 13, 2026
Merged

refactor(types): convert source to TypeScript#47
chenjiahan merged 1 commit into
masterfrom
chenjiahan/refactor-src-typescript

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

This PR converts the plugin source from JavaScript with JSDoc types to TypeScript while preserving the existing ESM .js import specifiers for runtime compatibility. It also updates ESLint configuration so the repository can lint TypeScript source and keeps the existing lint, build, and test flow working.

Copilot AI review requested due to automatic review settings May 13, 2026 06:37

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

https://github.com/rstackjs/eslint-rspack-plugin/blob/bb6205a2a788e2a4c63203560f4baa565d26b76d/src/index.js#L1
P1 Badge Update test imports after renaming sources

After this rename, the test suite still imports source modules with .js specifiers (for example test/empty.test.js imports ../src/index.js, and test/utils.test.js imports ../src/utils.js), but those files no longer exist and rstest.config.ts does not configure an extension alias from .js to .ts. In CI or local test runs that resolve these exact specifiers, the suite fails before exercising the plugin; either keep shim .js files or update/configure the test imports to resolve the new TypeScript sources.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 migrates the plugin’s source and internal typings from JavaScript + JSDoc to TypeScript, while keeping ESM .js import specifiers so the emitted runtime output remains compatible. It also updates the repo’s ESLint flat config and dev dependencies to lint TypeScript source.

Changes:

  • Converted src/utils and src/options from .js to .ts and replaced JSDoc typedefs with TypeScript types.
  • Refactored existing .ts sources (index.ts, linter.ts, getESLint.ts, ESLintError.ts) to use TypeScript-native type imports/aliases instead of JSDoc casts/ts-ignores.
  • Updated ESLint flat config and dev dependencies to parse/lint *.ts files via @typescript-eslint.

Reviewed changes

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

Show a summary per file
File Description
src/utils.ts New TypeScript implementation of utility helpers (arrify + path/glob parsing).
src/utils.js Removed legacy JS/JSDoc version of utilities.
src/options.ts New TypeScript source of option types + option normalization/filtering logic.
src/options.js Removed legacy JS/JSDoc version of options.
src/linter.ts Replaced JSDoc typedefs and @ts-ignore usage with concrete TS types and type guards.
src/index.ts Added TS types for plugin internals and tightened a few hook-related typings.
src/getESLint.ts Converted module-loading helpers and ESLint wiring to TS types.
src/ESLintError.ts Converted constructor typing to TS.
eslint.config.js Added @typescript-eslint parser/plugin config for *.ts files.
package.json Added @typescript-eslint/eslint-plugin and @typescript-eslint/parser dev deps.
pnpm-lock.yaml Lockfile updates for newly added TypeScript ESLint deps.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

src/options.ts:40

  • configType is currently typed as string, but the code only supports specific modes (and the README documents flat | eslintrc). Narrowing this to a string union (e.g., 'flat' | 'eslintrc') will prevent invalid values from compiling and avoid ambiguous runtime behavior (like incorrectly keeping/removing extensions).
  configType?: string;
};

src/linter.ts:47

  • In both the setup catch and the lintFiles(...).catch(...) path, the code assumes the caught value has a .message property. If a non-Error is thrown/rejected (string, object, etc.), this becomes undefined and produces unhelpful [eslint] undefined messages. Consider normalizing with e instanceof Error ? e.message : String(e) (or similar) before constructing ESLintError.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/options.ts
@chenjiahan chenjiahan merged commit 750eaf7 into master May 13, 2026
10 checks passed
@chenjiahan chenjiahan deleted the chenjiahan/refactor-src-typescript branch May 13, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants