feat(eslint-plugin): implement no-typeof-runtype rule#104
Merged
M-jerez merged 7 commits intomion-run-typesfrom Aug 26, 2025
Merged
feat(eslint-plugin): implement no-typeof-runtype rule#104M-jerez merged 7 commits intomion-run-typesfrom
M-jerez merged 7 commits intomion-run-typesfrom
Conversation
- Add ESLint rule to detect runType<typeof ...>() usage - Rule works with both @mionkit/run-types imports and relative imports - Comprehensive test suite with 13 test cases - Successfully detects 3 violations in literal.spec.ts as expected - Provides clear error message suggesting explicit type definitions
- Change build output from .dist to build directory (following mion-aot-template pattern)
- Update package.json to use proper ESLint plugin naming (eslint-plugin-mionkit)
- Add proper CommonJS and ESM exports for plugin compatibility
- Include compiled build artifacts in repository for ESLint consumption
- Create proper entry points at build/cjs/index.js and build/esm/index.js
- Successfully tested with ESLint CLI - detects 3 violations in literal.spec.ts
- All 13 unit tests still passing
The plugin is now fully functional and can be used by ESLint:
- Install locally: npm install ./packages/eslint-plugin
- Use in .eslintrc.js: plugins: ['mionkit'], rules: {'mionkit/no-typeof-runtype': 'error'}
- Add USAGE.md with installation and configuration instructions - Include examples of correct and incorrect usage - Show expected ESLint output format
✅ **Plugin Naming & Structure** - Restore proper @mionkit/eslint-plugin naming for scoped package - Update ESLint config to use correct rule name: @mionkit/no-typeof-runtype - Plugin now properly groups rules and ready for additional rules ✅ **Build Optimization** - Remove source maps and type declarations from build output - Cleaner build artifacts (only JS files needed for ESLint) - Standalone tsconfig.build.json to avoid composite project conflicts - Faster build process without unnecessary files ✅ **Integration** - Plugin already available in root devDependencies - ESLint configuration updated in .eslintrc.js - No manual installation needed when cloning repository ✅ **Verification** - All 13 tests passing ✅ - ESLint CLI working correctly ✅ - Detects 3 violations in literal.spec.ts ✅ - Updated documentation with correct usage examples **Usage:**
✅ **Recommended Configuration**
- Add configs.recommended to plugin exports
- Includes all mionkit ESLint rules with sensible defaults
- Simplifies setup for consumers
✅ **Updated Root ESLint Config**
- Use plugin:@mionkit/eslint-plugin/recommended in extends array
- Remove manual rule configuration from rules section
- Cleaner, more maintainable configuration
✅ **Usage Examples**
**Recommended (Easy):**
extends: ['plugin:@mionkit/eslint-plugin/recommended']
**Manual (Advanced):**
plugins: ['@mionkit/eslint-plugin']
rules: { '@mionkit/no-typeof-runtype': 'error' }
✅ **Verification**
- Recommended config working correctly ✅
- All 13 tests passing ✅
- ESLint detecting 3 violations in literal.spec.ts ✅
- Updated documentation with both approaches ✅
This makes the plugin much easier to adopt - consumers can just extend the recommended config instead of manually configuring each rule.
- Change @mionkit/eslint-plugin from version ^0.7.2 to file:./packages/eslint-plugin - Ensures ESLint loads the local development version instead of npm registry - Creates symlink in node_modules/@mionkit/eslint-plugin -> ../../packages/eslint-plugin - Should resolve plugin loading issues and make development more reliable This ensures that: 1. ESLint always uses the latest local changes 2. No need to publish plugin to test changes 3. Better development experience for contributors
…o include other functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the initial functionality for the ESLint plugin package with a
no-typeof-runtyperule that detects whenrunType<typeof ...>()is used and reports an ESLint error.Background
The run-types package has special functions that extract metadata from types at compile-time. The main function is
runTypefrom the '@mionkit/run-types' package. This is a generic function that returns metadata for a type, but it only works with explicitly defined types and most of the time does not infer types correctly whentypeofis used.Changes
✅ ESLint Rule Implementation
no-typeof-runtypedetectsrunType<typeof ...>()usagerunTypefrom@mionkit/run-typespackage (not other functions with same name)@mionkit/run-types) and relative imports (../../lib/runType)✅ Comprehensive Testing
✅ Build Configuration
lib/directory structure✅ Validation
packages/run-types/src/runType/atomic/literal.spec.ts:const rtReg = runType<typeof reg>();const rtReg2 = runType<typeof reg2>();const rtSym = runType<typeof sym>();Example
❌ Before (problematic):
✅ After (correct):
Testing
Next Steps
This PR provides the foundation for the ESLint plugin. Future enhancements could include:
Pull Request opened by Augment Code with guidance from the PR author