### Installing ESLint Rule Benchmark Package (npm) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/readme.md This command installs the `eslint-rule-benchmark` package as a development dependency using npm. It is the first step to set up the benchmarking tool in a project, allowing it to be used for performance analysis of ESLint rules. ```bash npm install --save-dev eslint-rule-benchmark ``` -------------------------------- ### Installing Project Dependencies with pnpm (Shell) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/contributing.md This command installs all necessary project dependencies using the pnpm package manager. It ensures that all required packages are available for development and testing. ```sh pnpm install ``` -------------------------------- ### Running ESLint Rule Benchmarks (npx) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/readme.md This command executes the `eslint-rule-benchmark` tool using `npx`, initiating the performance measurement based on the defined configuration file. It starts the benchmarking process for the specified ESLint rules, collecting performance data. ```bash npx eslint-rule-benchmark run ``` -------------------------------- ### Configuring ESLint Rule Benchmark (JavaScript) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/readme.md This JavaScript snippet demonstrates how to create a basic configuration file for `eslint-rule-benchmark` using the `defineConfig` helper. It defines a single test for a custom ESLint rule, specifying its `ruleId`, `rulePath`, and a `testPath` for a base case, enabling a quick start to benchmarking. ```js import { defineConfig } from 'eslint-rule-benchmark' export default defineConfig({ tests: [ { name: 'My Rule Performance', ruleId: 'my-plugin/my-rule', rulePath: '../rules/my-rule.js', cases: [ { testPath: './my-rule/base-case.js', }, ], }, ], }) ``` -------------------------------- ### Integrating ESLint Rule Benchmark with GitHub Actions (YAML) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/readme.md This YAML workflow configures a GitHub Action to automatically run ESLint Rule Benchmark on pull request events. It checks out the code, sets up Node.js, installs project dependencies, and then executes the benchmark, leveraging the GITHUB_TOKEN to post results as comments on the pull request. ```yaml name: ESLint Rule Benchmark on: pull_request: types: [opened, synchronize] jobs: benchmark: runs-on: ubuntu-latest permissions: pull-requests: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' - run: npm ci - name: Run benchmark env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx eslint-rule-benchmark run ``` -------------------------------- ### Advanced ESLint Rule Benchmark Configuration (TypeScript) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/readme.md This TypeScript configuration example showcases advanced options for `eslint-rule-benchmark`, including global settings for `iterations`, `warmup`, and `timeout`. It also demonstrates how to define multiple test groups with rule-specific overrides and test cases, including ESLint rule `options` and `severity` for granular control over benchmarking scenarios. ```typescript import { defineConfig } from 'eslint-rule-benchmark' export default defineConfig({ /* Number of measurement iterations. Default: 1000. */ iterations: 1000, /* Warmup configuration. */ warmup: { /* Number of warmup iterations. Default: 100. */ iterations: 100, /* Whether to enable warmup. Default: true. */ enabled: true, }, /* Max time per benchmark. Default: 5000. */ timeout: 5000, /* Array of benchmark test specifications. */ tests: [ { /* Descriptive name for this test group/specification. */ name: 'Rule: sort-imports', /* ESLint rule identifier. */ ruleId: 'sort-imports', /* Path to the rule's implementation. */ rulePath: '../lib/rules/sort-imports.ts', /* Override global benchmark settings for this specific test group. */ iterations: 50, timeout: 300, warmup: { iterations: 10, }, /* Array of test cases for this rule. */ cases: [ { testPath: './sort-imports/base-case.ts', /* ESLint rule options specific to this case. */ options: [{ order: 'asc', ignoreCase: true }], /* ESLint rule severity for this case (0, 1, 2). Default: 2. */ severity: 2, }, { testPath: './sort-imports/complex-case.ts', }, ], }, { name: 'Rule: sort-vars', ruleId: 'sort-vars', rulePath: '../lib/rules/sort-vars.ts', cases: [ { testPath: './sort-vars/base-case.ts', }, ], }, /* ... more test specifications */ ], }) ``` -------------------------------- ### Running Project Tests with pnpm (Shell) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/contributing.md This command executes the project's test suite using pnpm. Running tests is crucial to verify that local changes do not introduce regressions and adhere to project standards. ```sh pnpm test ``` -------------------------------- ### Cloning ESLint Rule Benchmark Repository (Shell) Source: https://github.com/azat-io/eslint-rule-benchmark/blob/main/contributing.md This command clones the ESLint Rule Benchmark repository from GitHub to your local machine, allowing you to begin development. It's the first step in setting up the project locally. ```sh git clone git@github.com:azat-io/eslint-rule-benchmark.git ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.