adametry / gulp-eslint

A Gulp plugin for identifying and reporting on patterns found in ECMAScript/JavaScript code.
MIT License
563 stars 118 forks source link

Strict mode detection doesn't work #128

Closed JulienBonnin-ABTasty closed 8 years ago

JulienBonnin-ABTasty commented 8 years ago

Hello,

I am using gulp-eslint for the first time because I am using browserify with babel to use ES6 features in my JS code.

My issue is really simple, I have the following .eslintrc: { "parser": "babel-eslint", "rules": { "strict": [2, "global"] } }

And the following file to test it (./client.main.js): "use strict"; console.log("Hello World");

Here is my gulp task for eslint:

gulp.task('lint', function () {

gulp.src(['./client/main.js'])
    .pipe(eslint())
    .pipe(eslint.result(function (result) {
        console.log('ESLint result: ' + result.filePath);
        console.log('# Messages: ' + result.messages.length);
        console.log('# Warnings: ' + result.warningCount);
        console.log('# Errors: ' + result.errorCount);
    }))
    .pipe(eslint.format());
    // .pipe(eslint.failAfterError());

});

The "use strict" at the top of my file throw me an error :warning: client/main.js 3:1 error Use the global form of "use strict" strict

✖ 1 problem (1 error, 0 warnings)

I'm stuck with this issue and for now I have warning level (1) enable instead of error level. How can I fix this ? Thanks

cookch10 commented 8 years ago

UPDATE: I think this could be due to babel-eslint/issues/228. By changing the parser option from "babel-eslint" to "", it works as expected.

I'm seeing the same with gulp-eslint v1.1.1, node v4.2.4 on Windows 7x64 OS:

package.json

  "devDependencies": {
    "babel-eslint": "^5.0.0-beta6",
    "del": "^2.2.0",
    "fs-filesysteminfo": "^1.0.6",
    "gulp": "^3.9.0",
    "gulp-cached": "^1.1.0",
    "gulp-connect": "^2.3.1",
    "gulp-eslint": "^1.1.1",
    "gulp-if": "^2.0.0",
    "gulp-jscs": "^3.0.2",
    "gulp-uglify": "^1.5.1",
    "opn": "^3.0.3",
    "through2": "^2.0.0"
  }

js:

function test() {
    'use strict';

    return 'test';
}

error: 1:1 error Use the function form of "use strict" strict

.eslintrc configuration

