CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-eslint-plugin-github

An opinionated collection of ESLint shared configs and rules used by GitHub for maintaining code quality across JavaScript and 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

binary-tools.mddocs/

Binary Tools

Command-line utilities for automated ESLint workflow enhancement and rule management.

Capabilities

eslint-ignore-errors Command

Automatically adds eslint-disable-next-line comments for ESLint violations in JavaScript files.

/**
 * Command-line utility for adding ESLint disable comments
 */
interface ESLintIgnoreErrors {
  /** Binary name in package.json */
  binary: 'eslint-ignore-errors';
  /** Entry point file */
  entryPoint: 'bin/eslint-ignore-errors.js';
  /** Command usage pattern */
  usage: 'eslint-ignore-errors <file.js>';
  /** Process ESLint JSON output and insert disable comments */
  functionality: 'ProcessESLintOutput';
}

Basic Usage:

# Add disable comments for all violations in a file
eslint-ignore-errors app/assets/javascripts/something.js

# Process multiple files
eslint-ignore-errors src/components/Button.js
eslint-ignore-errors src/utils/helpers.js

Command Functionality

The tool processes ESLint violations and automatically inserts appropriate disable comments.

/**
 * Core functionality of eslint-ignore-errors
 */
interface IgnoreErrorsProcess {
  /** Execute ESLint on target file and get JSON output */
  executeESLint(filePath: string): Promise<ESLintResult[]>;
  
  /** Process ESLint results and group violations by line */
  groupViolationsByLine(results: ESLintResult[]): Record<number, string[]>;
  
  /** Insert disable comments into source code */
  insertDisableComments(
    filePath: string, 
    violationsByLine: Record<number, string[]>
  ): void;
  
  /** Check if a line already contains a disable comment */
  isDisableComment(line: string): boolean;
  
  /** Merge new rule IDs into existing disable comments */
  mergeDisableComment(existingComment: string, newRuleIds: string[]): string;
}

interface ESLintResult {
  filePath: string;
  messages: ESLintMessage[];
}

interface ESLintMessage {
  line: number;
  column: number;
  ruleId: string;
  message: string;
}

Advanced Usage Examples:

# Example workflow for introducing new rules
# 1. Run eslint to see violations
npx eslint src/legacy-code.js

# 2. Add disable comments for all current violations
eslint-ignore-errors src/legacy-code.js

# 3. The file now has disable comments like:
# /* eslint-disable-next-line github/no-blur, github/no-inner-html */
# element.innerHTML = content;
# element.blur();

Comment Generation Logic

The tool intelligently handles comment insertion and merging.

/**
 * Comment generation and management logic
 */
interface CommentGeneration {
  /** Generate new disable comment for rule violations */
  generateDisableComment(ruleIds: string[], indentation: string): string;
  
  /** Detect existing disable comments */
  detectExistingComment(line: string): {
    isDisableComment: boolean;
    ruleIds: string[];
    commentFormat: string;
  };
  
  /** Merge multiple rule IDs into single comment */
  mergeRuleIds(existing: string[], newRules: string[]): string[];
  
  /** Preserve code indentation when inserting comments */
  preserveIndentation(sourceLine: string): string;
}

Comment Format Examples:

// Single rule violation
/* eslint-disable-next-line github/no-blur */
element.blur();

// Multiple rule violations on same line
/* eslint-disable-next-line github/no-blur, github/no-inner-html */
element.innerHTML = '<span>content</span>';
element.blur();

// Merging with existing comment
// Before: /* eslint-disable-next-line no-console */
// After: /* eslint-disable-next-line no-console, github/no-dataset */
console.log(element.dataset.userId);

File Processing Workflow

The tool follows a systematic approach to process files safely.

/**
 * File processing workflow steps
 */
interface ProcessingWorkflow {
  /** Read original file content */
  readSourceFile(filePath: string): string[];
  
  /** Execute ESLint with JSON formatter */
  runESLintAnalysis(filePath: string): {
    stdout: string;
    results: ESLintResult[];
  };
  
  /** Group violations by line number for batch processing */
  organizeViolations(messages: ESLintMessage[]): Record<number, string[]>;
  
  /** Insert comments while preserving existing disable comments */
  processLineByLine(
    sourceLines: string[],
    violationMap: Record<number, string[]>
  ): string[];
  
  /** Write modified content back to file */
  writeModifiedFile(filePath: string, modifiedLines: string[]): void;
}

Workflow Example:

// Original code with violations
function problematicFunction() {
  element.blur();                    // Line 2: github/no-blur
  element.innerHTML = userContent;   // Line 3: github/no-inner-html
  users.forEach(u => process(u));    // Line 4: github/array-foreach
}

// After running eslint-ignore-errors
function problematicFunction() {
  /* eslint-disable-next-line github/no-blur */
  element.blur();                    
  /* eslint-disable-next-line github/no-inner-html */
  element.innerHTML = userContent;   
  /* eslint-disable-next-line github/array-foreach */
  users.forEach(u => process(u));    
}

Error Handling and Edge Cases

The tool handles various edge cases and error conditions.

/**
 * Error handling and edge case management
 */
interface ErrorHandling {
  /** Handle ESLint execution failures */
  handleESLintErrors(error: Error, filePath: string): void;
  
  /** Skip files that don't need processing */
  shouldSkipFile(results: ESLintResult[]): boolean;
  
  /** Handle file system permission errors */
  handleFileSystemErrors(error: NodeJS.ErrnoException, filePath: string): void;
  
  /** Validate file path exists and is readable */
  validateInputFile(filePath: string): boolean;
}

Edge Case Handling:

# File doesn't exist
eslint-ignore-errors nonexistent.js
# Tool will fail gracefully with error message

# File has no violations
eslint-ignore-errors clean-code.js
# Tool will skip processing (no changes made)

# File already has all disable comments
eslint-ignore-errors already-ignored.js
# Tool will detect existing comments and merge appropriately

Types

interface BinaryToolOptions {
  /** Target file path for processing */
  filePath: string;
  /** ESLint configuration to use */
  eslintConfig?: string;
  /** Output verbosity level */
  verbose?: boolean;
}

interface CommentInsertionResult {
  /** Number of comments inserted */
  commentsAdded: number;
  /** Number of existing comments merged */
  commentsMerged: number;
  /** Lines that were modified */
  modifiedLines: number[];
  /** Any errors encountered */
  errors: string[];
}

interface DisableCommentFormat {
  /** Full comment text */
  commentText: string;
  /** List of rule IDs in comment */
  ruleIds: string[];
  /** Indentation level */
  indentation: string;
  /** Comment style (single-line, multi-line) */
  style: 'single' | 'multi';
}

docs

binary-tools.md

configs.md

formatters.md

index.md

plugin.md

rules.md

tile.json