1.1.1 • Published 5 months ago
eslint-plugin-ai-imports v1.1.1
eslint-plugin-ai-imports
An ESLint plugin that enforces using jest.mocked()
instead of type casting with jest.Mock
.
Installation
npm install eslint-plugin-ai-imports --save-dev
Usage
Add the plugin to your ESLint configuration:
// .eslintrc.js
module.exports = {
plugins: ['ai-imports'],
rules: {
'ai-imports/jest-mocked': 'error'
}
};
Rule Details
This rule aims to enforce using jest.mocked()
instead of type casting with jest.Mock
.
❌ Incorrect
(myMock as jest.Mock).mockImplementation(() => {});
✅ Correct
jest.mocked(myMock).mockImplementation(() => {});
Why?
Using jest.mocked()
is the recommended approach in Jest for TypeScript projects. It provides proper type inference and is more readable than type casting.