{"id":13508997,"url":"https://github.com/webpack-contrib/eslint-loader","last_synced_at":"2025-09-29T02:31:57.320Z","repository":{"id":24186661,"uuid":"27577616","full_name":"webpack-contrib/eslint-loader","owner":"webpack-contrib","description":"[DEPRECATED] A ESlint loader for webpack","archived":true,"fork":false,"pushed_at":"2020-09-27T13:43:24.000Z","size":1004,"stargazers_count":1058,"open_issues_count":0,"forks_count":121,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-01-16T05:13:18.889Z","etag":null,"topics":["javascript","loader","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null},"funding":{"open_collective":"webpack"}},"created_at":"2014-12-05T06:15:25.000Z","updated_at":"2024-11-26T05:44:32.000Z","dependencies_parsed_at":"2022-08-07T11:00:56.722Z","dependency_job_id":null,"html_url":"https://github.com/webpack-contrib/eslint-loader","commit_stats":null,"previous_names":["moox/eslint-loader"],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Feslint-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Feslint-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Feslint-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Feslint-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack-contrib","download_url":"https://codeload.github.com/webpack-contrib/eslint-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234583683,"owners_count":18856280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","loader","webpack"],"created_at":"2024-08-01T02:01:01.544Z","updated_at":"2025-09-29T02:31:56.937Z","avatar_url":"https://github.com/webpack-contrib.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/eslint/eslint\"\u003e\u003cimg width=\"200\" height=\"200\" src=\"https://cdn.worldvectorlogo.com/logos/eslint.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\u003cimg width=\"200\" height=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![chat][chat]][chat-url]\n[![size][size]][size-url]\n\n# eslint-loader\n\n\u003e A ESlint loader for webpack\n\n## :warning: DEPRECATED\n\n`eslint-loader` has been deprecated. Please use [`eslint-webpack-plugin`](https://github.com/webpack-contrib/eslint-webpack-plugin).\n\n## Install\n\n```bash\nnpm install eslint-loader --save-dev\n```\n\n**Note**: You also need to install `eslint` from npm, if you haven't already:\n\n```bash\nnpm install eslint --save-dev\n```\n\n## Usage\n\nIn your webpack configuration:\n\n```js\nmodule.exports = {\n  // ...\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          // eslint options (if necessary)\n        },\n      },\n    ],\n  },\n  // ...\n};\n```\n\nWhen using with transpiling loaders (like `babel-loader`), make sure they are in correct order (bottom to top). Otherwise files will be checked after being processed by `babel-loader`:\n\n```js\nmodule.exports = {\n  // ...\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        use: ['babel-loader', 'eslint-loader'],\n      },\n    ],\n  },\n  // ...\n};\n```\n\nTo be safe, you can use `enforce: 'pre'` section to check source files, not modified by other loaders (like `babel-loader`):\n\n```js\nmodule.exports = {\n  // ...\n  module: {\n    rules: [\n      {\n        enforce: 'pre',\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n      },\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'babel-loader',\n      },\n    ],\n  },\n  // ...\n};\n```\n\n## Options\n\nYou can pass [eslint options](http://eslint.org/docs/developer-guide/nodejs-api#cliengine) using standard webpack [loader options](https://webpack.js.org/configuration/module/#useentry).\n\n**Note**: That the config option you provide will be passed to the `CLIEngine`. This is a different set of options than what you'd specify in `package.json` or `.eslintrc`. See the [eslint docs](http://eslint.org/docs/developer-guide/nodejs-api#cliengine) for more detail.\n\n### `cache`\n\n- Type: `Boolean|String`\n- Default: `false`\n\nThis option will enable caching of the linting results into a file. This is particularly useful in reducing linting time when doing a full build.\n\nThis can either be a `boolean` value or the cache directory path(ex: `'./.eslint-loader-cache'`).\n\nIf `cache: true` is used, the cache is written to the `./node_modules/.cache/eslint-loader` directory. This is the recommended usage.\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          cache: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n### `eslintPath`\n\n- Type: `String`\n- Default: `eslint`\n\nPath to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. Now you dont have to install `eslint`.\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          eslintPath: path.join(__dirname, 'reusable-eslint'),\n        },\n      },\n    ],\n  },\n};\n```\n\n### `fix`\n\n- Type: `Boolean`\n- Default: `false`\n\nThis option will enable [ESLint autofix feature](http://eslint.org/docs/user-guide/command-line-interface#fix).\n\n**Be careful: this option will change source files.**\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          fix: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n### `formatter`\n\n- Type: `String|Function`\n- Default: `stylish`\n\nThis option accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          // several examples !\n\n          // default value\n          formatter: 'stylish',\n\n          // community formatter\n          formatter: require('eslint-friendly-formatter'),\n\n          // custom formatter\n          formatter: function (results) {\n            // `results` format is available here\n            // http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles()\n\n            // you should return a string\n            // DO NOT USE console.*() directly !\n            return 'OUTPUT';\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n### Errors and Warning\n\n**By default the loader will auto adjust error reporting depending on eslint errors/warnings counts.** You can still force this behavior by using `emitError` **or** `emitWarning` options:\n\n#### `emitError`\n\n- Type: `Boolean`\n- Default: `false`\n\nWill always return errors, if this option is set to `true`.\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          emitError: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `emitWarning`\n\n- Type: `Boolean`\n- Default: `false`\n\nWill always return warnings, if option is set to `true`. **If you're using hot module replacement, you may wish to enable this in development, or else updates will be skipped when there's an eslint error.**\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          emitWarning: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `failOnError`\n\n- Type: `Boolean`\n- Default: `false`\n\nWill cause the module build to fail if there are any errors, if option is set to `true`.\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          failOnError: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `failOnWarning`\n\n- Type: `Boolean`\n- Default: `false`\n\nWill cause the module build to fail if there are any warnings, if option is set to `true`.\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          failOnWarning: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `quiet`\n\n- Type: `Boolean`\n- Default: `false`\n\nWill process and report errors only and ignore warnings, if this option is set to `true`.\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          quiet: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `outputReport`\n\n- Type: `Boolean|Object`\n- Default: `false`\n\nWrite the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI.\n\nThe `filePath` is an absolute path or relative to the webpack config: `output.path`. You can pass in a different `formatter` for the output file, if none is passed in the default/configured formatter will be used.\n\n```js\nmodule.exports = {\n  entry: '...',\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        loader: 'eslint-loader',\n        options: {\n          outputReport: {\n            filePath: 'checkstyle.xml',\n            formatter: 'checkstyle',\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n## Gotchas\n\n### NoEmitOnErrorsPlugin\n\n`NoEmitOnErrorsPlugin` is now automatically enabled in webpack 4, when mode is either unset, or set to production. So even ESLint warnings will fail the build. No matter what error settings are used for `eslint-loader`, except if `emitWarning` enabled.\n\n### Defining `configFile` or using `eslint -c path/.eslintrc`\n\nBear in mind that when you define `configFile`, `eslint` doesn't automatically look for `.eslintrc` files in the directory of the file to be linted. More information is available in official eslint documentation in section [_Using Configuration Files_](http://eslint.org/docs/user-guide/configuring#using-configuration-files). See [#129](https://github.com/webpack-contrib/eslint-loader/issues/129).\n\n## Changelog\n\n[Changelog](CHANGELOG.md)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/eslint-loader.svg\n[npm-url]: https://npmjs.com/package/eslint-loader\n[node]: https://img.shields.io/node/v/eslint-loader.svg\n[node-url]: https://nodejs.org\n[deps]: https://david-dm.org/webpack-contrib/eslint-loader.svg\n[deps-url]: https://david-dm.org/webpack-contrib/eslint-loader\n[tests]: https://github.com/webpack-contrib/eslint-loader/workflows/eslint-loader/badge.svg\n[tests-url]: https://github.com/webpack-contrib/eslint-loader/actions\n[cover]: https://codecov.io/gh/webpack-contrib/eslint-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/eslint-loader\n[chat]: https://badges.gitter.im/webpack/webpack.svg\n[chat-url]: https://gitter.im/webpack/webpack\n[size]: https://packagephobia.now.sh/badge?p=eslint-loader\n[size-url]: https://packagephobia.now.sh/result?p=eslint-loader\n","funding_links":["https://opencollective.com/webpack"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Feslint-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack-contrib%2Feslint-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Feslint-loader/lists"}