ESLint Config Inspector
repository·main·Indexed 23 days ago
https://github.com/eslint/config-inspectorA visual tool for inspecting and understanding ESLint flat configurations through an interactive web interface. It allows developers to run a local server via npx, build static Single-Page Applications (SPA) of their configuration, and utilize a CLI for configuration path resolution and rule extraction. The tool supports modern flat config filenames (e.g., eslint.config.js, .ts) and provides a set of UI components for visualizing rules, files, and configuration items.
What's inside @eslint/config-inspector
- The ESLint Config Inspector is composed of several UI building blocks used to visualize ESLint configurations. These components are categorized into Chrome (navigation and badges), Configs (configuration details), Rules (rule listings and states), Files (file-specific information), and Primitives (low-level UI elements).
Use ESLint Config Inspector Config components
mainConfig components are used to display information about the ESLint configuration itself:
- ConfigItem: Displays configuration items, including scoped versions.
- ColorizedConfigName: Displays configuration names with colorization.
- SummarizeItem: Used to summarize items, such as rules.
- GlobItem: Displays glob patterns used in configurations.
Use ESLint Config Inspector Chrome components
mainThe Chrome components provide the high-level interface for the inspector:
- NavBar: The main navigation bar.
- ConfigInspectorBadge: A badge used within the inspector UI.
Use ESLint Config Inspector Rule components
mainRule components are used to visualize the status and details of ESLint rules:
- RuleList: A collection of rules.
- RuleItem: An individual rule in a list view.
- RuleStateItem: Displays the state of a rule, including options.
- ColorizedRuleName: Displays rule names with colorization (e.g., for plugin rules).
- RuleLevelIcon: Displays an icon representing the rule's error level.
- RuleDeprecatedInfo: Displays information regarding deprecated rules.
Use ESLint Config Inspector File components
mainFile components manage the display of file-related information:
- FileGroupItem: Groups files together (e.g., grouping Vue files).
- FileItem: Represents an individual file.
Use ESLint Config Inspector Primitive components
mainPrimitives are low-level building blocks:
- OptionSelectGroup: A group for selecting options.
- Shiki: A component for syntax highlighting using Shiki.
Build a static web app of your ESLint config
mainYou can generate a static Single-Page Application (SPA) that contains a snapshot of your current ESLint configuration. This is useful for deploying the configuration view to a web server or using it for comparisons. The output will be generated in the
dist/__eslint-config-inspectordirectory.npx @eslint/config-inspector buildRun ESLint Config Inspector locally
mainTo visually inspect and understand your ESLint flat configs, navigate to your project root (the directory containing
eslint.config.js) and run the inspector usingnpx. The tool will start a local server, typically athttp://localhost:7777, where you can interact with your configuration. Changes made to your configuration files will be automatically reflected in the inspector.npx @eslint/config-inspector@latestUnderstand the ESLintConfig return type
mainWhen calling
readConfig, the returned object contains three primary properties:configs: An array ofFlatConfigItemobjects representing the raw configuration items (including ESLint defaults).dependencies: An array of file paths representing all local files transitively imported by the configuration. These are the files the inspector should watch.payload: A processed object containing:configs: Transformed configuration items (e.g., with simplified plugin/parser references).rules: A flattened map of all available rules (including name, plugin, and metadata).files: (Optional) A list ofMatchedFileobjects ifglobMatchedFileswas enabled, mapping file paths to the specific configs that apply to them.meta: Metadata includinglastUpdate,basePath, andconfigPath.
View ESLint Config Inspector CLI options
mainTo see all available command-line options for the inspector, use the--helpflag. This applies to both the standard execution and the build command.Troubleshoot ESLint config path errors
mainIf you encounter errors related to finding or loading ESLint configuration files, the
@eslint/config-inspectoruses specific error types to provide diagnostic information:ConfigPathError: Occurs when the inspector cannot find any valid ESLint configuration file. The error message will list the directory it searched (basePath) and the specific filenames it was looking for (configFilenames).ConfigPathLegacyError: Occurs when the inspector encounters an unsupported legacy configuration file instead of the new flat config format. The inspector only supports the new flat config format as described in the ESLint documentation.
Read and process ESLint configuration
mainUse
readConfigto load an ESLint configuration file and transform it into a processed payload suitable for the Config Inspector.readConfigperforms several complex tasks:- Loads the config: Uses
jitito ensure compatibility with various module formats (ESM, CJS, TS). - Cache Busting: Appends
mtimequery parameters to URLs to ensure that changes to the config or its transitive imports are reflected during hot-reloads. On Node.js ≥ 22.15, it usesmodule.registerHooksto propagate this cache-busting to all imported files. - Dependency Tracking: Automatically discovers all local files imported by the configuration so the inspector can watch them for changes.
- Rule Extraction: Merges built-in ESLint rules with rules defined in your configuration and plugins.
- Default Injection: Includes ESLint's default configurations (languages, ignores, and file patterns).
Options
Option Type Default Description chdirbooleantrueIf true, changes the current process working directory to the configuration'sbasePath.globMatchedFilesbooleantrueIf true, performs a file system walk to find all files that match the provided configuration.- Loads the config: Uses