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-10/

Legacy Code Modernizer

Create a tool that validates JavaScript files for legacy patterns that violate modern ESNext standards.

Problem Description

Build a code validator that analyzes JavaScript files and reports violations of modern JavaScript best practices. The validator should detect legacy patterns including: var declarations, non-arrow callback functions, direct arguments usage, and unsafe practices like eval() or with statements.

The tool accepts a file path, analyzes the code, and returns a structured violation report.

Requirements

Input

  • filePath (string): Path to the JavaScript file to validate
  • options (object, optional): Configuration for which checks to enable
    • checkVarUsage (boolean): Check for var usage (default: true)
    • checkCallbacks (boolean): Check for non-arrow callbacks (default: true)
    • checkArguments (boolean): Check for arguments usage (default: true)
    • checkUnsafe (boolean): Check for unsafe practices (default: true)

Output

A validation report object with:

  • filePath (string): The analyzed file path
  • violations (array): List of violation objects, each containing:
    • type (string): Violation category - one of: "var-usage", "arguments-usage", "non-arrow-callback", "unsafe-practice"
    • line (number): Line number of the violation
    • message (string): Human-readable description

Pattern Categories

Your validator should detect:

  1. Variable Declaration Issues

    • Usage of var keyword (should use let or const)
  2. Function Syntax Issues

    • Non-arrow functions used as callbacks (should use arrow functions)
    • Direct usage of the arguments object (should use rest parameters)
  3. Unsafe Practices

    • Use of eval()
    • Use of with statements

Test Cases

  • When analyzing a file with var x = 5;, the report includes a violation with type "var-usage" @test
  • When analyzing a file with function callback() {} passed to array methods like map, the report includes a violation with type "non-arrow-callback" @test
  • When analyzing a file with direct arguments usage in a function, the report includes a violation with type "arguments-usage" @test
  • When analyzing a file with eval(), the report includes a violation with type "unsafe-practice" @test
  • When analyzing a file with no legacy patterns, the report returns an empty violations array @test

Implementation

@generates

API

/**
 * Validates a JavaScript file for legacy patterns
 * @param {string} filePath - Path to the JavaScript file to validate
 * @param {Object} options - Optional configuration
 * @param {boolean} options.checkVarUsage - Check for var usage (default: true)
 * @param {boolean} options.checkCallbacks - Check for non-arrow callbacks (default: true)
 * @param {boolean} options.checkArguments - Check for arguments usage (default: true)
 * @param {boolean} options.checkUnsafe - Check for unsafe practices (default: true)
 * @returns {Promise<Object>} Validation report with filePath and violations array
 */
async function validateFile(filePath, options = {}) {
  // Implementation
}

module.exports = { validateFile };

Dependencies { .dependencies }

eslint { .dependency }

Provides JavaScript linting capabilities and AST parsing for code analysis.

@kunalgolani/eslint-config { .dependency }

Provides opinionated ESLint configuration for modern JavaScript (ESNext) with rules that enforce modern patterns like const/let over var, arrow functions for callbacks, rest parameters over arguments, and safety rules against eval and with statements.

Version

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