From c9e9f12885afe7fd8f67d64951efa526dce37abd Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Thu, 15 Jun 2017 08:46:23 +0200 Subject: [PATCH] Revert "Added: eslintPath option (#181)" This reverts commit ff4737c82d94b2fdfa91765a4cf75e1babc8eb6b. --- README.md | 22 ---------------------- index.js | 19 ++++++------------- test/eslint-path.js | 33 --------------------------------- test/mock/eslint-mock.js | 21 --------------------- 4 files changed, 6 insertions(+), 89 deletions(-) delete mode 100644 test/eslint-path.js delete mode 100644 test/mock/eslint-mock.js diff --git a/README.md b/README.md index 0e5fdd3..6b7e3bf 100644 --- a/README.md +++ b/README.md @@ -142,28 +142,6 @@ module.exports = { } ``` -#### `eslintPath` (default: "eslint") - -Path to `eslint` instance that will be used for linting. - -```js -module.exports = { - entry: "...", - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - loader: "eslint-loader", - options: { - eslintPath: path.join(__dirname, "reusable-eslint-rules.js"), - } - }, - ], - }, - } -``` - #### Errors and Warning **By default the loader will auto adjust error reporting depending diff --git a/index.js b/index.js index 5d251f4..184f0a8 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ "use strict" +var eslint = require("eslint") var assign = require("object-assign") var loaderUtils = require("loader-utils") var objectHash = require("object-hash") @@ -67,7 +68,6 @@ function printLinterOutput(res, config, webpack) { // if enabled, use eslint auto-fixing where possible if (config.fix && res.results[0].output) { - var eslint = require(config.eslintPath) eslint.CLIEngine.outputFixes(res) } @@ -142,25 +142,19 @@ function printLinterOutput(res, config, webpack) { */ module.exports = function(input, map) { var webpack = this - - var userOptions = assign( - // user defaults - this.options.eslint || {}, - // loader query string - loaderUtils.getOptions(this) - ) - var config = assign( // loader defaults { formatter: require("eslint/lib/formatters/stylish"), cacheIdentifier: JSON.stringify({ "eslint-loader": pkg.version, - eslint: require(userOptions.eslintPath || "eslint").version, + eslint: eslint.version, }), - eslintPath: "eslint", }, - userOptions + // user defaults + this.options.eslint || {}, + // loader query string + loaderUtils.getOptions(this) ) var cacheDirectory = config.cache @@ -172,7 +166,6 @@ module.exports = function(input, map) { // Create the engine only once per config var configHash = objectHash(config) if (!engines[configHash]) { - var eslint = require(config.eslintPath) engines[configHash] = new eslint.CLIEngine(config) } diff --git a/test/eslint-path.js b/test/eslint-path.js deleted file mode 100644 index 7e738e7..0000000 --- a/test/eslint-path.js +++ /dev/null @@ -1,33 +0,0 @@ -var path = require("path") -var test = require("ava") -var webpack = require("webpack") -var conf = require("./utils/conf") - -test.cb("eslint-loader can use another instance of eslint via " + - "eslintPath config", function(t) { - t.plan(2) - webpack(conf( - { - entry: "./test/fixtures/good.js", - }, - { - eslintPath: path.join(__dirname, "mock/eslint-mock.js"), - } - ), - function(err, stats) { - if (err) { - throw err - } - - // console.log(stats.compilation.errors) - t.true( - stats.hasErrors(), - "a file that does not contains error but mock eslint instance " + - "returned error" - ) - t.true( - stats.compilation.errors[0].message.indexOf("Fake error") > -1 - ) - t.end() - }) -}) diff --git a/test/mock/eslint-mock.js b/test/mock/eslint-mock.js deleted file mode 100644 index 0bddc15..0000000 --- a/test/mock/eslint-mock.js +++ /dev/null @@ -1,21 +0,0 @@ -function CLIEngine() { - -} - -CLIEngine.prototype.executeOnText = function() { - return { - warningCount: 0, - errorCount: 1, - results: [{ - messages: [ - { - message: "Fake error", - }, - ], - }], - } -} - -module.exports = { - CLIEngine: CLIEngine, -}