1

我在 codeclimate 上遇到以下错误,有人可以帮助我吗

解析错误:找不到模块 'babel-plugin-root-import' 需要堆栈:- /usr/local/node_modules/@babel/core/lib/config/files/plugins.js - /usr/local/node_modules/@babel /core/lib/config/files/index.js - /usr/local/node_modules/@babel/core/lib/index.js - /usr/local/node_modules/@babel/eslint-parser/lib/worker/babel -core.cjs - /usr/local/node_modules/@babel/eslint-parser/lib/worker/handle-message.cjs - /usr/local/node_modules/@babel/eslint-parser/lib/client.cjs - / usr/local/node_modules/@babel/eslint-parser/lib/index.cjs - /usr/local/node_modules/eslint/lib/cli-engine/config-array-factory.js - /usr/src/app/lib /eslint6-patch.js - /usr/src/app/lib/eslint.js - /usr/src/app/bin/eslint.js

babel.config.js

module.exports = {
  sourceType: 'unambiguous',
  presets: [
    '@babel/preset-react',
    ['@babel/preset-env', {
      targets: '> 0.3%, not IE 11, not op_mini all, not samsung 4, not android 4.4.3-4.4.4',
      useBuiltIns: 'usage',
      corejs: { version: '3.8', proposals: false },
      modules: false,
    }],
  ],
  env: {
    development: {
      sourceMaps: true,
      plugins: ['source-map-support'],
    },
    test: {
      "plugins": ["@babel/plugin-transform-modules-commonjs"]
    }
  },
  plugins: [
    '@babel/transform-async-to-generator',
    '@babel/plugin-syntax-dynamic-import',
    'babel-plugin-root-import',
    '@babel/plugin-proposal-class-properties',
  ],
  ignore: ['node_modules/is_js'],
};

.eslintrc

{
  "parser": "@babel/eslint-parser",
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:import/recommended",
    "plugin:prettier/recommended"
  ],
  "plugins": ["jsx-a11y", "testing-library", "jest-dom", "jest", "prettier"],
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "commonjs": true,
    "jest/globals": true
  },
  "settings": {
    "react": {
      "version": "detect"
    },

    "import/resolver": {
      "node": {
        "extensions": [".js", ".jsx"]
      }
    }
  },
  "rules": {
    "camelcase": 0,
    "class-methods-use-this": 0,
    "func-names": 1,
    "global-require": 1,
    "import/named": 1,
    "import/namespace": 1,
    "import/no-mutable-exports": 1,
    "jsx-a11y/anchor-has-content": 1,
    "jsx-a11y/anchor-is-valid": 1,
    "jsx-a11y/click-events-have-key-events": 1,
    "jsx-a11y/control-has-associated-label": 1,
    "jsx-a11y/label-has-associated-control": 1,
    "jsx-a11y/label-has-for": 1,
    "jsx-a11y/mouse-events-have-key-events": 1,
    "jsx-a11y/no-static-element-interactions": 1,
    "max-classes-per-file": 1,
    "no-bitwise": 1,
    "no-console": 1,
    "no-empty-function": 0,
    "no-import-assign": 1,
    "no-multi-assign": 1,
    "no-nested-ternary": 1,
    "no-param-reassign": 1,
    "no-underscore-dangle": 1,
    "no-unused-expressions": ["warn", { "allowTaggedTemplates": true }],
    "no-unused-vars": 0,
    "no-use-before-define": 0, // Keep it disabled => https://stackoverflow.com/a/64024916/5001964
    "no-var-requires": 0,
    "one-var": 0,
    "prefer-rest-params": 0,
    "prefer-template": 0,
    "radix": 0,
    "react/destructuring-assignment": 0,
    "react/display-name": 0,
    "react/jsx-one-expression-per-line": ["warn", { "allow": "single-child" }],
    "react/no-array-index-key": 1,
    "react/no-children-prop": 0,
    "react/no-danger": 1,
    "react/no-deprecated": 1,
    "react/jsx-no-duplicate-props": 1,
    "react/no-find-dom-node": 1,
    "react/no-unused-prop-types": 0,
    "react/no-unused-state": 0,
    "react/prop-types": 1,
    "react/require-default-props": 0,
    "react/sort-comp": 0,
    "react/state-in-constructor": 0,
    "react/static-property-placement": 1,
    "vars-on-top": 0
  },
  "overrides": [
    {
      "files": [
        "**/__tests__/**/*.[jt]s?(x)",
        "**/?(*.)+(spec|test).[jt]s?(x)"
      ],
      "extends": [
        "plugin:jest-dom/recommended",
        "plugin:testing-library/react",
        "plugin:jest/recommended",
        "plugin:jest/style"
      ],
      "rules": {
        "jest/expect-expect": 0,
        "jest/no-disabled-tests": "warn",
        "jest/no-identical-title": "error",
        "jest/no-mocks-import": 0,
        "jest/prefer-to-have-length": "warn",
        "jest/valid-expect": 0,
        "jest/valid-title": 0,
        "testing-library/await-async-query": 0,
        "testing-library/no-node-access": 0,
        "testing-library/prefer-screen-queries": 0,
        "testing-library/render-result-naming-convention": 0,
        "valid-expect-in-promise": 0
      }
    }
  ]
}