{
    "parser": "babel-eslint", 
    "ecmaFeatures": {
        "arrowFunctions": true, 
        "binaryLiterals": true, 
        "blockBindings": true, 
        "classes": true, 
        "defaultParams": true, 
        "destructuring": true, 
        "forOf": false, 
        "generators": false, 
        "modules": false, 
        "objectLiteralComputedProperties": false, 
        "objectLiteralDuplicateProperties": false, 
        "objectLiteralShorthandMethods": false, 
        "objectLiteralShorthandProperties": false, 
        "octalLiterals": false, 
        "regexUFlag": false, 
        "regexYFlag": false, 
        "restParams": false, 
        "spread": false, 
        "superInFunctions": false, 
        "templateStrings": false, 
        "unicodeCodePointEscapes": false, 
        "globalReturn": false, 
        "jsx": false, 
        "experimentalObjectRestSpread": false 
    },
    "globals": {

    },
    "plugins": [

    ],
    "env": {
        "browser": true, 
        "node": true, 
        "commonjs": false, 
        "worker": false, 
        "amd": false, 
        "mocha": false, 
        "jasmine": false, 
        "jest": false, 
        "phantomjs": false, 
        "protractor": false, 
        "qunit": false, 
        "jquery": false, 
        "prototypejs": false, 
        "shelljs": false, 
        "meteor": false, 
        "mongo": false, 
        "applescript": false, 
        "nashorn": false, 
        "serviceworker": false, 
        "embertest": false, 
        "webextensions": false, 
        "es6": true 
    },
    "rules": {

        "comma-dangle": 0, 
        "no-cond-assign": 0, 
        "no-console": 0, 
        "no-constant-condition": 0, 
        "no-control-regex": 0, 
        "no-debugger": 0, 
        "no-dupe-args": 0, 
        "no-dupe-keys": 0, 
        "no-duplicate-case": 0, 
        "no-empty-character-class": 0, 
        "no-empty": 0, 
        "no-ex-assign": 0, 
        "no-extra-boolean-cast": 0, 
        "no-extra-parens": 0, 
        "no-extra-semi": 0, 
        "no-func-assign": 0, 
        "no-inner-declarations": 0, 
        "no-invalid-regexp": 0, 
        "no-irregular-whitespace": 0, 
        "no-negated-in-lhs": 0, 
        "no-obj-calls": 0, 
        "no-regex-spaces": 0, 
        "no-sparse-arrays": 0, 
        "no-unexpected-multiline": 0, 
        "no-unreachable": 0, 
        "use-isnan": 0, 
        "valid-jsdoc": 0, 
        "valid-typeof": 0, 

        "accessor-pairs": 0, 
        "block-scoped-var": 0, 
        "complexity": 0, 
        "consistent-return": 0, 
        "curly": 0, 
        "default-case": 0, 
        "dot-location": 0, 
        "dot-notation": 0, 
        "eqeqeq": 0, 
        "guard-for-in": 0, 
        "no-alert": 0, 
        "no-caller": 0, 
        "no-case-declarations": 0, 
        "no-div-regex": 0, 
        "no-else-return": 0, 
        "no-empty-label": 0, 
        "no-empty-pattern": 0, 
        "no-eq-null": 0, 
        "no-eval": 0, 
        "no-extend-native": 0, 
        "no-extra-bind": 0, 
        "no-fallthrough": 0, 
        "no-floating-decimal": 0, 
        "no-implicit-coercion": 0, 
        "no-implied-eval": 0, 
        "no-invalid-this": 0, 
        "no-iterator": 0, 
        "no-labels": 0, 
        "no-lone-blocks": 0, 
        "no-loop-func": 0, 
        "no-magic-numbers": 0, 
        "no-multi-spaces": 0, 
        "no-multi-str": 0, 
        "no-native-reassign": 0, 
        "no-new-func": 0, 
        "no-new-wrappers": 0, 
        "no-new": 0, 
        "no-octal-escape": 0, 
        "no-octal": 0, 
        "no-param-reassign": 0, 
        "no-process-env": 0, 
        "no-proto": 0, 
        "no-redeclare": 0, 
        "no-return-assign": 0, 
        "no-script-url": 0, 
        "no-self-compare": 0, 
        "no-sequences": 0, 
        "no-throw-literal": 0, 
        "no-unused-expressions": 0, 
        "no-useless-call": 0, 
        "no-useless-concat": 0, 
        "no-void": 0, 
        "no-warning-comments": 0, 
        "no-with": 0, 
        "radix": 0, 
        "vars-on-top": 0, 
        "wrap-iife": 0, 
        "yoda": 0, 

        "strict": [ 2, "function" ], 

        "init-declarations": 0, 
        "no-catch-shadow": 0, 
        "no-delete-var": 0, 
        "no-label-var": 0, 
        "no-shadow-restricted-names": 0, 
        "no-shadow": 0, 
        "no-undef-init": 0, 
        "no-undef": 0, 
        "no-undefined": 0, 
        "no-unused-vars": 0, 
        "no-use-before-define": 0, 

        "callback-return": 0, 
        "global-require": 0, 
        "handle-callback-err": 0, 
        "no-mixed-requires": 0, 
        "no-new-require": 0, 
        "no-path-concat": 0, 
        "no-process-exit": 0, 
        "no-restricted-modules": 0, 
        "no-sync": 0, 

        "array-bracket-spacing": 0, 
        "block-spacing": 0, 
        "brace-style": 0, 
        "camelcase": 0, 
        "comma-spacing": 0, 
        "comma-style": 0, 
        "computed-property-spacing": 0, 
        "consistent-this": 0, 
        "eol-last": 0, 
        "func-names": 0, 
        "func-style": 0, 
        "id-length": 0, 
        "id-match": 0, 
        "indent": 0, 
        "jsx-quotes": 0, 
        "key-spacing": 0, 
        "linebreak-style": 0, 
        "lines-around-comment": 0, 
        "max-depth": 0, 
        "max-len": 0, 
        "max-nested-callbacks": 0, 
        "max-params": 0, 
        "max-statements": 0, 
        "new-cap": 0, 
        "new-parens": 0, 
        "newline-after-var": 0, 
        "no-array-constructor": 0, 
        "no-bitwise": 0, 
        "no-continue": 0, 
        "no-inline-comments": 0, 
        "no-lonely-if": 0, 
        "no-mixed-spaces-and-tabs": 0, 
        "no-multiple-empty-lines": 0, 
        "no-negated-condition": 0, 
        "no-nested-ternary": 0, 
        "no-new-object": 0, 
        "no-plusplus": 0, 
        "no-restricted-syntax": 0, 
        "no-spaced-func": 0, 
        "no-ternary": 0, 
        "no-trailing-spaces": 0, 
        "no-underscore-dangle": 0, 
        "no-unneeded-ternary": 0, 
        "object-curly-spacing": 0, 
        "one-var": 0, 
        "operator-assignment": 0, 
        "operator-linebreak": 0, 
        "padded-blocks": 0, 
        "quote-props": 0, 
        "quotes": 0, 
        "require-jsdoc": 0, 
        "semi-spacing": 0, 
        "semi": 0, 
        "sort-vars": 0, 
        "space-after-keywords": 0, 
        "space-before-blocks": 0, 
        "space-before-function-paren": 0, 
        "space-before-keywords": 0, 
        "space-in-parens": 0, 
        "space-infix-ops": 0, 
        "space-return-throw-case": 0, 
        "space-unary-ops": 0, 
        "spaced-comment": 0, 
        "wrap-regex": 0, 

        "arrow-body-style": 0, 
        "arrow-parens": 0, 
        "arrow-spacing": 0, 
        "constructor-super": 0, 
        "generator-star-spacing": 0, 
        "no-arrow-condition": 0, 
        "no-class-assign": 0, 
        "no-const-assign": 0, 
        "no-dupe-class-members": 0, 
        "no-this-before-super": 0, 
        "no-var": 0, 
        "object-shorthand": 0, 
        "prefer-arrow-callback": 0, 
        "prefer-const": 0, 
        "prefer-reflect": 0, 
        "prefer-spread": 0, 
        "prefer-template": 0, 
        "require-yield": 0 

    }
}
shinnn commented 8 years ago

It's not an issue with this plugin.