Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: yarn rw lint fails using local eslint config with typed linting rules after RW 8 upgrade #11735

Open
1 task done
Philzen opened this issue Nov 25, 2024 · 0 comments
Open
1 task done
Labels
bug/needs-info More information is needed for reproduction

Comments

@Philzen
Copy link
Contributor

Philzen commented Nov 25, 2024

What's not working?

We recently added an eslintrc.json to our project as described here. We did that b/c we like to have our named imports sorted (sort-imports) and enforce types to be explicitly imported as such (@typescript-eslint/consistent-type-imports).

Now after the upgrade from RW 7 to 8.4.1 running yarn rw lint throws:

=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=4.7.4 <5.6.0

YOUR TYPESCRIPT VERSION: 5.6.2

Please only submit bug reports when using the officially supported version.

=============

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Error while loading rule '@typescript-eslint/consistent-type-imports': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Parser: ./node_modules/@babel/eslint-parser/lib/index.cjs
Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.
Occurred while linting ./web/src/i18n.js
    at throwError (./node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:38:11)
    at getParserServices (./node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:21:9)
    at create (./node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js:88:68)
    at Object.create (./node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:31:20)
    at createRuleListeners (./node_modules/eslint/lib/linter/linter.js:895:21)
    at ./node_modules/eslint/lib/linter/linter.js:1066:110
    at Array.forEach (<anonymous>)
    at runRules (./node_modules/eslint/lib/linter/linter.js:1003:34)
    at Linter._verifyWithoutProcessors (./node_modules/eslint/lib/linter/linter.js:1355:31)
    at Linter._verifyWithConfigArray (./node_modules/eslint/lib/linter/linter.js:1807:21)
    at Linter.verify (./node_modules/eslint/lib/linter/linter.js:1437:65)
    at Linter.verifyAndFix (./node_modules/eslint/lib/linter/linter.js:2068:29)
    at verifyText (./node_modules/eslint/lib/cli-engine/cli-engine.js:254:48)
    at CLIEngine.executeOnFiles (./node_modules/eslint/lib/cli-engine/cli-engine.js:834:28)
    at ESLint.lintFiles (./node_modules/eslint/lib/eslint/eslint.js:551:23)
    at Object.execute (./node_modules/eslint/lib/cli.js:421:36)
    at async main (./node_modules/eslint/bin/eslint.js:152:22)

I tried all kinds of settings for parserOptions mentioned in the typed linting docs to no avail. However, adding

  "parser": "@typescript-eslint/parser",

to our .eslintrc.json makes the error go away – however i'm not sure this is really intended by @redwoodjs/eslint-config, as i would assume the Redwood team wants to employ @babel/eslint-parser here for a good reason, which probably was brought in via either #10911 or #11235.

How do we reproduce the bug?

Have any custom eslint config (js/cjs/json/whathaveyou) in your project that includes the rule @typescript-eslint/consistent-type-imports, for example, our .eslintrc.json looks as follows:

{
  "$schema": "https://json.schemastore.org/eslintrc.json",
  "extends": ["@redwoodjs/eslint-config"],
  "ignorePatterns": ["!.storybook/"],
  "root": true,
  "rules": {
    "sort-imports": [
      "error",
      {
        "ignoreDeclarationSort": true,
        "allowSeparatedGroups": true
      }
    ],
    "@typescript-eslint/consistent-type-imports": [
      "error",
      {
        "prefer": "type-imports"
      }
    ]
  }
}

What's your environment? (If it applies)

System:
    OS: Linux 6.6 Manjaro Linux
    Shell: 5.2.37 - /bin/bash
  Binaries:
    Node: 20.16.0 - /tmp/xfs-83057bbe/node
    Yarn: 4.4.0 - /tmp/xfs-83057bbe/yarn
  Databases:
    SQLite: 3.46.1 - /usr/bin/sqlite3
  npmPackages:
    @redwoodjs/auth-dbauth-setup: 8.4.1 => 8.4.1 
    @redwoodjs/cli-storybook-vite: 8.4.1 => 8.4.1 
    @redwoodjs/core: 8.4.1 => 8.4.1 
    @redwoodjs/project-config: 8.4.1 => 8.4.1

Are you interested in working on this?

  • I'm interested in working on this
@Philzen Philzen added the bug/needs-info More information is needed for reproduction label Nov 25, 2024
@Philzen Philzen changed the title [Bug?]: yarn rw lint fails with customized [Bug?]: yarn rw lint fails using local eslint config with typed linting rules Nov 25, 2024
@Philzen Philzen changed the title [Bug?]: yarn rw lint fails using local eslint config with typed linting rules [Bug?]: yarn rw lint fails using local eslint config with typed linting rules after RW 8 upgrade Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction
Projects
None yet
Development

No branches or pull requests

1 participant