jscs-dev/grunt-jscs

grunt failing on jscs with node v5.2.0, npm 3.3.12

O-Mutt opened this issue · 8 comments

I was thinking this was just something that i did in my project but now looking at how my question has gone unanswered and continues to get upvotes i'm starting to wonder if the framework may be at fault.

Console Output
$ node -v
v5.2.0

$ npm -v
3.3.12

$ grunt --version
grunt-cli v0.1.13
grunt v0.4.5

$ grunt jscs
Loading "jscs.js" tasks...ERROR
>> TypeError: fn.call is not a function
Warning: Task "jscs" not found. Use --force to continue.

Aborted due to warnings.
package.json
{
"name": "Javascript",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "grunt": "~0.4.5",
    "matchdep": "^0.3.0",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-express": "~1.4.1",
    "grunt-open": "~0.2.3",
    "grunt-chmod": "~1.0.3",
    "grunt-contrib-jshint": "~0.11.3",
    "grunt-contrib-uglify": "~0.10.0",
    "karma": "~0.13.15",
    "grunt-karma": "~0.12.1",
    "jasmine-core": "~2.3.4",
    "karma-jasmine": "~0.3.6",
    "phantomjs": "~1.9.18",
    "karma-phantomjs-launcher": "~0.2.1",
    "angular-mocks": "~1.2.28",
    "jquery": "~2.1.4",
    "underscore": "~1.8.3",
    "grunt-contrib-clean": "~0.6.0",
    "karma-coverage": "~0.5.3",
    "grunt-jscs": "~2.3.0",
    "grunt-contrib-concat": "~0.5.1"
  }
}
gruntfile.js
module.exports = function (grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

grunt.initConfig({
    .....
    jscs: {
        src: [
            'gruntfile.js',
            '<%= sourceFolder %>/**/*.js',
            '!<%= sourceFolder %>/angular/**',
            '!<%= sourceFolder %>/es5-shim/**',
            '!<%= sourceFolder %>/**/*[.-]min.js',
            '!<%= sourceFolder %>/respond/*.js',
            '!<%= sourceFolder %>/angular-ui-bootstrap/*.js',
            '!<%= sourceFolder %>/analytics/angulartics*.js'
        ],
        options: {
            config: '.jscsrc',
            fix: true
        }
    }
});

Stackoverflow Question

Is your project at GitHub?

A possible reason for this is that npm 2 and 3 do installs that are flatter than npm 1,
what may have caused unwanted dependencies to be loaded due to this code:

require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

No unfortunately, my project is not available on github :/.

I switched the loading to:

require('load-grunt-tasks')(grunt);

and the output was:

USER /c/Projects/TFS/Development/Assets/1601/Iris.Javascript
$ npm install grunt-jscs --save-dev
grunt-jscs@2.5.0 node_modules\grunt-jscs
├── vow@0.4.12
├── lodash@3.10.1
└── jscs@2.7.0 (to-double-quotes@2.0.0, to-single-quotes@2.0.0, minimatch@3.0.0, reserved-words@0.1.
1, natural-compare@1.2.2, estraverse@4.1.1, glob@5.0.15, pathval@0.1.1, jscs-preset-wikimedia@1.0.0,
 esprima@2.7.1, xmlbuilder@3.1.0, commander@2.9.0, chalk@1.1.1, vow-fs@0.3.4, cli-table@0.3.1, babel
-jscs@2.0.5, jscs-jsdoc@1.3.1, js-yaml@3.4.6, prompt@0.2.14, jsonlint@1.6.2, babel-core@5.8.34, esco
pe@3.3.0)

USER /c/Projects/TFS/Development/Assets/1601/Javascript
$ npm -v
2.14.7

USER /c/Projects/TFS/Development/Assets/1601/Javascript
$ node -v
v4.2.3

USER /c/Projects/TFS/Development/Assets/1601/Javascript
$ grunt
Loading "jscs.js" tasks...ERROR
>> TypeError: fn.call is not a function

Running "default" task

Running "express:all" (express) task

Running "express-server:all" (express-server) task
Web server started on port:9001, hostname: 0.0.0.0 [pid: 7880]

Running "open:all" (open) task

Running "build_packages:true first:true" (build_packages) task
Warning: Task "jscs" not found. Use --force to continue.

Aborted due to warnings.
$ grunt --help
Loading "jscs.js" tasks...ERROR
>> TypeError: fn.call is not a function
Grunt: The JavaScript Task Runner (v0.4.5)

Usage
 grunt [options] [task [task ...]]

Options
...
Available tasks
             chmod
        concurrent
             clean
            concat
              copy
            jshint
            uglify
             watch
          parallel
           express
     express-start
   express-restart
    express-server
 express-keepalive
             karma
              open
    build_packages
           release
           default
             debug

my node_modules folder does include grunt-jscs and in it's node_modules it includes jscs

I have this same problem in a smaller grunt project elsewhere and have had to remove jscs there as well in order to continue development

I just reproduced this error installing the same packages as you, and I got the following:

Reading /data/node_modules/grunt-jscs/package.json...OK
Parsing /data/node_modules/grunt-jscs/package.json...OK
Loading "jscs.js" tasks...ERROR
>> TypeError: fn.call is not a function
>>     at /data/node_modules/sugar/release/sugar-full.development.js:6126:12
>>     at Array.forEach (native)
>>     at extend.keys (/data/node_modules/sugar/release/sugar-full.development.js:6125:12)
>>     at /data/node_modules/sugar/release/sugar-full.development.js:179:25
>>     at Array.map (native)
>>     at Array.<anonymous> (/data/node_modules/sugar/release/sugar-full.development.js:180:23)
>>     at /data/node_modules/babel-core/lib/traversal/scope/index.js:1144:132
>>     at Object.<anonymous> (/data/node_modules/babel-core/lib/traversal/scope/index.js:1158:3)
>>     at Module._compile (module.js:399:26)
>>     at Object.Module._extensions..js (module.js:406:10)
>>     at Module.load (module.js:345:32)
>>     at Function.Module._load (module.js:302:12)
>>     at Module.require (module.js:355:17)
>>     at require (internal/module.js:13:17)
>>     at Object.<anonymous> (/data/node_modules/babel-core/lib/traversal/path/index.js:28:14)
>>     at Module._compile (module.js:399:26)

I'm still looking into it.

+1 on this

It seems to me that this was an issue with some JSCS dependency in common with your other dependencies.

I just tried again this problem, and everything went fine. Check the shrinkwrap I generated from this setup:
https://gist.github.com/gustavohenke/7fa6dcfa0e7424e7f1a7

ping @Mutmatt

Damn. I FINALLY found it. grunt-express. I started going one by one, commenting everything out. Needless to say, when i found the grunt-express project on github the last release was 2 years ago.... :/ Sorry for the run around

You're welcome, @Mutmatt!