codeclimate-eslint icon indicating copy to clipboard operation
codeclimate-eslint copied to clipboard

Add support for plugins for eslint-7 channel

Open mileslane opened this issue 3 years ago • 6 comments

Actual Behavior

It would be helpful to be able to get our GitHub Codeclimate checks to pass. Currently, we are getting errors like this:

Parsing error: Cannot find module 'babel-plugin-macros' Require stack: - /code/babel.config.js

Expected Behavior

Our babel.config.js file uses the following plugins that are not present in the list of Dependencies in the eslint-7 package.json file:

  • babel-plugin-macros
  • @babel/preset-typescript
  • @babel/plugin-proposal-optional-chaining
  • @babel/plugin-syntax-dynamic-import
  • @babel/plugin-transform-destructuring
  • @babel/plugin-proposal-class-properties
  • @babel/plugin-proposal-private-methods
  • @babel/plugin-proposal-private-property-in-object
  • @babel/plugin-proposal-object-rest-spread
  • @babel/plugin-transform-regenerator

NOTES

Running codeclimate analyze -e eslint:eslint-7 locally does not trigger these complaints about these plugins.


  • [X] 4-6 word issue title

mileslane avatar Feb 02 '22 20:02 mileslane

Here is my proposed patch (I don't have write access):

diff --git a/package.json b/package.json
index 39296eac..2e871ec3 100644
--- a/package.json
+++ b/package.json
@@ -15,11 +15,20 @@
     "@babel/plugin-transform-runtime": "^7.13.10",
     "@babel/preset-env": "^7.14.7",
     "@babel/preset-react": "^7.14.5",
+    "@babel/preset-typescript": "^7.16.7",
+    "@babel/plugin-proposal-object-rest-spread": "^7.16.7",
+    "@babel/plugin-proposal-optional-chaining": "^7.16.7",
+    "@babel/plugin-proposal-private-methods": "^7.16.11",
+    "@babel/plugin-proposal-private-property-in-object": "^7.16.7",
+    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
+    "@babel/plugin-transform-destructuring": "^7.16.7",
+    "@babel/plugin-transform-regenerator": "^7.16.7",
     "@babel/runtime": "^7.14.8",
     "@hapi/eslint-plugin": "^5.0.0",
     "@typescript-eslint/eslint-plugin": "^4.33.0",
     "@typescript-eslint/parser": "^4.33.0",
     "babel-eslint": "^10.0.1",
+    "babel-plugin-macros": "^3.1.0",
     "babel-plugin-react-generate-property": "^1.0.5",
     "eslint": "7.8.1",
     "eslint-config-airbnb": "^17.1.0",

mileslane avatar Feb 02 '22 22:02 mileslane

If you like, I could put up a separate PR for each of these plugins for your consideration.

mileslane avatar Feb 05 '22 15:02 mileslane

Ah. I see the problem. Our lead developer is requiring individual plugins from @babel/preset-env in the process of specifying the babel configuration. This appears to be the issues he is trying to resolve: Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-methods. Is it possible to make Codeclimate not choke when individual plugins are required that are included in @babel/preset-env?

mileslane avatar Feb 05 '22 15:02 mileslane

So, it appears that there are two plugins that are definitely missing in your package.json file:

  • babel-plugin-transform-react-remove-prop-types (https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types#readme)
  • babel-plugin-macros (https://github.com/kentcdodds/babel-plugin-macros)

mileslane avatar Feb 05 '22 16:02 mileslane

We're also seeing similar errors, but for the babel-plugin-module-resolver plugin.

chrisjimenez avatar Feb 09 '22 18:02 chrisjimenez

@mileslane @chrisjimenez Would you mind testing your projects again please? Some updates were done on the engine that may fix your issue: #578 #579

camillof avatar Jun 27 '22 20:06 camillof