brunch / jshint-brunch

Adds JSHint linting support to Brunch.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to ignore vendor files ?

mpellerin42 opened this issue · comments

Hi,

I have a problem to use jshint-brunch on a project in which I have a vendor folder : jshint parse vendor folder and so compilation fails.
I use .jshintrc file to configure jshint.

If I set path watched like this (instead of let default path configuration) :

paths: {
    "watched": ['app']
},

jshint don't parse vendor folder but brunch neither, so my vendor files are not compiled.

Is there a way that I miss to configure jshint-brunch to ignore my vendor folder?

As you can see in the README, you can configure patterns in this way:

# brunch-config.coffee
exports.config =
  plugins:
    jshint:
      pattern: /^app\/.*\.js$/

This pattern should ignore everything which is not a js file inside app dir

I know and I already try it with this conf :

plugins: {
            jshint: {
                pattern: /^app\/.*\.js$/,
                options: {
                    "browser"   : true,
                    "node"      : true,
                    "bitwise"   : true,
                    "curly"     : true,
                    "eqeqeq"    : true,
                    "undef"     : true,
                    "unused"    : true,
                    "laxbreak"  : true,
                    "globals"   : {
                        "angular": true,
                        "OpenLayers": true,
                        "$": true,
                        "Rickshaw": true
                    }
                }
            }
        }

With this conf (and removing .jshint file from my project), vendor folder is not parse but my js files neither : jshint return none errors, even if I add one on purpose.

  • What brunch version are you on?
  • What node.js / npm / OS version are you on?

OS: windows 7
brunch v1.8.3
node v0.12.2
npm v2.7.4

Could you try this regexp?

/^app.*\.js$/

Thanks, with this pattern, jshint parse well my app folder and not vendor folder as expected.
So now, I use .jshintrc file for jshint configuration, and following plugin configuration :

jshint: {
    pattern: /^app.*\.js$/
}

and jshint work as expected.

Reading your documentation, I thought that using pattern option force me to also configure jshint options in brunch-config.js. But when I tried, with following configuration, it didn't work: globals were not take into account.
I had a lot of errors like these

 6 |       angular.forEach(input, function(value) {
           ^ 'angular' is not defined.
53 |             var graph = new Rickshaw.Graph( {
                                 ^ 'Rickshaw' is not defined.

with this configuration block in brunch-config.js:

            jshint: {
                pattern: /^app.*\.js$/,
                options: {
                    "browser"   : true,
                    "node"      : true,
                    "bitwise"   : true,
                    "curly"     : true,
                    "eqeqeq"    : true,
                    "undef"     : true,
                    "unused"    : true,
                    "globals"   : {
                        "angular": true,
                        "OpenLayers": true,
                        "$": true,
                        "Rickshaw": true
                    }
                }
            }

It doesn't seem like expected behaviour, does it ?

I read again documentation and I saw my mistake: when using plugin configuration in brunch-config file, globals should not be declared in options block but at the same level as pattern and options :)
I'll keep my working configuration with .jshintrc for that project, but I note that for future projects.

Thanks again for your support.