npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-performance-rules

v1.0.1

Published

ESLint plugin to detect performance anti-patterns

Readme

eslint-plugin-performance

ESLint plugin to detect performance anti-patterns in JavaScript and TypeScript codebases. This plugin helps identify code patterns that may cause runtime performance degradation through static AST analysis.

Features

  • 🔍 Detects quadratic loop complexity (O(n²) patterns)
  • 🚫 Identifies synchronous blocking calls in loops
  • ⚡ Catches expensive JSON parsing in loops
  • ⚛️ Finds React inline object creation causing re-renders
  • 🎯 Detects unnecessary array cloning
  • 📊 Performance score formatter with impact assessment
  • 🔧 Works with JavaScript and TypeScript
  • ✅ Zero runtime dependencies

Installation

npm install eslint-plugin-performance --save-dev

Configuration

ESLint Configuration (.eslintrc.json)

{
  "plugins": ["performance"],
  "extends": ["plugin:performance/recommended"]
}

Or configure rules individually:

{
  "plugins": ["performance"],
  "rules": {
    "performance/no-quadratic-loops": "warn",
    "performance/no-sync-in-loop": "warn",
    "performance/no-large-json-parse-in-loop": "warn",
    "performance/react-no-inline-object-creation": "warn",
    "performance/no-unnecessary-array-clone": "warn"
  }
}

Flat Config (eslint.config.js)

const performancePlugin = require('eslint-plugin-performance');

module.exports = [
  {
    plugins: {
      performance: performancePlugin
    },
    rules: {
      'performance/no-quadratic-loops': 'warn',
      'performance/no-sync-in-loop': 'warn',
      'performance/no-large-json-parse-in-loop': 'warn',
      'performance/react-no-inline-object-creation': 'warn',
      'performance/no-unnecessary-array-clone': 'warn'
    }
  }
];

Or use the recommended configuration:

const performancePlugin = require('eslint-plugin-performance');

module.exports = [
  {
    plugins: {
      performance: performancePlugin
    },
    rules: performancePlugin.configs.recommended.rules
  }
];

TypeScript Configuration

For TypeScript projects, configure the parser:

.eslintrc.json:

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "plugins": ["performance"],
  "extends": ["plugin:performance/recommended"]
}

eslint.config.js:

const performancePlugin = require('eslint-plugin-performance');
const tsParser = require('@typescript-eslint/parser');

module.exports = [
  {
    files: ['**/*.ts', '**/*.tsx'],
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        ecmaVersion: 2020,
        sourceType: 'module',
        ecmaFeatures: {
          jsx: true
        }
      }
    },
    plugins: {
      performance: performancePlugin
    },
    rules: performancePlugin.configs.recommended.rules
  }
];

Rules

no-quadratic-loops

Detects nested loops that iterate over the same array reference, which causes O(n²) algorithmic complexity.

Rationale: Nested loops over the same array create quadratic time complexity, causing exponential performance degradation as data size grows. A 1000-item array becomes 1,000,000 iterations. Detects synchronous blocking calls (fs.*Sync, child_process.*Sync) inside loops that block the event loop repeatedly.

Rationale: Synchronous file system and process operations block the Node.js event loop. Calling them in a loop multiplies the blocking time, freezing your application for extended periods.

no-large-json-parse-in-loop

Detects JSON.parse() calls inside loops, which causes repeated expensive parsing operations.

Rationale: JSON parsing is CPU-intensive. Parsing JSON repeatedly in a loop wastes processing time. Parse once before the loop or restructure your data flow.

react-no-inline-object-creation

Detects inline object literals, array literals, and arrow functions in JSX props that cause unnecessary re-renders.

Rationale: Creating new objects, arrays, or functions inline in JSX creates a new reference on every render. This causes child components to re-render even when the actual values haven't changed, breaking React's reconciliation optimization.

no-unnecessary-array-clone

Detects array cloning operations (spread operator, Array.from(), slice()) when the cloned array is never mutated.

Rationale: Cloning arrays allocates new memory and copies all elements. If you never mutate the clone, you're wasting memory and CPU cycles. Use the original array reference instead.

Usage

Running ESLint

# Standard ESLint run
npx eslint .

# With auto-fix (where applicable)
npx eslint . --fix

# Check specific files
npx eslint src/**/*.js

Example CLI Output

/project/src/utils/data.js
  12:3  warning  Nested loop iterates over same array, causing O(n²) complexity  performance/no-quadratic-loops
  28:5  warning  Synchronous blocking call inside loop blocks event loop         performance/no-sync-in-loop

/project/src/components/UserList.jsx
  15:23  warning  Inline object creation in JSX prop causes re-renders  performance/react-no-inline-object-creation
  16:21  warning  Inline arrow function in JSX prop causes re-renders   performance/react-no-inline-object-creation

✖ 4 problems (0 errors, 4 warnings)

Performance Formatter

Use the custom performance formatter to get an aggregated performance score:

npx eslint . --format ./node_modules/eslint-plugin-performance/lib/formatters/performance.js

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

MIT