jscs-dev / gulp-jscs

Check JavaScript code style with jscs
MIT License
312 stars 51 forks source link

Unclear error when .jscsrc is missing #103

Open VWoeltjen opened 8 years ago

VWoeltjen commented 8 years ago

As a new jscs and current gulp user, I tried to get started by using gulp-jscs in my build. Ran into an error pretty quickly. Was able to reproduce in a simplified case and ultimately resolve.

My gulpfile.js:

var gulp = require('gulp'),
    jscs = require('gulp-jscs');

gulp.task('check', function () {
    return gulp.src('src')
        .pipe(jscs())
        .pipe(jscs.reporter());
});

With which I encounter the following error:

$ gulp check
[14:07:25] Using gulpfile /some/path/gulpfile.js
[14:07:25] Starting 'check'...
[14:07:25] 'check' errored after 147 ms
[14:07:25] TypeError: Object.keys called on non-object
    at Function.keys (native)
    at copyConfiguration (/some/path/node_modules/gulp-jscs/node_modules/jscs/lib/config/configuration.js:1187:12)
    at NodeConfiguration.Configuration._processConfig (/some/path/node_modules/gulp-jscs/node_modules/jscs/lib/config/configuration.js:474:5)
    at NodeConfiguration.Configuration.load (/some/path/node_modules/gulp-jscs/node_modules/jscs/lib/config/configuration.js:238:10)
    at StringChecker.configure (/some/path/node_modules/gulp-jscs/node_modules/jscs/lib/string-checker.js:67:29)
    at Checker.configure (/some/path/node_modules/gulp-jscs/node_modules/jscs/lib/checker.js:28:39)
    at module.exports (/some/path/node_modules/gulp-jscs/index.js:35:10)
    at Gulp.<anonymous> (/some/path/gulpfile.js:6:15)
    at module.exports (/some/path/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/some/path/node_modules/gulp/node_modules/orchestrator/index.js:273:3)

To self-debug, I tried running the same under plain jscs:

$ jscs src
No configuration found. Add a .jscsrc file to your project root or use the -c option.

Creating a .jscsrc file resolved both problems. Expect it would be useful for other new users to see a similar error message from gulp-jscs in this case

0bserver07 commented 8 years ago

Or it is due to the version, make sure you have matching gulp dependencies:

  "devDependencies": {
    "gulp": "^3.9.0",
    "gulp-inject": "^1.5.0",
    "gulp-jscs": "^2.0.0",
    "gulp-jshint": "^1.11.2",
    "gulp-nodemon": "^2.0.4",
    "jshint-stylish": "^2.0.1"
  }
EvanCarroll commented 8 years ago

Also ran into this error. Seems as if other projects are also having this problem. Perhaps this should be fixed in jscs?

https://github.com/PolymerElements/polymer-starter-kit/pull/555 https://github.com/PolymerElements/polymer-starter-kit/pull/580

skolsuper commented 8 years ago

:+1:

ghost commented 8 years ago

I ran into the same error, agree with Evan. Where are you supposed to place this '.jscsrc' file and what are you supposed to put in it?

EvanCarroll commented 8 years ago

My solution was simple.. Stop using jscs. It seems as if eslint has totally replaced it anyway. I didn't research well enough before I adopted jscs to begin with. gulp-jscs last had a patch 4 months ago. That effectively makes it dead.