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

Using eslint version 8.0.0-rc.0 crashes @open-wc/eslint-config #2325

Closed
tirithen opened this issue Oct 7, 2021 · 4 comments
Closed

Using eslint version 8.0.0-rc.0 crashes @open-wc/eslint-config #2325

tirithen opened this issue Oct 7, 2021 · 4 comments

Comments

@tirithen
Copy link

tirithen commented Oct 7, 2021

Expected behavior

Finally eslint has support for class fields in version 8.0.0-rc.0! So I upgraded in package.json in my existing project created half a year ago with the terrific npm init @open-wc command.

I expected (or at least hoped :) fingers crossed) that it would work right out the box so that I could start using private class fields in my code without the linter crashing on syntax errors.

Actual Behavior

Upgrading to that verison in my project makes the @open-wc/eslint-config configuration crash.

➜  open-wc-project ✗ npx eslint --ext .js,.html . --ignore-path .gitignore

Oops! Something went wrong! :(

ESLint: 8.0.0-rc.0

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Failed to load plugin 'import' declared in 'package.json » @open-wc/eslint-config » /home/user/open-wc-project/node_modules/eslint-config-airbnb-base/index.js » /home/user/open-wc-project/node_modules/eslint-config-airbnb-base/rules/imports.js': Package subpath './lib/util/glob-util' is not defined by "exports" in /home/user/open-wc-project/node_modules/eslint/package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (/home/user/open-wc-project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/user/open-wc-project/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js:43:34)

Additional context

➜  open-wc-project ✗ node --version
v16.10.0
➜  open-wc-project ✗ npm --version
7.24.1

Most relevant parts of package.json:

{
  "devDependencies": {
    "@open-wc/eslint-config": "^4.3.0",
    "@open-wc/testing": "^2.5.33",
    "eslint": "^8.0.0-rc.0",
    "eslint-config-prettier": "^8.3.0",
  },
  "eslintConfig": {
    "extends": [
      "@open-wc/eslint-config",
      "eslint-config-prettier"
    ],
    "rules": {
      "no-continue": "off",
      "max-classes-per-file": "off",
      "import/no-extraneous-dependencies": "off"
    }
  }
}

Running prettier seem to fail the files with private fields as well, but at least it does not crash so it is not as large of a blocker:

➜  open-wc-project ✗ npx prettier "**/*.js" --check --ignore-path .gitignore 
Checking formatting...
[warn] examples/custom-elements.js
[warn] Code style issues found in the above file(s). Forgot to run Prettier?

Thanks for all the great work you have put into making modern JavaScript accessible for more developers! 👍

@nsisodiya
Copy link

facing the same problem.

@nsisodiya
Copy link

any solution to temporary fix this?

@nsisodiya
Copy link

I manually installed the latest import plugin and it worked

npm install eslint-plugin-import

infact, I think, if you remove the node_modules and package_lock.json file, and do a fresh npm install, that will also solve the problem.
my node_modules was somehow having an older version of eslint-plugin-import.
try checking version

npm ls eslint-plugin-import

as mentioned in import-js/eslint-plugin-import#2252 (comment) v 2.22.2 or higher is needed.

@tirithen
Copy link
Author

tirithen commented Dec 2, 2021

@nsisodiya nice, I also no longer get import crashes anymore, even without the eslin-plugin-import dependency that you mentioned, only Node.js 17.1.0.

Now I need to figure out the next problem I have, how to get private fields support with eslint 8.3.0, but I'll create another issue for that.

@tirithen tirithen closed this as completed Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants