CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-eslint-config-node

tessl install tessl/npm-eslint-config-node@3.0.0

Pluggable ESLint configuration for Node.js that extends ESNext with Node.js-specific safety checks and best practices

Agent Success

Agent success rate when using this tile

73%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.12x

Baseline

Agent success rate without this tile

65%

task.mdevals/scenario-5/

ESLint Rule Configuration Manager

Build a Node.js utility that validates and merges ESLint rule configurations with proper severity level handling.

Requirements

Create a configuration utility that:

  1. Accepts ESLint rule configurations as JavaScript objects
  2. Validates that severity levels are valid (0, 1, 2, "off", "warn", or "error")
  3. Normalizes severity levels to their numeric form (0, 1, or 2)
  4. Merges multiple configuration objects, with later configs overriding earlier ones
  5. Reports which rules are configured at each severity level

Input Format

Rule configurations are objects where:

  • Keys are rule names (strings)
  • Values can be:
    • A severity level: 0, 1, 2, "off", "warn", or "error"
    • An array with severity as first element and options: [2, "always"] or ["error", { "max": 100 }]

Output Format

The utility should export a function mergeConfigs that:

  • Takes an array of configuration objects
  • Returns an object with:
    • config: The merged configuration (normalized to numeric severity)
    • summary: An object with counts: { disabled: <count>, warnings: <count>, errors: <count> }

Test Cases

Basic severity normalization

  • Given config { "no-console": "error" }, normalizes to { "no-console": 2 } @test
  • Given config { "no-console": "warn", "no-debugger": "off" }, normalizes to { "no-console": 1, "no-debugger": 0 } @test

Array-format rules

  • Given config { "quotes": ["error", "single"] }, normalizes to { "quotes": [2, "single"] } @test
  • Given config { "max-len": ["warn", { "code": 80 }] }, normalizes to { "max-len": [1, { "code": 80 }] } @test

Configuration merging

  • Merging { "no-console": 1 } and { "no-console": 2 } results in { "no-console": 2 } @test
  • Merging { "no-console": 1, "quotes": 2 } and { "no-debugger": 0 } results in { "no-console": 1, "quotes": 2, "no-debugger": 0 } @test

Summary generation

  • Config { "no-console": 2, "no-debugger": 1, "no-alert": 0 } produces summary { disabled: 1, warnings: 1, errors: 1 } @test
  • Config with array values { "quotes": [2, "single"], "semi": [0, "never"] } correctly counts severities @test

Validation

  • Invalid severity level 3 throws an error @test
  • Invalid severity string "invalid" throws an error @test

Implementation

@generates

API

/**
 * Merges multiple ESLint rule configurations with severity normalization.
 *
 * @param {Array<Object>} configs - Array of ESLint rule configuration objects
 * @returns {Object} Object with 'config' (merged rules) and 'summary' (severity counts)
 * @throws {Error} If any severity level is invalid
 */
function mergeConfigs(configs) {
  // Implementation here
}

module.exports = { mergeConfigs };

Dependencies { .dependencies }

@kunalgolani/eslint-config { .dependency }

Provides reference ESLint configuration patterns with multi-level severity settings.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/eslint-config-node@3.0.x
tile.json