thoughtbot / eslint-config

A sharable ESLint configuration that enforces thoughtbot’s JavaScript guides.
https://thoughtbot.com
MIT License
10 stars 1 forks source link

Does not support ESLint v9.0.0 #10

Open stevepolitodesign opened 3 months ago

stevepolitodesign commented 3 months ago

Environment

yarn: 1.22.17 node: 21.4.0

Steps to reproduce

  1. Run yarn add eslint@latest
  2. Run yarn add @thoughtbot/eslint-config --dev
  3. Add .eslintrc.json with the following:
      {
        "extends": ["@thoughtbot/eslint-config/base"]
      }
  4. Add a sample file.
    // index.js
    const foo = 'bar';
  5. Run eslint command with ESLINT_USE_FLAT_CONFIG set to false per the latest release's recommendations.
    ESLINT_USE_FLAT_CONFIG=false yarn eslint *.js

Note the following output:

Oops! Something went wrong! :(

ESLint: 9.0.0

Error: Cannot read config file: /Users/polito/Desktop/thoughtbot_eslint_config_example/node_modules/@thoughtbot/eslint-config/base.js
Error: The ESLint patch script has only been tested with ESLint version 6.x, 7.x, and 8.x. (Your version: 9.0.0)
Consider reporting a GitHub issue:
https://github.com/microsoft/rushstack/issues
Referenced from: /Users/polito/Desktop/thoughtbot_eslint_config_example/.eslintrc.json
    at Object.<anonymous> (/Users/polito/Desktop/thoughtbot_eslint_config_example/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:184:11)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/polito/Desktop/thoughtbot_eslint_config_example/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
(node:1626) ESLintRCWarning: You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details.
(Use `node --trace-warnings ...` to show where the warning was created)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
emilford commented 3 months ago

These guides were shared while discussing Suspenders and this issue during our Web team sync.

Eslint Migrate to 9.x Guide Configuration Migration Guide Importing Plugins and Custom Parsers

rakeshpetit commented 3 months ago

Based on the guides, I tried to create a eslint.config.js like this:

const globals = require("globals");
const js = require("@eslint/js");
const thoughtbotBase = require("@thoughtbot/eslint-config/base");

module.exports = [
  js.configs.recommended,
  {
    files: ["**/*.js"],
    plugins: {
      "@thoughtbot-eslint": thoughtbotBase,
    },
  },
];

but hit an error in @rushstack/eslint-patch.

Error: Failed to patch ESLint because the calling module was not recognized.
If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:
https://github.com/microsoft/rushstack/issues
    at Object.<anonymous> (.../eslint-config/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:167:19)

This does seem like an issue in @rushstack/eslint-patch with an open https://github.com/microsoft/rushstack/issues/4635 to sort eslint-patch for ESLint 9.

I found in a playground how Flat configs must be specified for ESLint 9.0.0+ and tried that. After installing a few @typescript-eslint dependencies, the config in the playground repo worked well for my example project. So this indicated that we need to add support for Flag configs in our eslint-config based on https://github.com/typescript-eslint/typescript-eslint/pull/7935 where something similar was done.

Based on all this information, I feel like supporting ESLint 9.0.0+ might take longer due to our external dependencies.