简体   繁体   English

更改了 ESLint,React 错误不再显示在浏览器中

[英]Changed ESLint, React errors no longer show in browser

I'm working on a project with multiple people, and we changed our ESLint a bit.我正在和多人一起做一个项目,我们稍微改变了我们的 ESLint。 If there were React/ ESLint errors, it would fail to compile and show the errors in the browser.如果有 React/ESLint 错误,它将无法编译并在浏览器中显示错误。

The project was made using CRA a few years ago and is still on React 17该项目是几年前使用 CRA 制作的,目前仍在使用 React 17

The problem: Since changing, all the errors go to the Problems tab and the browser just freezes.问题:自更改以来,“问题”选项卡中的所有错误 go 和浏览器都冻结了。 Also, the errors appear in the dev tools.此外,错误出现在开发工具中。 It's almost like the errors are just going to the wrong spot.这几乎就像错误只是去了错误的地方。 I'd really like the errors to also appear in the browser.我真的希望错误也出现在浏览器中。

Here is my.eslintrc.js: Any ideas?这是 my.eslintrc.js:有什么想法吗?

  env: {
    browser: true,
    node: true,
    es6: true,
    es2021: true,
  },
  extends: ['airbnb', 'prettier'],
  overrides: [],
  parserOptions: {
    ecmaVersion: 12,
    sourceType: 'module',
  },
  ignorePatterns: ['src/assets/js/*.js', 'node_modules/*'],
  plugins: ['react', 'prettier'],
  rules: {
    'prettier/prettier': ['error'],
    'react/prop-types': 'off',
    'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
    camelcase: 'off',
    'jsx-a11y/no-static-element-interactions': 'off',
    'import/no-extraneous-dependencies': 'off',
    'default-param-last': 'off',
  },
};

It could be some local error unrelated to ESLint, but I just changed that and a few dependencies.这可能是一些与 ESLint 无关的本地错误,但我只是更改了它和一些依赖项。

package.json

    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsx-a11y": "^6.6.1",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.31.11",
    "eslint-plugin-react-hooks": "^4.6.0",

Thank you, I'd really appreciate any help.谢谢你,我真的很感激任何帮助。

I solved it.我解决了。 I deleted our package-lock.json at some point when doing a new npm install and somehow that caused this error.我在进行新的npm install时删除了我们的package-lock.json并且不知何故导致了这个错误。 I thought it was typically okay to delete lock files, but after I added it back and did a fresh install it all seems okay now.我认为删除锁定文件通常是可以的,但在我将其添加回来并进行全新安装后,现在一切似乎都可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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