简体   繁体   中英

ESLint throwing unpredicted errors with Hardhat

I recently began a project which uses hardhat. I ran npx hardhat. , and went with the advanced TS project.

Everything works fine, from the types to the solidity compiling, but ESLint always complains...

This is the kind of error I keep seeing:

在此处输入图像描述

在此处输入图像描述

As you can see the types are there, but ESLint continues to throw errors. This luckily doesn't stop the app to run.

Here is my config file:

module.exports = {
  env: {
    browser: false,
    es2021: true,
    mocha: true,
    node: true
  },
  plugins: ['@typescript-eslint'],
  extends: ['standard', 'plugin:node/recommended'],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 12
  },
  rules: {
    'node/no-unsupported-features/es-syntax': [
      'error',
      { ignores: ['modules'] }
    ]
  }
}

I've spent a lot of time on this issue, and the best method for me was to remove everything.

1 - Create a .ptettierrc.json file the root of your project.

2 - Run yarn remove eslint-plugin-promise eslint-plugin-node eslint-plugin-import eslint-config-standard eslint-config-prettier

3 - Change your ESLint config to the one below:

module.exports = {
  env: {
    browser: false,
    es2021: true,
    mocha: true,
    node: true
  },
  plugins: ['@typescript-eslint'],
  extends: ['plugin:prettier/recommended'],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 12
  },
  rules: {
    'node/no-unsupported-features/es-syntax': [
      'error',
      { ignores: ['modules'] }
    ]
  }
}

Keep in mind this is for a fresh config, if you've already changed your config, just remove any mentions of the package we removed on step 2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM