brunch / jshint-brunch

Adds JSHint linting support to Brunch.
7 stars 4 forks source link

how to ignore vendor files ? #20

Closed mpellerin42 closed 9 years ago

mpellerin42 commented 9 years ago

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?

paulmillr commented 9 years ago

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

mpellerin42 commented 9 years ago

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.

paulmillr commented 9 years ago
mpellerin42 commented 9 years ago

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

paulmillr commented 9 years ago

Could you try this regexp?

/^app.*\.js$/
mpellerin42 commented 9 years ago

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 ?

mpellerin42 commented 9 years ago

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.