gruntjs / grunt-contrib-jshint

Validate files with JSHint.
http://gruntjs.com/
MIT License
709 stars 193 forks source link

Specific options does not overwrite the global options from .jshintrc #198

Open exos opened 9 years ago

exos commented 9 years ago

According the documentation the specific options replaces the global ones, but, It's does not work, I have:

Gruntfile.js (Not complete)

jshint: {
        options: {
            jshintrc: true
        },
        grunt: {
            options: {
                "maxlen": false,
                "strict": false
            },
            files: {
                src: 'Gruntfile.js'
            }
        },
        lib: {
            options: {
            },
            files: {
                src: [
                    'index.js',
                    'lib/*.js',
                    'lib/**/*.js'
                ]
            }
        }

    }
  });

.jshintrc (only the replaced options)

    "strict"        : true, 
    "maxlen"     : 80,

And when I run "grunt" command (with the jshint by default), I get this:

Running "jshint:grunt" (jshint) task

   Gruntfile.js
      5 |  grunt.initConfig({
           ^ Missing "use strict" statement.
     11 |        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;' + '\n' +
                                                                                                  ^ Line is too long.
     12 |        ' * License: <%= _.pluck(pkg.licenses, "type").join(", ") %> (<%= _.pluck(pkg.licenses, "url").join(", ") %>)' + '\n' +
                                                                                                                                       ^ Line is too long.

>> 3 errors in 1 file
Warning: Task "jshint:grunt" failed. Use --force to continue.

Aborted due to warnings.

I have installed the version 0.11.1, with node 0.12.0 and npm 2.6.0, running in Archlinux.

├─┬ grunt-contrib-jshint@0.11.1
│ ├── hooker@0.2.3
│ └─┬ jshint@2.6.3
│   ├─┬ cli@0.6.5
│   │ └─┬ glob@3.2.11
│   │   ├── inherits@2.0.1
│   │   └─┬ minimatch@0.3.0
│   │     ├── lru-cache@2.5.0
│   │     └── sigmund@1.0.0
│   ├─┬ console-browserify@1.1.0
│   │ └── date-now@0.1.4
│   ├── exit@0.1.2
│   ├─┬ htmlparser2@3.8.2
│   │ ├── domelementtype@1.3.0
│   │ ├── domhandler@2.3.0
│   │ ├─┬ domutils@1.5.1
│   │ │ └─┬ dom-serializer@0.1.0
│   │ │   ├── domelementtype@1.1.3
│   │ │   └── entities@1.1.1
│   │ ├── entities@1.0.0
│   │ └─┬ readable-stream@1.1.13
│   │   ├── core-util-is@1.0.1
│   │   ├── inherits@2.0.1
│   │   ├── isarray@0.0.1
│   │   └── string_decoder@0.10.31
│   ├─┬ minimatch@1.0.0
│   │ ├── lru-cache@2.5.0
│   │ └── sigmund@1.0.0
│   ├── shelljs@0.3.0
│   ├── strip-json-comments@1.0.2
│   └── underscore@1.6.0
MrDefinite commented 9 years ago

Same problem.

fischermatte commented 9 years ago

+1

domtronn commented 9 years ago

+1 I saw in the changelog that this was done in v0.3.0 on 2013-03-13 and reverted immediately in v0.4.0 on 2013-04-04.

Is there a reason this was removed? I'd find it very useful.

_EDIT_\ For anyone experiencing this, you can place a second .jshintrc within the directory of secondary grunt target and it will match the first .jshintrc found above the file it's linting.

Hope this helps!

jshemas commented 9 years ago

+1

benkeen commented 6 years ago

+1