Giter Club home page Giter Club logo

eslint-parallel's Introduction

eslint-parallel

Tiny eslint wrapper to allow executing javascript linting in parallel.

Install

npm install eslint-parallel

Access CLI

node_modules/.bin/eslint-parallel src/js/**

Options

See ESLint Docs for all the options

API Usage

  import Linter from 'eslint-parallel';
  new Linter({
    cache: true,
    cwd: process.cwd()
  }).execute(['src/js/**']).then(
    (result) => {
      const failed = result.errorCount || result.warningCount;

      if (failed) {
        // failed
      } else {
        // passed
      }
    },
    (err) => {
      console.log(err);
      process.exit(1);
    }
  );

eslint-parallel's People

Contributors

alansouzati avatar j-f1 avatar mamal72 avatar pgadmin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eslint-parallel's Issues

cannot read config file

eslint ff/static/modules --ext .tsx works but eslint-parallel ff/static/modules --ext .tsx does not.

node version: 12.18.1
OS version: ubuntu 18.04.4 LTS

eslintrc:

// code code code
// bla bla bla
// more irrelevant code
module.exports = {
 // stuff
};

Log:

(fifteen5) > time yarn modules:lint                                                            ~/Documents/fifteen5(dev✗)@caleb-H110M-A
yarn run v1.22.4
$ eslint-parallel ff/static/modules --ext .tsx
Error: Cannot read config file: /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
Error: Cannot find module './.eslintrc'
Require stack:
- /home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js
- /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js:7:23)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js',
    '/home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js'
  ]
}
Rule | Time (ms) | Relative
:----|----------:|--------:
Error: Cannot read config file: /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
Error: Cannot find module './.eslintrc'
Require stack:
- /home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js
- /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js:7:23)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js',
    '/home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js'
  ]
}
Rule | Time (ms) | Relative
:----|----------:|--------:
(node:32527) UnhandledPromiseRejectionWarning: Linting failed
(node:32527) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32527) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:32527) UnhandledPromiseRejectionWarning: Linting failed
(node:32527) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:32527) UnhandledPromiseRejectionWarning: Linting failed
(node:32527) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
Error: Cannot read config file: /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
Error: Cannot find module './.eslintrc'
Require stack:
- /home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js
- /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js:7:23)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js',
    '/home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js'
  ]
}
Error: Cannot read config file: /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
Error: Cannot find module './.eslintrc'
Require stack:
- /home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js
- /home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js
- /home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js:7:23)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/caleb/Documents/fifteen5/ff/static/js/.eslintrc-next.js',
    '/home/caleb/Documents/fifteen5/ff/static/modules/.eslintrc.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config/config-file.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/config.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/cli-engine.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/node_modules/eslint/lib/api.js',
    '/home/caleb/Documents/fifteen5/node_modules/eslint-parallel/lib/linter.js'
  ]
}
Rule | Time (ms) | Relative
:----|----------:|--------:
Rule | Time (ms) | Relative
:----|----------:|--------:
(node:32527) UnhandledPromiseRejectionWarning: Linting failed
(node:32527) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:32527) UnhandledPromiseRejectionWarning: Linting failed
(node:32527) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
Rule | Time (ms) | Relative
:----|----------:|--------:
Done in 1.34s.

v1.2.1: CLI throws with ERR_REQUIRE_ESM from strip-ansi

Node: v14.16.1
eslint-parallel: 1.2.1

Caused by #25

Running eslint-parallel src/app/ --ext js
throws the following error:

internal/modules/cjs/loader.js:1080
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: node_modules/eslint-parallel/node_modules/strip-ansi/index.js
require() of ES modules is not supported.
require() of node_modules/eslint-parallel/node_modules/strip-ansi/index.js from node_modules/eslint-parallel/lib/formatter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from [...]/node_modules/eslint-parallel/node_modules/strip-ansi/package.json.

Looks like the babel transformed eslint-parallel lib/formatter.js uses require and the strip-ansi module setting forbids it.

Passing directories results in all non-js files being globbed

For example, running eslint-parallel ./src will attempt to lint all files under src, whether they be JavaScript or not.

Replacing ./src with ./src/**/*.js will attempt to lint files specified in .eslintignore, causing warnings.

Eslint itself has a utility for constructing the necessary globs, see https://github.com/eslint/eslint/blob/4def8764273e7cc53c71f0dd67da271636e4c1be/lib/util/glob-util.js#L47-L53. It doesn't look like it's exported from the package, but it's a small piece of code to reproduce.

slower than eslint

I've tried to run this

eslint ran in 3 minutes
and eslint-parallel ran in 4 minutes

is there any benchmark about it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.