CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-eslint-config-canonical

Canonical ESLint Shareable Config providing comprehensive code style guide with 1,000+ rules for JavaScript/TypeScript projects

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

testing-configurations.mddocs/

Testing Configurations

ESLint configurations optimized for various testing frameworks. These configurations provide framework-specific rules, patterns, and best practices for writing maintainable tests.

Capabilities

Jest Configuration

Comprehensive Jest testing configuration with rules for describe blocks, test organization, and Jest-specific patterns.

/**
 * Jest testing framework ESLint configuration
 * Includes plugin: jest
 * Applies to: Jest test files and Jest-specific patterns
 */
interface JestConfiguration {
  recommended: ESLintConfig;
}

declare const jest: JestConfiguration;

Usage Examples:

import * as jest from 'eslint-config-canonical/jest';
import tseslint from 'typescript-eslint';

export default tseslint.config({
  files: ['**/*.test.{js,ts}', '**/*.spec.{js,ts}', '**/__tests__/**/*.{js,ts}'],
  ...jest.recommended,
});

Key Features:

  • Jest-specific globals (describe, it, expect, etc.)
  • Test structure and organization rules
  • Assertion best practices
  • Mock usage patterns
  • Async test handling

Vitest Configuration

Configuration for Vitest testing framework with modern testing patterns and Vite integration.

/**
 * Vitest testing framework ESLint configuration
 * Includes plugin: @vitest/eslint-plugin
 * Provides Vitest-specific rules and patterns
 */
interface VitestConfiguration {
  recommended: ESLintConfig;
}

declare const vitest: VitestConfiguration;

Usage Examples:

import * as vitest from 'eslint-config-canonical/vitest';
import tseslint from 'typescript-eslint';

export default tseslint.config({
  files: ['**/*.test.{js,ts}', '**/*.spec.{js,ts}'],
  ...vitest.recommended,
});

Key Features:

  • Vitest-specific globals and utilities
  • Modern testing patterns
  • Vite integration considerations
  • Performance testing rules
  • Snapshot testing best practices

AVA Configuration

Configuration for AVA testing framework with its unique execution model and assertion patterns.

/**
 * AVA testing framework ESLint configuration
 * Includes plugin: ava
 * Provides AVA-specific rules and test patterns
 */
interface AVAConfiguration {
  recommended: ESLintConfig;
}

declare const ava: AVAConfiguration;

Usage Examples:

import * as ava from 'eslint-config-canonical/ava';
import tseslint from 'typescript-eslint';

export default tseslint.config({
  files: ['test/**/*.js', '**/*.test.js'],
  ...ava.recommended,
});

Key Features:

  • AVA-specific test patterns
  • Concurrent test execution rules
  • Assertion library integration
  • Test file organization
  • Macro usage patterns

Mocha Configuration

Configuration for Mocha testing framework with traditional BDD/TDD patterns and lifecycle hooks.

/**
 * Mocha testing framework ESLint configuration
 * Includes plugin: mocha
 * Provides Mocha-specific rules and patterns
 */
interface MochaConfiguration {
  recommended: ESLintConfig;
}

declare const mocha: MochaConfiguration;

Usage Examples:

import * as mocha from 'eslint-config-canonical/mocha';
import tseslint from 'typescript-eslint';

export default tseslint.config({
  files: ['test/**/*.{js,ts}', '**/*.test.{js,ts}'],
  ...mocha.recommended,
});

Key Features:

  • Mocha globals (describe, it, before, after, etc.)
  • BDD and TDD pattern enforcement
  • Hook usage best practices
  • Test organization rules
  • Async test patterns

Integration Patterns

Multi-Framework Project

import * as jest from 'eslint-config-canonical/jest';
import * as vitest from 'eslint-config-canonical/vitest';
import tseslint from 'typescript-eslint';

export default tseslint.config(
  // Jest for unit tests
  {
    files: ['src/**/*.test.{js,ts}'],
    ...jest.recommended,
  },
  
  // Vitest for integration tests
  {
    files: ['tests/integration/**/*.{js,ts}'],
    ...vitest.recommended,
  }
);

TypeScript Testing Setup

import * as canonical from 'eslint-config-canonical';
import * as typescript from 'eslint-config-canonical/typescript';
import * as jest from 'eslint-config-canonical/jest';
import tseslint from 'typescript-eslint';

export default tseslint.config(
  // Base configuration
  canonical.recommended,
  
  // TypeScript support
  {
    files: ['**/*.{ts,tsx}'],
    ...typescript.recommended,
  },
  
  // Jest tests
  {
    files: ['**/*.test.ts', '**/*.spec.ts'],
    ...jest.recommended,
  }
);

React Component Testing

import * as canonical from 'eslint-config-canonical';
import * as typescript from 'eslint-config-canonical/typescript';
import * as react from 'eslint-config-canonical/react';
import * as jest from 'eslint-config-canonical/jest';
import tseslint from 'typescript-eslint';

export default tseslint.config(
  canonical.recommended,
  
  // TypeScript files
  {
    files: ['**/*.{ts,tsx}'],
    ...typescript.recommended,
  },
  
  // React components
  {
    files: ['**/*.{jsx,tsx}'],
    ...react.recommended,
  },
  
  // Component tests
  {
    files: ['**/*.test.{jsx,tsx}', '**/*.spec.{jsx,tsx}'],
    ...jest.recommended,
  }
);

Testing Best Practices Enforced

Test Structure

All testing configurations enforce proper test structure:

// ✅ Correct - descriptive test names
describe('UserService', () => {
  it('should return user data when valid ID is provided', () => {
    // test implementation
  });
});

// ❌ Incorrect - vague test names
describe('UserService', () => {
  it('works', () => {
    // test implementation
  });
});

Assertion Patterns

// ✅ Correct - specific assertions
expect(result).toBe(expected);
expect(array).toHaveLength(3);

// ❌ Incorrect - truthy/falsy assertions for specific values
expect(result).toBeTruthy(); // when you expect a specific value
expect(array.length).toBeTruthy(); // when you expect a specific length

Async Test Handling

// ✅ Correct - proper async/await usage
it('should fetch user data', async () => {
  const user = await fetchUser(1);
  expect(user.name).toBe('John');
});

// ❌ Incorrect - missing await
it('should fetch user data', () => {
  const user = fetchUser(1); // Promise not awaited
  expect(user.name).toBe('John');
});

Framework-Specific Rules

Jest-Specific Patterns

  • Consistent test file naming
  • Proper mock usage and cleanup
  • Snapshot testing best practices
  • Setup and teardown lifecycle management

Vitest-Specific Patterns

  • Proper test isolation
  • Vite-specific mock patterns
  • Performance testing considerations
  • Modern ES module testing

AVA-Specific Patterns

  • Concurrent test execution safety
  • Proper assertion usage
  • Macro pattern enforcement
  • Test context management

Mocha-Specific Patterns

  • Hook usage optimization
  • Timeout management
  • Context sharing best practices
  • Reporter-friendly test organization

Install with Tessl CLI

npx tessl i tessl/npm-eslint-config-canonical

docs

auto-configuration.md

core-configurations.md

framework-configurations.md

index.md

testing-configurations.md

utility-configurations.md

tile.json