lo1tuma / eslint-plugin-mocha

ESLint rules for mocha
MIT License
279 stars 61 forks source link

ramda 0.28.0 regression in 10.0.4 (node 17) #322

Closed higherorderfunctor closed 2 years ago

higherorderfunctor commented 2 years ago

Plugin is failing to load in a monorepo with an esm module package in it's workspace. Had to rollback to 10.0.3. This may be on the ramda side looking at https://github.com/ramda/ramda/issues/3241.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Failed to load plugin 'mocha' declared in '.eslintrc.cjs » ../../.eslintrc.js': Package subpath './src/find' is not defined by "exports" in ./node_modules/ramda/package.json

./packages//.eslintrc.cjs

module.exports = {
  extends: ["../../.eslintrc.js"],
};

./eslintrc.js

module.exports = {
  env: {
    es2021: true,
  },
  extends: [
    "airbnb-base",
    "eslint:recommended",
    "plugin:prettier/recommended",
    "plugin:import/recommended",
    "plugin:promise/recommended",
    "plugin:mocha/recommended",
  ],
  plugins: ["prettier", "promise", "mocha"],
  rules: {
    camelcase: "warn",
    "mocha/no-mocha-arrows": "off",
    "no-underscore-dangle": "warn",
    "no-shadow": "off",
  },
};
simlu commented 2 years ago

Running into the exact same issue here updating various packages. Something definitely broke

Edit: This only breaks for us running against node 17. We also test against node 14 and node 16 and it works fine there.

gajus commented 2 years ago

Thanks for the hint about v17. It works well with v16. Must be npm version difference.

lo1tuma commented 2 years ago

So it seems to be indeed a problem with ramda itself. Unfortunately the update was necessary since the old version contained a vulnerability, see #320.

This comment suggested a workaround to add the .js suffix to all ramda imports. Could anyone confirm that this would fix the issue? If so I would happy to apply this workaround.

higherorderfunctor commented 2 years ago

They merged a possible fix a couple hours ago to alter the exports: https://github.com/ramda/ramda/pull/3270

Not sure when it will make it into a release though.

danielduarte commented 2 years ago

As a workaround until ramda devs release the new version with the fix (that is already merged), I've installed the package pointing to a specific commit and worked fine for me (in Node.js v17 and previous).

npm install --save-dev "git://github.com/ramda/ramda.git#50c6b57110b2f3631ed8633141f12012b7768d85"

It's not the best, but since we're using ramda as an indirect dependency, it solves the issue. And of course, it's temporary.

simlu commented 2 years ago

@danielduarte Thanks for the update on this. We "solved" this by simply not updating to 10.0.4. Not ideal (we have dozens of repos and Devs keep forgetting to "downgrade" after an update 🤷‍♂️), but it works for now

lo1tuma commented 2 years ago

Fixed in version 10.0.5 by #326