webpack-contrib / eslint-loader

[DEPRECATED] A ESlint loader for webpack
MIT License
1.06k stars 121 forks source link

Uncaught Error: Module build failed (from ./node_modules/eslint-loader/dist/cjs.js): #302

Closed tranthaison1231 closed 5 years ago

tranthaison1231 commented 5 years ago

Expected Behavior

Actual Behavior

Code

// webpack.config.js
// If your code blocks are over 20 lines, please paste a link to a gist
// (https://gist.github.com).
// additional code, HEY YO remove this block if you don't need it

How Do We Reproduce?

ricardogobbosouza commented 5 years ago

@tranthaison1231 Could you provide more information or a repository?

tranthaison1231 commented 5 years ago

Yeah, I have repository so old, and yesterday I update it, but I have error with it.

tranthaison1231 commented 5 years ago

{ "name": "RAA-AnhDoan", "version": "0.1.0", "private": true, "dependencies": { "antd": "^3.23.5", "connected-react-router": "^6.5.2", "customize-cra": "^0.8.0", "history": "^4.10.1", "i18next": "^17.0.16", "i18next-browser-languagedetector": "^3.0.3", "less": "^3.10.3", "less-loader": "^5.0.0", "lodash": "^4.17.15", "moment": "^2.24.0", "prop-types": "^15.7.2", "react": "^16.10.1", "react-avatar-editor": "^11.0.7", "react-color": "^2.17.3", "react-dom": "^16.10.1", "react-i18next": "^10.13.1", "react-quill": "^1.3.3", "react-redux": "^7.1.1", "react-router": "^5.1.1", "react-router-dom": "^5.1.1", "react-scripts": "^3.1.2", "redux": "^4.0.4", "redux-saga": "^1.1.1", "reselect": "^4.0.0", "styled-components": "^4.4.0" }, "scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": "react-app" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ], "devDependencies": { "babel-plugin-import": "^1.12.2", "eslint-config-airbnb": "^18.0.1", "eslint-config-prettier": "^6.3.0", "plopfile-generate": "^2.0.18", "react-app-rewired": "^2.1.3" } }

tranthaison1231 commented 5 years ago

My error is image

ricardogobbosouza commented 5 years ago

@tranthaison1231 Some of your dependencies are using eslint-loader: 3.0.0 This bug was fixed in 3.0.1 and we are in 3.0.2

ricardogobbosouza commented 5 years ago

Try: npm install eslint-loader --save-dev

ricardogobbosouza commented 5 years ago

Here the problem react-scripts https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/package.json#L47

alexplumb commented 5 years ago

I started getting this error after upgrading from eslint@6.4.0 to eslint@6.5.0. I'm using eslint-loader@3.0.2.

ricardogobbosouza commented 5 years ago

@alexplumb Please share your configuration and if possible a repository to reproduce.

alexplumb commented 5 years ago

Here's my eslintrc and my webpack config

{
    "env": {
      "browser": true
    },
    "extends": [
      "airbnb",
      "plugin:react-redux/recommended"
    ],
    "plugins": [
      "react-redux",
      "react-hooks"
    ],
    "parser": "babel-eslint",
    "rules": {
      "react/jsx-one-expression-per-line": [ 2, {
        "allow": "single-child"
      }],
      "react/state-in-constructor": 0,
      "react/prop-types": 0,
      "react/jsx-props-no-spreading": 0,
      "import/prefer-default-export": 0,
      "prefer-const": 0,
      "no-bitwise": 0,
      "no-console": 0,
      "import/no-unresolved": 0,
      "max-len": [
        "warn", {
          "code": 150,
          "tabWidth": 2,
          "ignoreUrls": true,
          "ignoreComments": true,
          "ignoreRegExpLiterals": true,
          "ignoreStrings": true,
          "ignoreTemplateLiterals": true
        }
      ],
      "import/no-cycle": 0,
      "react-hooks/rules-of-hooks": "error",
      "react-hooks/exhaustive-deps": "warn"
    },
    "parserOptions": {
      "ecmaFeatures": {
        "legacyDecorators": true
      }
    }
}

and webpack

const webpackConfig: webpack.Configuration = {
  mode: 'development',
  target: 'web',
  devServer: {
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,PATCH,OPTIONS',
      'Access-Control-Allow-Headers': 'content-type,authorization,accept',
    },
    port: 5000,
    public: ngrok.baseAddress,
    contentBase: path.join(__dirname, 'public'),
    inline: true,
    historyApiFallback: true,
    clientLogLevel: 'none',
    open: true,
  },
  entry: {
    index: [
      'react-hot-loader/patch',
      './client/js/index.jsx',
    ],
  },
  devtool: 'eval',
  output: {
    path: path.resolve('./public'),
    publicPath: '/',
    pathinfo: true,
    filename: 'build/js/[name].js',
  },
  module: {
    rules: [
      {
        enforce: 'pre',
        test: /.(js|jsx)$/,
        exclude: [
          path.resolve(__dirname, 'node_modules'),
          path.resolve(__dirname, 'functions'),
        ],
        use: {
          loader: 'eslint-loader',
          options: {
            fix: true,
            emitError: true,
            formatter: eslintFormatter,
          },
        },
      },
      {
        test: /.(js|jsx)$/,
        exclude: [
          path.resolve(__dirname, 'functions'),
        ],
        use: [
          'thread-loader',
          {
            loader: 'babel-loader',
            options: {
              cacheDirectory: true,
              babelrc: false,
              presets: [
                ['@babel/preset-env', { useBuiltIns: 'usage', corejs: 3 }],
                '@babel/preset-react',
              ],
              plugins: [
                ['@babel/plugin-proposal-decorators', { legacy: true }],
                ['@babel/plugin-proposal-class-properties', { loose: false }],
                '@babel/plugin-proposal-object-rest-spread',
                '@babel/plugin-transform-async-to-generator',
                '@babel/plugin-transform-react-jsx-source',
                '@babel/plugin-syntax-dynamic-import',
                'react-hot-loader/babel',
              ],
              ignore: [
                'functions',
                'node_modules',
              ],
            },
          },
        ],
      },
      {
        test: /.s?css$/,
        use: [
          { loader: 'style-loader' },
          { loader: 'css-loader' },
          { loader: 'sass-loader' },
        ],
      },
      {
        test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        use: [
          { loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff' } },
        ],
      },
      {
        test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        use: [
          { loader: 'file-loader', options: { outputPath: './build/images/' } },
        ],
      },
      {
        test: /\.(gif|png|jpe?g|svg)$/i,
        use: [
          { loader: 'file-loader', options: { outputPath: './build/images/' } },
          { loader: 'image-webpack-loader' },
        ],
      },
    ],
  },
  plugins: [
    new webpack.EnvironmentPlugin({
      NODE_ENV: 'development',
      ...config,
      ...env,
    }),
    new HtmlWebpackPlugin({
      inject: true,
      path: path.resolve('./public'),
      filename: 'index.html',
      template: 'public/index.html.local',
    }),
    // If you require a missing module and then `npm install` it, you still have
    // to restart the development server for Webpack to discover it. This plugin
    // makes the discovery automatic so you don't have to restart.
    // See https://github.com/facebook/create-react-app/issues/186
    new WatchMissingNodeModulesPlugin(path.resolve('node_modules')),
    new hardSourceWebpackPlugin(),
    new WebpackManifestPlugin({
      fileName: path.resolve(__dirname, './functions/frontend-manifest.json'),
    }),
  ],
  resolve: {
    modules: [path.resolve(__dirname, 'client'), path.resolve(__dirname, 'node_modules')],
    extensions: ['.js', '.jsx', '.css', '.json'],
    alias: {
      // Use compiled pica files from /dist folder
      pica: 'pica/dist/pica.js',
      recharts: path.resolve('./node_modules/recharts-fork'),
      react: path.resolve('./node_modules/react'),
      'react-dom': '@hot-loader/react-dom',
    },
  },
};
ricardogobbosouza commented 5 years ago

@alexplumb your package.json too

alexplumb commented 5 years ago
{
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/plugin-proposal-class-properties": "^7.5.5",
    "@babel/plugin-proposal-decorators": "^7.6.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.6.2",
    "@babel/plugin-syntax-dynamic-import": "^7.2.0",
    "@babel/plugin-transform-async-to-generator": "^7.5.0",
    "@babel/plugin-transform-react-jsx-source": "^7.5.0",
    "@babel/polyfill": "^7.6.0",
    "@babel/preset-env": "^7.6.2",
    "@babel/preset-react": "^7.0.0",
    "@hot-loader/react-dom": "^16.9.0",
    "@sentry/webpack-plugin": "^1.8.1",
    "@types/algoliasearch": "^3.34.2",
    "@types/node": "^12.7.8",
    "@types/webpack": "^4.39.2",
    "@types/webpack-dev-server": "^3.1.7",
    "acorn": "^7.1.0",
    "acorn-dynamic-import": "4.0.0",
    "autodll-webpack-plugin": "^0.4.2",
    "babel-eslint": "^10.0.3",
    "babel-loader": "^8.0.6",
    "babel-plugin-import": "^1.12.2",
    "babel-plugin-lodash": "^3.3.4",
    "babel-plugin-recharts": "^1.2.0",
    "concurrently": "^4.1.2",
    "core-js": "^3.2.1",
    "cross-env": "^6.0.0",
    "css-loader": "^3.2.0",
    "date-time-format-timezone": "^1.0.21",
    "eslint": "^6.4.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-loader": "^3.0.2",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.14.3",
    "eslint-plugin-react-hooks": "^2.1.1",
    "eslint-plugin-react-redux": "^3.0.1",
    "file-loader": "^4.2.0",
    "firebase-admin": "^8.6.0",
    "firebase-tools": "^7.4.0",
    "glob": "^7.1.4",
    "hard-source-webpack-plugin": "^0.13.1",
    "html-webpack-plugin": "^4.0.0-beta.8",
    "image-webpack-loader": "^6.0.0",
    "lodash-webpack-plugin": "^0.11.5",
    "node-sass": "^4.12.0",
    "optimize-css-assets-webpack-plugin": "^5.0.3",
    "postcss-safe-parser": "^4.0.1",
    "react-dev-utils": "^9.0.4",
    "react-hot-loader": "^4.12.14",
    "redux-devtools": "^3.5.0",
    "redux-devtools-dock-monitor": "^1.1.3",
    "redux-devtools-log-monitor": "^1.4.0",
    "redux-logger": "^3.0.6",
    "regenerator-runtime": "^0.13.3",
    "sass-loader": "^8.0.0",
    "style-loader": "^1.0.0",
    "sw-precache-webpack-plugin": "^0.11.5",
    "terser-webpack-plugin": "^2.1.2",
    "thread-loader": "^2.1.3",
    "ts-node": "^8.4.1",
    "typescript": "^3.6.3",
    "url-loader": "^2.1.0",
    "webpack": "^4.41.0",
    "webpack-bundle-analyzer": "^3.5.2",
    "webpack-cli": "^3.3.9",
    "webpack-dev-server": "^3.8.1",
    "webpack-manifest-plugin": "^2.1.2"
  },
  "dependencies": {
    "@date-io/luxon": "^1.3.11",
    "@deck.gl/aggregation-layers": "^7.2.6",
    "@deck.gl/core": "^7.2.6",
    "@deck.gl/layers": "^7.2.6",
    "@deck.gl/react": "^7.2.6",
    "@fortawesome/fontawesome-free": "^5.11.2",
    "@material-ui/core": "^4.4.3",
    "@material-ui/icons": "^4.4.3",
    "@material-ui/lab": "^4.0.0-alpha.27",
    "@material-ui/pickers": "^3.2.6",
    "@material-ui/styles": "^4.4.3",
    "@sentry/browser": "^5.6.3",
    "@sentry/utils": "^5.6.1",
    "algoliasearch": "^3.35.0",
    "classnames": "^2.2.6",
    "connected-react-router": "^6.5.2",
    "dom-helpers": "^3.4.0",
    "exif-orientation": "^1.0.0",
    "fingerprintjs2": "^2.1.0",
    "firebase": "^6.6.2",
    "formik": "^1.5.8",
    "formik-material-ui": "0.0.22",
    "history": "^4.10.1",
    "instantsearch.css": "^7.3.1",
    "lodash": "^4.17.15",
    "luxon": "^1.19.3",
    "material-ui-banner": "^1.3.1",
    "material-ui-linkify": "^1.1.3",
    "pica": "^5.1.0",
    "places.js": "^1.16.5",
    "proxy-polyfill": "^0.3.0",
    "randomstring": "^1.1.5",
    "react": "^16.10.1",
    "react-autosuggest": "^9.4.3",
    "react-countdown-now": "^2.1.1",
    "react-dom": "^16.10.1",
    "react-dropzone": "^10.1.9",
    "react-image-crop": "^8.3.1",
    "react-instantsearch-dom": "^5.7.0",
    "react-lazy-images": "^1.1.0",
    "react-loadable": "^5.5.0",
    "react-map-gl": "^5.0.11",
    "react-meta-tags": "^0.7.4",
    "react-redux": "^7.1.1",
    "react-router": "^5.1.1",
    "react-router-dom": "^5.1.1",
    "react-signature-pad-wrapper": "^1.2.6",
    "react-stripe-elements": "^5.0.1",
    "react-swipeable-views": "^0.13.3",
    "react-transition-group": "^2.9.0",
    "recharts-fork": "^1.7.2",
    "recompose": "^0.30.0",
    "redux": "^4.0.4",
    "redux-saga": "^1.1.1",
    "reselect": "^4.0.0",
    "sanitize-filename": "^1.6.3",
    "shiitake": "^2.3.0",
    "use-aspect-ratio": "^1.0.3",
    "use-clipboard-copy": "^0.1.1",
    "yup": "^0.27.0"
  }
}
ricardogobbosouza commented 5 years ago

@alexplumb try re-install

  1. rm -rf node_modules yarn.lock package-lock.json
  2. npm install // or yarn
  3. run webpack