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

Support passing the path to the ESLint module #153

Closed
@insin

Description

@insin

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)
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions