Skip to content

MatanelGordon/eslint-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESLint Analyzer

ESLint Analyzer Icon

LLM-Ready SQL queries on ESLint errors in your project

A powerful tool for analyzing ESLint output with SQL queries, perfect for understanding code quality patterns and planning migration strategies.

Motivation

ESLint Analyzer is designed for:

  • Error Analysis: Deep dive into your project's linting issues with SQL queries
  • Statistics: Generate comprehensive reports on code quality metrics
  • Migration Strategies: Plan ESLint adoption in large legacy projects by understanding error distribution
  • Team Insights: Identify patterns and prioritize fixes across your codebase

Perfect for teams wanting to bring ESLint to existing projects or analyze code quality at scale.

Table Structure

The tool creates a DuckDB table with the following columns:

Column Type Description
file_path TEXT Path to the file containing the error/warning
rule_id TEXT ESLint rule identifier (e.g., no-unused-vars)
project_name TEXT Project name (derived from uploaded file name)
start_line INTEGER Line number where the issue starts
end_line INTEGER Line number where the issue ends
start_column INTEGER Column number where the issue starts
end_column INTEGER Column number where the issue ends
fixable BOOLEAN Whether the issue can be auto-fixed
deprecated BOOLEAN Whether the rule is deprecated
node_type TEXT AST node type where the issue occurs
severity TEXT Issue severity (error or warning)

Getting Started

1. Run the Application

# Using Docker
docker run -p 3000:3000 eslint-analyzer

# Or run locally
pnpm install
pnpm start
image

The application will be available at http://localhost:3000

2. Generate ESLint JSON Files

In your project(s), generate ESLint output in JSON format:

# Single project
eslint . --format json --output-file my-project.json

# For monorepos - create separate files for each package
eslint packages/frontend --format json --output-file frontend.json
eslint packages/backend --format json --output-file backend.json

Note: The filename (without extension) becomes the project_name in the database.

3. Upload and Process

  1. Open the web interface at http://localhost:3000
  2. Upload your JSON file(s) using the file picker
  3. Optional: Enter your project's root directory name to convert absolute file paths to relative paths (removes usernames and system-specific paths)
  4. Click "Process" to import the data
  5. Multiple files can be uploaded for monorepo analysis

Useful Queries

Here are some LLM-made practical SQL queries to analyze your ESLint data:

Total Errors and Warnings Count

SELECT 
    severity,
    COUNT(*) as count
FROM eslint 
GROUP BY severity;

Top 10 Files with Most Issues

SELECT 
    file_path,
    COUNT(*) as total_issues,
    SUM(CASE WHEN severity = 'error' THEN 1 ELSE 0 END) as errors,
    SUM(CASE WHEN severity = 'warning' THEN 1 ELSE 0 END) as warnings
FROM eslint 
GROUP BY file_path 
ORDER BY total_issues DESC 
LIMIT 10;

Top 10 Files with Only Fixable Issues

SELECT 
    file_path,
    COUNT(*) as fixable_issues
FROM eslint 
WHERE fixable = true
GROUP BY file_path
HAVING COUNT(*) = (
    SELECT COUNT(*) 
    FROM eslint e2 
    WHERE e2.file_path = eslint.file_path
)
ORDER BY fixable_issues DESC 
LIMIT 10;

Files with Only Fixable Warnings

SELECT 
    file_path,
    COUNT(*) as fixable_warnings
FROM eslint 
WHERE severity = 'warning' 
    AND fixable = true
GROUP BY file_path
HAVING COUNT(*) = (
    SELECT COUNT(*) 
    FROM eslint e2 
    WHERE e2.file_path = eslint.file_path 
        AND e2.severity = 'warning'
)
ORDER BY fixable_warnings DESC;

Most Common Rules by Project

SELECT 
    project_name,
    rule_id,
    COUNT(*) as occurrences
FROM eslint 
GROUP BY project_name, rule_id 
ORDER BY project_name, occurrences DESC;

Contributing

Just kidding, there's no contribution process! 😄

But if you find this tool useful and want to improve it, send me an email.

About

Extracts ESLint errors to DuckDB for querying.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published