Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 837 Bytes

README.md

File metadata and controls

43 lines (29 loc) · 837 Bytes

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.