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

Getting NX error running lint when leveraging typescript-eslint v8 and newer projectService config in eslint config #27961

Closed
1 of 4 tasks
PaulACoroneos opened this issue Sep 17, 2024 · 3 comments

Comments

@PaulACoroneos
Copy link
Contributor

Current Behavior

Hi all. I am trying to migrate to typescript-eslint v8 and leverage the new projectService configuration. However when I update my .eslintrc.cjs with the following syntax:

module.exports = {
  extends: ['plugin:@nx/react', '../../../.eslintrc.json'],
  ignorePatterns: ['!**/*'],
  overrides: [
    {
      files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
      rules: {},
      parserOptions: {
        projectService: {
          allowDefaultProject: ['*.js', '*.ts'],
        },
        tsconfigRootDir: __dirname,
      },
    },
    {
      files: ['*.ts', '*.tsx'],
      rules: {},
    },
    {
      files: ['*.js', '*.jsx'],
      rules: {},
    },
  ],
};

And a typescript-eslint rule in my global eslint config file such as

        "@typescript-eslint/restrict-template-expressions": [
          "error",
          {
            "allowArray": true
          }
        ],

I get the following error when trying to use the nx lint exector:

Error: You have attempted to use the lint rule "@typescript-eslint/restrict-template-expressions" which requires the full TypeScript type-checker to be available, but you do not have "parserOptions.project" configured to point at your project tsconfig.json files in the relevant TypeScript file "overrides" block of your ESLint config "<path to eslint config>/.eslintrc.cjs"
Occurred while linting <path to file in directory>

Please see https://nx.dev/recipes/tips-n-tricks/eslint for full guidance on how to resolve this issue.

Expected Behavior

I expect projectService option (what is supposed to replace project in eslint config) to work as expected and not throw an error about project not existing

GitHub Repo

No response

Steps to Reproduce

See description of of current behavior

Nx Report

Node           : 20.17.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.7.1

nx                 : 19.6.2
@nx/js             : 19.6.2
@nx/jest           : 19.6.2
@nx/linter         : 19.6.2
@nx/eslint         : 19.6.2
@nx/workspace      : 19.6.2
@nx/cypress        : 19.6.2
@nx/devkit         : 19.6.2
@nx/esbuild        : 19.6.2
@nx/eslint-plugin  : 19.6.2
@nx/express        : 19.6.2
@nx/next           : 19.6.2
@nx/node           : 19.6.2
@nx/plugin         : 19.6.2
@nx/react          : 19.6.2
@nx/rollup         : 19.6.2
@nx/storybook      : 19.6.2
@nrwl/tao          : 19.6.2
@nx/web            : 19.6.2
@nx/webpack        : 19.6.2
typescript         : 5.4.3

Failure Logs

Error: You have attempted to use the lint rule "@typescript-eslint/restrict-template-expressions" which requires the full TypeScript type-checker to be available, but you do not have "parserOptions.project" configured to point at your project tsconfig.json files in the relevant TypeScript file "overrides" block of your ESLint config "<path to eslint config>/.eslintrc.cjs"
Occurred while linting <path to file in directory>

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@PaulACoroneos
Copy link
Contributor Author

Please let me know if any additional repro details are needed.

@JamesHenry
Copy link
Collaborator

JamesHenry commented Sep 21, 2024

I would personally recommend migrating to flat config (eslint.config.js) at the same time as moving to typescript-eslint v8 and eslint v9, rather than using this new construct with the legacy eslintrc config style, it's a combination that is less likely to be tested and covered by the various projects in question. I'm afraid it is a combination that accordingly won't be a priority for us to look into at this time. If you still run into any issues once on flat config please let us know

(PS .eslintrc.js has never been something we've officially supported as a combination with .eslintrc.json like you have here, so again you are a bit off the beaten track with this)

@JamesHenry JamesHenry closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2024
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants