webpack-contrib / eslint-loader

[DEPRECATED] A ESlint loader for webpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module build failed: Error: No ESLint configuration found

mittalyashu opened this issue · comments

Getting this error: Module build failed: Error: No ESLint configuration found

Here's the code inside webpack.config.js.

{
				test: /\.js$/,
				exclude: /node_modules/,
				use: [
					"babel-loader",
					"eslint-loader"
				]
			}

same error. seems need configuration
./node_modules/.bin/eslint --init

I had this problem when building a Webpack-based Vue.js app in an environment where my .eslintrc wasn't present - linting the code upon doing so was pointless to me as it is always linted before merging. Long story short, I moved the eslint-loader part of my global Webpack config to the dev-only config (based on the default Vue CLI setup):

diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js
index c265eb6..9b09c19 100644
--- a/build/webpack.base.conf.js
+++ b/build/webpack.base.conf.js
@@ -29,15 +29,6 @@ module.exports = {
   },
   module: {
     rules: [
-      {
-        test: /\.(js|vue)$/,
-        loader: 'eslint-loader',
-        enforce: 'pre',
-        include: [resolve('src'), resolve('test')],
-        options: {
-          formatter: require('eslint-friendly-formatter')
-        }
-      },
       {
         test: /\.vue$/,
         loader: 'vue-loader',
diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js
index 5470402..c4d91de 100644
--- a/build/webpack.dev.conf.js
+++ b/build/webpack.dev.conf.js
@@ -13,7 +13,17 @@ Object.keys(baseWebpackConfig.entry).forEach(function (name) {

 module.exports = merge(baseWebpackConfig, {
   module: {
-    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
+    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }).concat([
+      {
+        test: /\.(js|vue)$/,
+        loader: 'eslint-loader',
+        enforce: 'pre',
+        include: [resolve('src'), resolve('test')],
+        options: {
+          formatter: require('eslint-friendly-formatter')
+        }
+      }
+    ])
   },
   // cheap-module-eval-source-map is faster for development
   devtool: '#cheap-module-eval-source-map',

Your mileage may vary if you're using a different setup, but you get the idea: you can't run Webpack with eslint-loader if you don't have a .eslintrc file, which sometimes you don't want.

Does anyone have any clue, how to use prettier in eslint-loader?

I use prettier on Mac: do control ^ + option + F

@Saf1997, do you use Prettier inside code editor or integrate with webpack.

It would be nice if eslint-loader won't lint at all if no config was found/given or at least make it configurable. At the moment not providing a config will break the webpack build process.

Try creating a file named .eslintrc.json in the root of examples directory and input something in the file

{
"rules": {
"semi": ["error", "always"],
"quotes": ["error", "double"]
}
}

In my case there were these hidden files .babelrc, editorconfig, .eslintignore, .eslintrc.js and .postcssrc.js(in case you have installed bootstrap). These files were not commited so when I took pull these files were missing. I resolved my problem by copying back these files.
Hope that helps.