An ESLint runner for Jest that integrates ESLint into the Jest testing framework for unified code testing and quality checks
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Interactive Jest watch plugin that allows toggling ESLint's --fix option during development without restarting the watch process.
Jest watch plugin class that provides interactive --fix option toggling.
/**
* Jest watch plugin for toggling ESLint --fix option during watch mode
* Requires Jest 23.0.0 or higher
*/
class ESLintWatchFixPlugin {
/**
* Creates new watch plugin instance
* @param options - Plugin initialization options
*/
constructor(options: WatchPluginOptions);
/**
* Executes when plugin key is pressed - toggles fix option
* @returns Promise<boolean> - Always returns true to continue watch mode
*/
async run(): Promise<boolean>;
/**
* Provides usage information for Jest watch mode display
* @returns Object with key and prompt for watch mode menu
*/
getUsageInfo(): WatchPluginUsageInfo;
}
interface WatchPluginOptions {
/** Output stream for plugin messages */
stdout: NodeJS.WriteStream;
/** Plugin configuration */
config: {
/** Key to press for activating plugin (default: 'F') */
key?: string;
};
}
interface WatchPluginUsageInfo {
/** Key to display in watch mode menu */
key: string;
/** Description text for watch mode menu */
prompt: string;
}Usage Examples:
// jest.config.js - Adding watch plugin
module.exports = {
projects: [
{
runner: 'jest-runner-eslint',
displayName: 'lint',
testMatch: ['<rootDir>/src/**/*.js'],
},
],
watchPlugins: [
'jest-runner-eslint/watch-fix',
],
};
// Custom key configuration
module.exports = {
watchPlugins: [
['jest-runner-eslint/watch-fix', { key: 'L' }],
],
};Module export for the watch plugin functionality.
/**
* Watch plugin module export
* Re-exports ESLintWatchFixPlugin from build directory
*/
const ESLintWatchFixPlugin = require("jest-runner-eslint/watch-fix");Usage Examples:
// Direct instantiation (not typically needed)
const ESLintWatchFixPlugin = require("jest-runner-eslint/watch-fix");
const plugin = new ESLintWatchFixPlugin({
stdout: process.stdout,
config: { key: 'F' }
});
// Get current usage info
const usageInfo = plugin.getUsageInfo();
console.log(`Press ${usageInfo.key} to ${usageInfo.prompt}`);
// Toggle fix option
await plugin.run();Internal system for managing fix option overrides during watch mode.
/**
* Configuration override manager for watch mode fix option
* Singleton instance that manages global fix state
*/
class ConfigOverrides {
/**
* Sets the fix option override value
* @param fix - Boolean value to set as fix override
*/
setFix(fix: boolean): void;
/**
* Gets the current fix option override value
* @returns Current fix override value or undefined if not set
*/
getFix(): boolean | undefined;
}
/** Singleton instance of ConfigOverrides */
const configOverrides: ConfigOverrides;Usage Examples:
// Internal usage by watch plugin
const configOverrides = require('./utils/configOverrides');
// Toggle current fix state
const currentFix = configOverrides.getFix();
configOverrides.setFix(!currentFix);
// Check fix state in runner
const fixOverride = configOverrides.getFix();
const shouldFix = fixOverride !== undefined ? fixOverride : baseConfig.fix;The watch plugin integrates with Jest's watch mode system to provide interactive ESLint configuration.
Key Features:
Watch Mode Display:
Watch Usage
› Press f to run only failed tests.
› Press o to only run tests related to changed files.
› Press F to toggle ESLint --fix (disabled).
› Press q to quit watch mode.The prompt text updates based on current fix state:
"override ESLint --fix" - When no override is set"toggle ESLint --fix (disabled)" - When fix is explicitly disabled"toggle ESLint --fix (enabled)" - When fix is explicitly enabled