.codeclimate.yml

{
  "parser": "@babel/eslint-parser",
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:import/recommended",
    "plugin:prettier/recommended"
  ],
  "plugins": ["jsx-a11y", "testing-library", "jest-dom", "jest", "prettier"],
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "commonjs": true,
    "jest/globals": true
  },
  "settings": {
    "react": {
      "version": "detect"
    },

    "import/resolver": {
      "node": {
        "extensions": [".js", ".jsx"]
      }
    }
  },
  "rules": {
    "camelcase": 0,
    "class-methods-use-this": 0,
    "func-names": 1,
    "global-require": 1,
    "import/named": 1,
    "import/namespace": 1,
    "import/no-mutable-exports": 1,
    "jsx-a11y/anchor-has-content": 1,
    "jsx-a11y/anchor-is-valid": 1,
    "jsx-a11y/click-events-have-key-events": 1,
    "jsx-a11y/control-has-associated-label": 1,
    "jsx-a11y/label-has-associated-control": 1,
    "jsx-a11y/label-has-for": 1,
    "jsx-a11y/mouse-events-have-key-events": 1,
    "jsx-a11y/no-static-element-interactions": 1,
    "max-classes-per-file": 1,
    "no-bitwise": 1,
    "no-console": 1,
    "no-empty-function": 0,
    "no-import-assign": 1,
    "no-multi-assign": 1,
    "no-nested-ternary": 1,
    "no-param-reassign": 1,
    "no-underscore-dangle": 1,
    "no-unused-expressions": ["warn", { "allowTaggedTemplates": true }],
    "no-unused-vars": 0,
    "no-use-before-define": 0, // Keep it disabled => https://stackoverflow.com/a/64024916/5001964
    "no-var-requires": 0,
    "one-var": 0,
    "prefer-rest-params": 0,
    "prefer-template": 0,
    "radix": 0,
    "react/destructuring-assignment": 0,
    "react/display-name": 0,
    "react/jsx-one-expression-per-line": ["warn", { "allow": "single-child" }],
    "react/no-array-index-key": 1,
    "react/no-children-prop": 0,
    "react/no-danger": 1,
    "react/no-deprecated": 1,
    "react/jsx-no-duplicate-props": 1,
    "react/no-find-dom-node": 1,
    "react/no-unused-prop-types": 0,
    "react/no-unused-state": 0,
    "react/prop-types": 1,
    "react/require-default-props": 0,
    "react/sort-comp": 0,
    "react/state-in-constructor": 0,
    "react/static-property-placement": 1,
    "vars-on-top": 0
  },
  "overrides": [
    {
      "files": [
        "**/__tests__/**/*.[jt]s?(x)",
        "**/?(*.)+(spec|test).[jt]s?(x)"
      ],
      "extends": [
        "plugin:jest-dom/recommended",
        "plugin:testing-library/react",
        "plugin:jest/recommended",
        "plugin:jest/style"
      ],
      "rules": {
        "jest/expect-expect": 0,
        "jest/no-disabled-tests": "warn",
        "jest/no-identical-title": "error",
        "jest/no-mocks-import": 0,
        "jest/prefer-to-have-length": "warn",
        "jest/valid-expect": 0,
        "jest/valid-title": 0,
        "testing-library/await-async-query": 0,
        "testing-library/no-node-access": 0,
        "testing-library/prefer-screen-queries": 0,
        "testing-library/render-result-naming-convention": 0,
        "valid-expect-in-promise": 0
      }
    }
  ]
}

4

0 回答 0