eslint / config-inspector

A visual tool for inspecting and understanding your ESLint flat configs.
https://www.npmjs.com/package/@eslint/config-inspector
Apache License 2.0
518 stars 15 forks source link

[Bug] Config Inspector uses recommended/deprecated rule indications from ESLint v9 rather than the installed ESLint version #53

Closed Standard8 closed 1 month ago

Standard8 commented 1 month ago

I am working on setting up flat configuration with ESLint v8.57.0 as an initial step before switching to v9.

I wanted to check the configuration, so I was trying out config inspector. Looking at the rules applied to all files from the recommended config, I was surprised to see some that weren't flagged as being included in the recommended configuration, or that were flagged as deprecated.

STR

  1. In a new project, install ESLint 8.57.0 and config-inspector 4.8.0.
  2. Create a dummy index.js file
  3. Create a simple eslint.config.mjs file:
import js from "@eslint/js";

export default [
  js.configs.recommended,
];
  1. Look at the results in the inspector (npx @eslint/config-inspector)

Actual Results

The rules are marked according to how they are in ESLint v9.

Expected Results

The rules are marked as recommended or deprecated according to how they were for ESLint v8.57.0, or not marked at all if the information is not available.

antfu commented 1 month ago

We read the info from your local eslint: https://github.com/eslint/config-inspector/blob/720e5de4c86c54a74a3e81c6144945fbd6b83faa/src/configs.ts#L107

Can you double check your lockfile and see if there is eslint v9 installed locally?

Standard8 commented 1 month ago

As referenced above, the project does not have ESLint v9 installed, I also do not have it installed globally.

If I install config-inspector into the repository that I created, then it seems to use v8 - the no-new-symbol rule is not marked as deprecated.

If I don't install config-inspector into the repository, but use it directly via npx @eslint/config-inspector@latest (as suggested by the readme then it is using v9 and no-new-symbol is marked as deprecated.

When I look in the .npm/_npx/ directory, I see that under the relevant node_modules/eslint/package.json ESLint is v9.

Looking around I can't see why there is a v9 installed in that .npm/_npx/ directory. If I clean it out and run only npx @eslint/config-inspector@latest then ESLint v9 gets put back into that directory.

So as far as I can tell, the inspector is picking up the ESLint installed alongside the config-inspector, rather than the ESLint installed in the local repository where the configuration is.

Standard8 commented 3 weeks ago

Thank you for fixing this, that works better.