origin-1 / gulp-eslint-new

A gulp plugin to lint code with ESLint 8 and 9.
MIT License
25 stars 2 forks source link

Error: Cannot find module 'gulp-eslint-new' in version >=1.7.0 #10

Closed nitesh-voya closed 1 month ago

nitesh-voya commented 1 month ago

In our project we are are using below code snippet to perform linting on js. We have use gulp-load-plugins to load all plugins

import gulpLoadPlugins from 'gulp-load-plugins';
const $ = gulpLoadPlugins();

gulp.task('drupal:lint', function runDrupalLinting() {
  // Get JS LINT targets.
  let jsPaths = options.lint.scripts.files;
  jsPaths = jsPaths.concat(
    getDrupalExtensions().map(function(ext) {
      return ext + options.paths.scripts + options.glob.recursive + options.glob.scripts;
    })
  );
  let jsTasks = jsLint(jsPaths);
  return jsTasks;
});

function jsLint(jsPaths = options.lint.scripts.files) {
  return gulp.src(jsPaths)
    .pipe($.eslintNew({
      configFile: options.lint.scripts.config,
      useEslintrc: false
    }))
    .pipe($.eslintNew.format())
    .pipe($.eslintNew.failAfterError());
}

above code snippet is workfing fine till version 1.6.0 of gulp-eslint-new and $.eslintNew was printing below in console.

[Function: exports] {
  result: [Function: createResultStream],
  results: [Function: createResultsStream],
  failOnError: [Function (anonymous)],
  failAfterError: [Function (anonymous)],
  formatEach: [Function (anonymous)],
  format: [Function (anonymous)],
  fix: [Function (anonymous)]
}

But after version >=1.7.0, $.eslintNew throwing below error. Requiring external module @babel/register Error: Cannot find module 'gulp-eslint-new' from

fasttime commented 1 month ago

Thanks, this will be fixed in gulp-eslint-new 2.3.0. But really, the problem seems to be that gulp-load-plugins doesn't understand the exports field in gulp plugins. It would be better to fix the issue there or find another tool that does the job.

fasttime commented 1 month ago

Released fix in gulp-eslint-new 2.3.0.

nitesh-voya commented 1 month ago

thanks

nitesh-voya commented 1 month ago

I tested 2.3.0 version locally and its working fine. But I could not understand through why it breaks in 1.7.0 version I checked diff between these two release https://github.com/origin-1/gulp-eslint-new/compare/1.6.0...1.7.0 but could not get in.

fasttime commented 1 month ago

It's because index.js was moved to lib/gulp-eslint-new.js. The new path is specified in the exports field in package.json. Without that setting, the entry point would default to index.js.