You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable TypeScript linting and fix config type safety (#790) (#796)
## Summary
This PR addresses #790 by enabling TypeScript linting for all package
files and fixing the primary type safety issues related to config
objects. This is **Phase 2b** of the TypeScript ESLint technical debt
resolution.
## Key Changes
### 1. Enabled TypeScript Linting
- Removed `package/**/*.ts` from ESLint ignore patterns
- All TypeScript files in `package/` are now linted (except as
specifically overridden)
### 2. Deferred CommonJS Migration to Phase 3
- Added global suppression for `@typescript-eslint/no-require-imports`
- This allows us to fix type safety issues while deferring the
CommonJS-to-ESM migration to a future breaking change release
### 3. Fixed Config Type Safety (Primary Goal)
Added proper `Config` type assertions in 11 files that
`require("../config")`:
- `package/environments/base.ts`
- `package/environments/development.ts`
- `package/environments/production.ts`
- `package/environments/test.ts`
- `package/plugins/webpack.ts`
- `package/plugins/rspack.ts`
- `package/dev_server.ts`
- `package/rspack/index.ts`
- `package/rules/raw.ts`
- `package/utils/getStyleRule.ts`
- `package/utils/requireOrError.ts`
### 4. Cleanup
- Removed unused `eslint-disable` directives for `global-require`
- Removed unused type definitions (`ServerType`, `WebSocketType`)
### 5. Updated ESLint Config Overrides
Updated override blocks to suppress remaining type safety errors in:
- Utility files that use dynamic requires
- Plugin/optimization files that access webpack/rspack modules
dynamically
- Files that will require more extensive refactoring
## Impact
### Errors Fixed
- **Before**: 112 ESLint errors when TypeScript files were linted
- **After**: 0 ESLint errors ✅
- **Fixed**: 65+ type safety errors related to config object access
### Type Safety Improvements
- Config objects now have proper typing throughout the codebase
- TypeScript can now catch config-related type errors at compile time
- Improved IDE autocomplete and documentation for config properties
### Remaining Work
The remaining ~47 type safety errors in utility files, plugin loaders,
and dynamic module requires are now properly documented in
`eslint.config.js` with override blocks. These will be addressed in
future PRs as they require:
- Proper typing for dynamic webpack/rspack plugin requires
- Refactoring of utility functions to use proper types instead of `any`
- Potentially creating type definitions for third-party modules
## Testing
- ✅ `yarn lint` passes
- ✅ `bundle exec rubocop` passes
- ✅ Type checking passes
- ✅ Pre-commit hooks pass
- ⚠️ Test suite has same pass/fail rate as main (11 failing suites are
pre-existing)
## Related Issues
- Fixes#790 - TypeScript ESLint Phase 2b: Type Safety Improvements
- Follows #789 (PR #793) - Phase 2a simple fixes
- Part of #783 - TypeScript ESLint Technical Debt resolution
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <[email protected]>
0 commit comments