refactor(types): convert source to TypeScript#47
Conversation
There was a problem hiding this comment.
💡 Codex Review
https://github.com/rstackjs/eslint-rspack-plugin/blob/bb6205a2a788e2a4c63203560f4baa565d26b76d/src/index.js#L1
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".
There was a problem hiding this comment.
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/utilsandsrc/optionsfrom.jsto.tsand replaced JSDoc typedefs with TypeScript types. - Refactored existing
.tssources (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
*.tsfiles 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
configTypeis currently typed asstring, but the code only supports specific modes (and the README documentsflat | 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/removingextensions).
configType?: string;
};
src/linter.ts:47
- In both the setup
catchand thelintFiles(...).catch(...)path, the code assumes the caught value has a.messageproperty. If a non-Erroris thrown/rejected (string, object, etc.), this becomesundefinedand produces unhelpful[eslint] undefinedmessages. Consider normalizing withe instanceof Error ? e.message : String(e)(or similar) before constructingESLintError.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR converts the plugin source from JavaScript with JSDoc types to TypeScript while preserving the existing ESM
.jsimport 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.