nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.27k stars 2.32k forks source link

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

Open PaulACoroneos opened 3 days ago

PaulACoroneos commented 3 days ago

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

Additional Information

No response

PaulACoroneos commented 2 days ago

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