Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Support passing the path to the ESLint module #153

Closed
insin opened this issue Feb 15, 2017 · 3 comments
Closed

Support passing the path to the ESLint module #153

insin opened this issue Feb 15, 2017 · 3 comments

Comments

@insin
Copy link

insin commented Feb 15, 2017

Allowing the path to the ESLint module to be passed would support use of this loader with reusable modules which also manage ESLint dependencies for you, e.g.:

var path = require('path')
var resolve = require('resolve')
var webpackConfig = {
  module: {
    rules: [
      {
        test: /\.js$/,
        enforce: 'pre',
        loader: 'eslint-loader',
        options: {
          configFile: require.resolve('reusable-eslint-module/.eslintrc'),
          eslintPath: resolve.sync('eslint', {basedir: path.join(__dirname, 'reusable-eslint-module')})
        },
        exclude: /node_modules/
      }
    ]
  }
}

Implementation-wise, ESLint could be imported only when needed (and similarly in the lint() function):

   // Create the engine only once per config
   var configHash = objectHash(config)
   if (!engines[configHash]) {
+    var eslint = require(config.eslintPath || 'eslint')
     engines[configHash] = new eslint.CLIEngine(config)
   }
@MoOx
Copy link
Contributor

MoOx commented Feb 22, 2017

Why not :)

@trungdq88
Copy link
Contributor

I have submitted a PR here #181

@MoOx do you mind have a look?

@MoOx
Copy link
Contributor

MoOx commented Oct 30, 2017

Closed by #181

@MoOx MoOx closed this as completed Oct 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants