FGRibreau / check-build

:dart: Check-build - Verifies that your NodeJS project follows team conventions, is well written, up to date and secure.
http://blog.fgribreau.com/2014/10/check-build-verify-that-your-nodejs.html
MIT License
687 stars 30 forks source link

Failing to load eslint #57

Open rplopes opened 9 years ago

rplopes commented 9 years ago

We've been using check-build to run jscs and jshint. We now wanted to add eslint, but check-build fails to load it (running eslint separately works fine).

Simplified package.json:

{
  ...
  "devDependencies": {
    "check-build": "2.6.0",
    "eslint": "1.10.2",
    "jscs": "1.13.1",
    "jshint": "2.8.0",
    ...
  },
  ...
}

Our .checkbuild after adding eslint:

{
  "checkbuild": {
    "enable": ["eslint", "jscs", "jshint"],
    "allowFailures": false,
    "continueOnError": true
  },
  "eslint": {
    "args": ["."]
  },
  "jscs": {
    "args": ["."]
  },
  "jshint": {
    "args": ["."]
  },
}

Running eslint independently works:

$ eslint .
$ echo $?
0

However, check-build fails on eslint:

$ check-build
[eslint]

/bin/sh: <project_dir>/node_modules/check-build/node_modules/.bin/eslint: No such file or directory

Checkbuild module "eslint" failed.

true

[jscs]
No code style errors found.

[jshint]

✔ No problems

1 module(s) failed, exiting.

I don't fully understand if this is an issue with check-build looking for eslint in the wrong directory (if it was meant to use /node_modules/.bin/eslint instead, which exists) or looking at the right directory but for some reason not being shipped with the necessary bin.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28717323-failing-to-load-eslint?utm_campaign=plugin&utm_content=tracker%2F7304231&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F7304231&utm_medium=issues&utm_source=github).
FGRibreau commented 9 years ago

Hello @rplopes, it's linked with the upgrade to npm3, since npm3 flatten node directories I did not came up with a fix right know but I'm looking forward to it

rplopes commented 9 years ago

Hi @FGRibreau. Thank you for the reply. However, I'm still using npm 2:

$ npm -v
2.14.7

Is this behaviour to be expected with this version of npm?

FGRibreau commented 9 years ago

Is /node_modules/.bin/eslint available ? Did you try to completly remove node_modules and then start an npm install again?

rplopes commented 9 years ago

Yes, and running it from the node_modules directory results in the same behaviour as running it as described above:

$ node_modules/.bin/eslint .
$ echo $?
0

Removing the node_modules directory and running npm install again results in the same error: check-build will still try to load eslint from node_modules/check-build/node_modules/.bin/eslint and fail with No such file or directory.

FGRibreau commented 8 years ago

We just need to update check-build eslint.js with require.resolve('eslint') to make it work