Closed numandev1 closed 3 years ago
It looks like you are subclassing Linter
. Can you create an example to reproduce this using Linter
directly?
My hunch is this has something to do with how your project is packaged rather than an issue in ESLint itself. Otherwise we would have had this error reported already.
We had the same error in eslint demo when esquery v1.2.0 was published with "module"
field.
In Node runtime, const esquery = require("esquery")
is an object that looks like this: { parse, match, ... }
.
Webpack, by default, prefers "module"
over "main"
. In the esquery package, "module"
points to an ESM module that uses default export: export default { parse, match, ... }
, which results in a different interface. In the bundle, esquery
becomes { default: { parse, match, ... } }
instead of expected { parse, match, ... }
, and that's why esquery.parse()
fails.
We solved this for eslint demo by configuring Webpack to prefer "main"
over "module"
here (https://github.com/eslint/website/pull/707). That way, it bundles the same modules ESLint is using in Node runtime (except for packages that have the "browser"
field).
@mdjermanovic thanks it has resolved my issue.
Environment
Environment Info:
Node version: v14.15.4 npm version: v6.14.10 Local ESLint version: v7.32.0 Global ESLint version: v7.32.0 (Currently used) Operating System: darwin 20.3.0
What parser are you using?
@typescript-eslint/parser
What did you do?
Configuration
```js const eslintPlugins = { react: require("eslint-plugin-react"), "react-hooks": require("eslint-plugin-react-hooks"), "unused-imports": require("eslint-plugin-unused-imports"), prettier: require("eslint-plugin-prettier"), }; const linterConfig = { parser: parseForESLint, parserOptions: { ecmaFeatures: { jsx: true }, ecmaVersion: 2017, sourceType: "module", }, }; ```above function is calling
super.verify
method of eslint which is giving this errorTypeError: esquery.parse is not a function
What did you expect to happen?
should get props array now I am getting an empty array with below
TypeError: esquery.parse is not a function
What actually happened?
I am trying to get the props to array from this code
but I am getting this error
TypeError: esquery.parse is not a function
Participation
Additional comments
when I try to use
above function is calling
super.verify
method of eslint which is giving below errorhere is my transformedCode code