Parsing error require of es modules

I tried to use .eslintrc.js like this. Here is it: module.exports = { 'settings': { 'react': { 'createClass': 'createReactClass', // Regex for Component Factory to u...

I tried to use .eslintrc.js like this. Here is it:

module.exports = {
    'settings': {
        'react': {
            'createClass': 'createReactClass', // Regex for Component Factory to use,
            // default to 'createReactClass'
            'pragma': 'React',  // Pragma to use, default to 'React'
            'fragment': 'Fragment',  // Fragment to use (may be a property of <pragma>), default to 'Fragment'
            'version': 'detect', // React version. 'detect' automatically picks the version you have installed.
            // You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
            // default to latest and warns if missing
            // It will default to 'detect' in the future
            'flowVersion': '0.53' // Flow version
        },
        'propWrapperFunctions': [
            // The names of any function used to wrap propTypes, e.g. `forbidExtraProps`. If this isn't set, any propTypes wrapped in a function will be skipped.
            'forbidExtraProps',
            { 'property': 'freeze', 'object': 'Object' },
            { 'property': 'myFavoriteWrapper' },
            // for rules that check exact prop wrappers
            { 'property': 'forbidExtraProps', 'exact': true }
        ],
        'componentWrapperFunctions': [
            // The name of any function used to wrap components, e.g. Mobx `observer` function. If this isn't set, components wrapped by these functions will be skipped.
            'observer', // `property`
            { 'property': 'styled' }, // `object` is optional
            { 'property': 'observer', 'object': 'Mobx' },
            { 'property': 'observer', 'object': '<pragma>' } // sets `object` to whatever value `settings.react.pragma` is set to
        ],
        'formComponents': [
            // Components used as alternatives to <form> for forms, eg. <Form endpoint={ url } />
            'CustomForm',
            { 'name': 'Form', 'formAttribute': 'endpoint' }
        ],
        'linkComponents': [
            // Components used as alternatives to <a> for linking, eg. <Link to={ url } />
            'Hyperlink',
            { 'name': 'Link', 'linkAttribute': 'to' }
        ]
    },
    'env': {
        'commonjs': true
    },
    'parserOptions': {
        'ecmaVersion': 7,
        'sourceType': 'module',
        'allowImportExportEverywhere': false,
        'ecmaFeatures': {
            'globalReturn': false,
        },
    },
    'parser': 'babel-eslint'
}

And, in package.json:

{
   ...
  "devDependencies": {
    "babel-eslint": "^10.1.0",
    "eslint": "^8.3.0",
    "eslint-plugin-react": "^7.27.1",
    ....
  }
}

Then, run:

And, caused:

...cookie.jsx   # This is an empty file.
  0:0  error  Parsing error: require() of ES Module ...definition.js from ...require-from-eslint.js not supported.
Instead change the require of definition.js in ...require-from-eslint.js to a dynamic import() which is available in all CommonJS modules

It looks like a configure problems, but I cannot solve it. I tried changing other configure or copy an exist configure file from other projects, it doesn’t help.

Could you help me solve?

Thanks.

I am currently setting up a boilerplate with React, TypeScript, styled components, Webpack, etc., and I am getting an error when trying to run ESLint:

Error: Must use import to load ES Module

Here is a more verbose version of the error:

/Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
  0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
require() of ES modules is not supported.
require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json

The error occurs in every single one of my .js and .ts/ .tsx files where I only use import or the file doesn’t even have an import at all. I understand what the error is saying, but I don’t have any idea why it is being thrown when in fact I only use imports or even no imports at all in some files.

Here is my package.json file where I trigger the linter from using npm run lint:eslint:quiet:

{
  "name": "my-react-boilerplate",
  "version": "1.0.0",
  "description": "",
  "main": "index.tsx",
  "directories": {
    "test": "test"
  },
  "engines": {
    "node": ">=14.0.0"
  },
  "type": "module",
  "scripts": {
    "build": "webpack --config webpack.prod.js",
    "dev": "webpack serve --config webpack.dev.js",
    "lint": "npm run typecheck && npm run lint:css && npm run lint:eslint:quiet",
    "lint:css": "stylelint './src/**/*.{js,ts,tsx}'",
    "lint:eslint:quiet": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet",
    "lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern",
    "lint:eslint:fix": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet --fix",
    "test": "cross-env NODE_ENV=test jest --coverage",
    "test:watch": "cross-env NODE_ENV=test jest --watchAll",
    "typecheck": "tsc --noEmit",
    "precommit": "npm run lint"
  },
  "lint-staged": {
    "*.{ts,tsx,js,jsx}": [
      "npm run lint:eslint:fix",
      "git add --force"
    ],
    "*.{md,json}": [
      "prettier --write",
      "git add --force"
    ]
  },
  "husky": {
    "hooks": {
      "pre-commit": "npx lint-staged && npm run typecheck"
    }
  },
  "resolutions": {
    "styled-components": "^5"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.5.4",
    "@babel/plugin-proposal-class-properties": "^7.5.0",
    "@babel/preset-env": "^7.5.4",
    "@babel/preset-react": "^7.0.0",
    "@types/history": "^4.7.6",
    "@types/react": "^17.0.29",
    "@types/react-dom": "^17.0.9",
    "@types/react-router": "^5.1.17",
    "@types/react-router-dom": "^5.1.5",
    "@types/styled-components": "^5.1.15",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "babel-cli": "^6.26.0",
    "babel-eslint": "^10.0.2",
    "babel-loader": "^8.0.0-beta.6",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "clean-webpack-plugin": "^4.0.0",
    "dotenv-webpack": "^7.0.3",
    "error-overlay-webpack-plugin": "^1.0.0",
    "eslint": "^8.0.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-config-with-prettier": "^6.0.0",
    "eslint-plugin-compat": "^3.3.0",
    "eslint-plugin-import": "^2.25.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-react": "^7.14.2",
    "eslint-plugin-react-hooks": "^4.2.0",
    "extract-text-webpack-plugin": "^3.0.2",
    "file-loader": "^6.2.0",
    "html-webpack-plugin": "^5.3.2",
    "husky": "^7.0.2",
    "prettier": "^2.4.1",
    "raw-loader": "^4.0.2",
    "style-loader": "^3.3.0",
    "stylelint": "^13.13.1",
    "stylelint-config-recommended": "^5.0.0",
    "stylelint-config-styled-components": "^0.1.1",
    "stylelint-processor-styled-components": "^1.10.0",
    "ts-loader": "^9.2.6",
    "tslint": "^6.1.3",
    "typescript": "^4.4.4",
    "url-loader": "^4.1.1",
    "webpack": "^5.58.2",
    "webpack-cli": "^4.2.0",
    "webpack-dev-server": "^4.3.1",
    "webpack-merge": "^5.3.0"
  },
  "dependencies": {
    "history": "^4.10.0",
    "process": "^0.11.10",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router-dom": "^5.2.0",
    "styled-components": "^5.2.1"
  }
}

Here is my .eslintrc file:

{
  "extends": ["airbnb", "prettier"],
  "parser": "babel-eslint",
  "plugins": ["prettier", "@typescript-eslint"],
  "parserOptions": {
    "ecmaVersion": 8,
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "impliedStrict": true,
      "classes": true
    }
  },
  "env": {
    "browser": true,
    "node": true,
    "jest": true
  },
  "rules": {
    "arrow-body-style": ["error", "as-needed"],
    "class-methods-use-this": 0,
    "react/jsx-filename-extension": 0,
    "global-require": 0,
    "react/destructuring-assignment": 0,
    "import/named": 2,
    "linebreak-style": 0,
    "import/no-dynamic-require": 0,
    "import/no-named-as-default": 0,
    "import/no-unresolved": 2,
    "import/prefer-default-export": 0,
    "semi": [2, "always"],
    "max-len": [
      "error",
      {
        "code": 80,
        "ignoreUrls": true,
        "ignoreComments": true,
        "ignoreStrings": true,
        "ignoreTemplateLiterals": true
      }
    ],
    "new-cap": [
      2,
      {
        "capIsNew": false,
        "newIsCap": true
      }
    ],
    "no-param-reassign": 0,
    "no-shadow": 0,
    "no-tabs": 2,
    "no-underscore-dangle": 0,
    "react/forbid-prop-types": [
      "error",
      {
        "forbid": ["any"]
      }
    ],
    "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
    "react/jsx-no-bind": [
      "error",
      {
        "ignoreRefs": true,
        "allowArrowFunctions": true,
        "allowBind": false
      }
    ],
    "react/no-unknown-property": [
      2,
      {
        "ignore": ["itemscope", "itemtype", "itemprop"]
      }
    ]
  }
}

And I’m not sure if it is relevant, but here is also my tsconfig.eslint.json file:

{
  "extends": "./tsconfig.json",
  "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.js"],
  "exclude": ["node_modules/**", "build/**", "coverage/**"]
}

How can I fix this?

Googling the error does not present any useful forums or raised bugs. Most of them just state not to use require in your files which I am not.

Dung Do Tien Jun 27 2022 334

Hi Dev guys, I have written a small NodeJs application.  I want to fetch data from API and display it on the browser as a table. I installed node-fetch package and use it to fetch data from API. You can see it here:

index.js

 const fetch = require('node-fetch');
var express = require('express');
var app = express();

app.get('/', async (req, res) =>  {
        const result = await getUser();
        console.log(result);
});

var server = app.listen(4500, function () {
    console.log('Server is running..');
});


async function getUser() {
    try {
      const response = await fetch('https://randomuser.me/api/');
  
      if (!response.ok) {
        throw new Error(`Error! status: ${response.status}`);
      }
  
      const result = await response.json();
      return result;
    } catch (err) {
      console.log(err);
    }
}

I used node index.js command to run Node app, but I got an exception throw Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: «node-fetchsrcindex.js». Require() of ES modules is not supported.

 Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:UserscontasourcereposNodeJsDemo1node_modulesnode-fetchsrcindex.js
require() of ES modules is not supported.
require() of C:UserscontasourcereposNodeJsDemo1node_modulesnode-fetchsrcindex.js from C:UserscontasourcereposNodeJsDemo1index.js is an ES module file as it is a .js file whose nearest parent packag
e.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename C:UserscontasourcereposNodeJsDemo1node_modulesnode-fetchsrcindex.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:UserscontasourcereposNo
deJsDemo1node_modulesnode-fetchpackage.json.

←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:13)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:985:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:878:14)←[39m
←[90m    at Module.require (internal/modules/cjs/loader.js:1025:19)←[39m
←[90m    at require (internal/modules/cjs/helpers.js:72:18)←[39m
    at Object.<anonymous> (C:UserscontasourcereposNodeJsDemo1index.js:1:15)
←[90m    at Module._compile (internal/modules/cjs/loader.js:1137:30)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:985:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:878:14)←[39m {
  code: ←[32m'ERR_REQUIRE_ESM'←[39m
}

Here is my package.json file:

 {
  "name": "Demo1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "dotenv": "^16.0.1",
    "express": "^4.18.1",
    "node-fetch": "^3.2.6"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

Where am I going wrong?

Thank you in advance.

Have 2 answer(s) found.

  • Based on your package.json file, you are using node-fetch version 3.  This version did not support require('node-fetch') syntax. 

    To solve this issue, you can:

    Step1:  add more "type": "module" into your package.json file.

     {
      ........
      "type": "module",
      ........
    }

    Step2:  Change

     const fetch = require('node-fetch');

    To

     import fetch from "node-fetch";

    It’ll be solved for you.

  • the error Require() of ES modules is not supported occurs because you installed node-fetch version 3 and you can downgrade and install version 2.

    To install node-fetch version 2, run the command:

    Your issue will be solved.

Related Q&A May You Like

  1. Error: listen EADDRINUSE: address already in use :::5000 in Node
  2. Nodejs ReferenceError: require is not defined in ES module scope
  3. Nodejs: Only file and data URLs are supported by the default ESM loader
  4. Error: Cannot find module ‘node-fetch’ in Express NodeJs
  5. SyntaxError: await is only valid in async function in Nodejs
  6. Error: Cannot find module ‘dotenv’ in NodeJs express
  7. Error: ReferenceError: window is not defined in NodeJs
  8. NodeJs: The «chunk» argument must be of type string or an instance of Buffer
  9. Error: Incorrect arguments to mysqld_stmt_execute in Nodejs
  10. NodeJs MongooseError: Operation ‘x.find()` buffering timed out after 10000ms
  11. NodeJs no ‘Access-Control-Allow-Origin’ header is present on the requested resource
  12. Exception throw referencerrror: fs is not defined in NodeJs
  13. Nodejs express throw npm err! missing script: start
  14. Throw the error: Cannot find module ‘express’ in NodeJs
  15. Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’ in Node

Leave An Answer

* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

Grepper Logo

Add Answer
|
View In TPC Matrix

Technical Problem Cluster First Answered On
September 1, 2021

Popularity
10/10

Helpfulness
5/10


Contributions From The Grepper Developer Community

Contents

Code Examples

  • Error [ERR_REQUIRE_ESM]: require() of ES Module
  • Solution for Error [ERR_REQUIRE_ESM]: require() of ES Module
  • Related Problems

  • error [err_require_esm]: require() of es module
  • err_require_esm node
  • babel-node err_require_esm
  • parsing error: require() of es module
  • err_require_esm chalk
  • js require instead of import
  • node js require module
  • TPC Matrix View Full Screen

    Error [ERR_REQUIRE_ESM]: require() of ES Module

    Comment

    2


    Popularity

    9/10 Helpfulness
    5/10
    Language
    typescript

    Source: stackoverflow.com

    Tags: module
    typescript

    Tijan Ayomide

    Contributed on Oct 04 2022

    Tijan Ayomide

    3 Answers  Avg Quality 8/10


    Solution for Error [ERR_REQUIRE_ESM]: require() of ES Module

    Comment

    3


    Popularity

    10/10 Helpfulness
    3/10
    Language
    javascript

    Source: www.npmjs.com

    Tags: javascript
    module
    solution

    Pleasant Puma

    Contributed on Sep 01 2021

    Pleasant Puma

    2 Answers  Avg Quality 5/10


    Grepper

    Features
    Reviews
    Code Answers
    Search Code Snippets

    Plans & Pricing
    FAQ
    Welcome
    Browsers Supported
    Grepper Teams

    Documentation

    Adding a Code Snippet

    Viewing & Copying Snippets

    Social

    Twitter LogoTwitter

    LinkedIn LogoLinkedIn

    Legal

    Privacy Policy
    Terms

    Contact

    support@codegrepper.com

    В настоящее время я настраиваю шаблон с React, TypeScript, стилизованными компонентами, Webpack и т. д., и я получаю сообщение об ошибке при попытке запустить ESLint:

    Ошибка: необходимо использовать импорт для загрузки модуля ES

    Вот более подробная версия ошибки:

    /Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
      0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
    require() of ES modules is not supported.
    require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
    Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json
    

    Ошибка возникает в каждом из моих файлов .js и .ts/.tsx, где я использую только import или в файле вообще нет импорта. Я понимаю, о чем говорит ошибка, но я понятия не имею, почему она возникает, когда на самом деле я использую только импорт или даже вообще не импортирую некоторые файлы.

    Вот мой файл package.json, в котором я запускаю линтер, используя npm run lint:eslint:quiet:

    {
      "name": "my-react-boilerplate",
      "version": "1.0.0",
      "description": "",
      "main": "index.tsx",
      "directories": {
        "test": "test"
      },
      "engines": {
        "node": ">=14.0.0"
      },
      "type": "module",
      "scripts": {
        "build": "webpack --config webpack.prod.js",
        "dev": "webpack serve --config webpack.dev.js",
        "lint": "npm run typecheck && npm run lint:css && npm run lint:eslint:quiet",
        "lint:css": "stylelint './src/**/*.{js,ts,tsx}'",
        "lint:eslint:quiet": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet",
        "lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern",
        "lint:eslint:fix": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet --fix",
        "test": "cross-env NODE_ENV=test jest --coverage",
        "test:watch": "cross-env NODE_ENV=test jest --watchAll",
        "typecheck": "tsc --noEmit",
        "precommit": "npm run lint"
      },
      "lint-staged": {
        "*.{ts,tsx,js,jsx}": [
          "npm run lint:eslint:fix",
          "git add --force"
        ],
        "*.{md,json}": [
          "prettier --write",
          "git add --force"
        ]
      },
      "husky": {
        "hooks": {
          "pre-commit": "npx lint-staged && npm run typecheck"
        }
      },
      "resolutions": {
        "styled-components": "^5"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "@babel/core": "^7.5.4",
        "@babel/plugin-proposal-class-properties": "^7.5.0",
        "@babel/preset-env": "^7.5.4",
        "@babel/preset-react": "^7.0.0",
        "@types/history": "^4.7.6",
        "@types/react": "^17.0.29",
        "@types/react-dom": "^17.0.9",
        "@types/react-router": "^5.1.17",
        "@types/react-router-dom": "^5.1.5",
        "@types/styled-components": "^5.1.15",
        "@typescript-eslint/eslint-plugin": "^5.0.0",
        "babel-cli": "^6.26.0",
        "babel-eslint": "^10.0.2",
        "babel-loader": "^8.0.0-beta.6",
        "babel-polyfill": "^6.26.0",
        "babel-preset-env": "^1.7.0",
        "babel-preset-react": "^6.24.1",
        "babel-preset-stage-2": "^6.24.1",
        "clean-webpack-plugin": "^4.0.0",
        "dotenv-webpack": "^7.0.3",
        "error-overlay-webpack-plugin": "^1.0.0",
        "eslint": "^8.0.0",
        "eslint-config-airbnb": "^18.2.0",
        "eslint-config-prettier": "^8.3.0",
        "eslint-config-with-prettier": "^6.0.0",
        "eslint-plugin-compat": "^3.3.0",
        "eslint-plugin-import": "^2.25.2",
        "eslint-plugin-jsx-a11y": "^6.2.3",
        "eslint-plugin-prettier": "^4.0.0",
        "eslint-plugin-react": "^7.14.2",
        "eslint-plugin-react-hooks": "^4.2.0",
        "extract-text-webpack-plugin": "^3.0.2",
        "file-loader": "^6.2.0",
        "html-webpack-plugin": "^5.3.2",
        "husky": "^7.0.2",
        "prettier": "^2.4.1",
        "raw-loader": "^4.0.2",
        "style-loader": "^3.3.0",
        "stylelint": "^13.13.1",
        "stylelint-config-recommended": "^5.0.0",
        "stylelint-config-styled-components": "^0.1.1",
        "stylelint-processor-styled-components": "^1.10.0",
        "ts-loader": "^9.2.6",
        "tslint": "^6.1.3",
        "typescript": "^4.4.4",
        "url-loader": "^4.1.1",
        "webpack": "^5.58.2",
        "webpack-cli": "^4.2.0",
        "webpack-dev-server": "^4.3.1",
        "webpack-merge": "^5.3.0"
      },
      "dependencies": {
        "history": "^4.10.0",
        "process": "^0.11.10",
        "react": "^17.0.1",
        "react-dom": "^17.0.1",
        "react-router-dom": "^5.2.0",
        "styled-components": "^5.2.1"
      }
    }
    

    Вот мой файл .eslintrc:

    {
      "extends": ["airbnb", "prettier"],
      "parser": "babel-eslint",
      "plugins": ["prettier", "@typescript-eslint"],
      "parserOptions": {
        "ecmaVersion": 8,
        "ecmaFeatures": {
          "experimentalObjectRestSpread": true,
          "impliedStrict": true,
          "classes": true
        }
      },
      "env": {
        "browser": true,
        "node": true,
        "jest": true
      },
      "rules": {
        "arrow-body-style": ["error", "as-needed"],
        "class-methods-use-this": 0,
        "react/jsx-filename-extension": 0,
        "global-require": 0,
        "react/destructuring-assignment": 0,
        "import/named": 2,
        "linebreak-style": 0,
        "import/no-dynamic-require": 0,
        "import/no-named-as-default": 0,
        "import/no-unresolved": 2,
        "import/prefer-default-export": 0,
        "semi": [2, "always"],
        "max-len": [
          "error",
          {
            "code": 80,
            "ignoreUrls": true,
            "ignoreComments": true,
            "ignoreStrings": true,
            "ignoreTemplateLiterals": true
          }
        ],
        "new-cap": [
          2,
          {
            "capIsNew": false,
            "newIsCap": true
          }
        ],
        "no-param-reassign": 0,
        "no-shadow": 0,
        "no-tabs": 2,
        "no-underscore-dangle": 0,
        "react/forbid-prop-types": [
          "error",
          {
            "forbid": ["any"]
          }
        ],
        "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
        "react/jsx-no-bind": [
          "error",
          {
            "ignoreRefs": true,
            "allowArrowFunctions": true,
            "allowBind": false
          }
        ],
        "react/no-unknown-property": [
          2,
          {
            "ignore": ["itemscope", "itemtype", "itemprop"]
          }
        ]
      }
    }
    

    И я не уверен, что это актуально, но вот еще мой файл tsconfig.eslint.json:

    {
      "extends": "./tsconfig.json",
      "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.js"],
      "exclude": ["node_modules/**", "build/**", "coverage/**"]
    }
    

    Как я могу это исправить?

    Поиск ошибки в Google не дает никаких полезных форумов или выявленных ошибок. Большинство из них просто заявляют, что не используют require в ваших файлах, чего я не делаю.

    Понравилась статья? Поделить с друзьями:

    Читайте также:

  • Parsing error property assignment expected
  • Passat b6 airbag error
  • Passat b5 ошибка c06ee
  • Passat b5 ошибка 65535
  • Pasito плюется жидкостью как исправить

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии