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

ES Lint not setup correctly on new project #28971

Open
1 of 4 tasks
ccaspanello opened this issue Nov 16, 2024 · 4 comments
Open
1 of 4 tasks

ES Lint not setup correctly on new project #28971

ccaspanello opened this issue Nov 16, 2024 · 4 comments

Comments

@ccaspanello
Copy link

Current Behavior

When creating a new workspace ES Lint gives me errors. This occurs not only in Webstorm but also on the command line. I've tried this with a React project as well as a NestJS project. I'm not sure what is going on here. The following are steps to reproduce.

NX Version: v20.1.2

Error

nx lint my-app

> nx run my-app:lint

> eslint .


Oops! Something went wrong! :(

ESLint: 9.15.0

TypeError: Error while loading rule '@typescript-eslint/no-empty-function': Cannot read properties of undefined (reading 'allow')
Occurred while linting /Users/***/Desktop/nx-sandbox/apps/my-app/eslint.config.js
    at Object.create (/Users/***/Desktop/nx-sandbox/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint/lib/rules/no-empty-function.js:125:18)

Expected Behavior

I would expect ES lint to work out of the box without further configuration

GitHub Repo

No response

Steps to Reproduce

  1. Create Workspace:
    npx create-nx-workspace --pm pnpm

  2. Follow the wizard:

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · nx-sandbox
✔ Which stack do you want to use? · react
✔ What framework would you like to use? · none
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · my-app
✔ Which bundler would you like to use? · vite
✔ Test runner to use for end to end (E2E) tests · cypress
✔ Default stylesheet format · tailwind
✔ Which CI provider would you like to use? · github

 NX   Creating your v20.1.2 workspace.

✔ Installing dependencies with pnpm
✔ Successfully created the workspace: nx-sandbox.
✔ Nx Cloud has been set up successfully
✔ CI workflow has been generated successfully

 NX   Your CI setup is almost complete.
  1. Go into workspace directory
    cd nx-sandbox

  2. Ensure dependencies are installed
    pnpm install

  3. Try to run the lint command
    nx lint my-app

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.3.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.12.3

nx (global)        : 20.1.2
nx                 : 20.1.2
@nx/js             : 20.1.2
@nx/jest           : 20.1.2
@nx/eslint         : 20.1.2
@nx/workspace      : 20.1.2
@nx/cypress        : 20.1.2
@nx/eslint-plugin  : 20.1.2
@nx/react          : 20.1.2
@nx/vite           : 20.1.2
@nx/web            : 20.1.2
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/cypress/plugin
@nx/jest/plugin

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

No response

@bonejon
Copy link

bonejon commented Nov 16, 2024

I've been struggling against this error, but have just found this issue. There seems to be an incompatibility / breaking change in eslint 9.15.

typescript-eslint/typescript-eslint#10338

remove the ^ from the eslint entry in package.json to pin the version and it seems to work fine.
"eslint": "9.14.0",

@ccaspanello
Copy link
Author

@bonejon - Thanks for the advice. My current version was "eslint": "^9.8.0",. Removing the carrot did the trick. I guess when things like this happen (and they will) ... what is the right course of action and can/should NX do anything? I'm new to NX and I like it ... when it work ... when it doesn't it feels like it's hard to debug the "magic" it does.

@brandicph
Copy link

brandicph commented Nov 18, 2024

After upgrading to [email protected] many errors start to appear when running lint.

 NX   Error while loading rule '@typescript-eslint/no-empty-function': Cannot read properties of undefined (reading 'allow')

After downgrading to [email protected] everything works again.

Based on the following configuration

node: v22.11.0
nx: v20.1.2

UPDATE

It is working after updating typescript-eslint as @PaulACoroneos mentioned

"@typescript-eslint/eslint-plugin": "8.15.0",
"@typescript-eslint/parser": "8.15.0",
"eslint": "9.15.0",

@PaulACoroneos
Copy link
Contributor

Yes this is fixed in the canary of typescript-eslint. I believe fix will land later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants