Search code examples
sublimetext3eslintjshintiifesublimelinter

sublime text3 jshint error "Incompatible values for 'undefined' and 'undefined' linting options." when using IIFE expression


OS: macOS Sierra 10.12.5 .

Sublime Text: Build 3126 .

jshint v2.9.5 .

eslint v4.4.0 .

I have installed below packages for linting the js file

  1. sublimeLinter-contrib-eslint

  2. sublimeLinter-jshint

In my each .js file, IIFE (function(){ has been written on the top of the file BUT linter gives below error in gutter

Incompatible values for "undefined" and "undefined" linting options.

I have both .jshintrc and .eslintrc file in my project root directory BUT I am a bit confused 1. Which linter throw this error? and 2. How to resolve/fix it?

-.jshintrc_

{
    "node": true,
    "esversion": 6,
    "globals" : {
        "moment": true,
        "saveAs": true
    }
}

.eslintrc

{
    "env": {
        "browser": true,
        "node": true,
        "es6": true
    },
    "extends": "eslint:recommended",
    "globals": {
      "angular": true,
      "module": true,
      "inject": true,
      "moment": true,
      "saveAs": true,
      "AWS": true,
      "require": false
    },
    "rules": {
        "indent": [0,"tab"],
        "linebreak-style": [0, "unix"],
        "semi": [2, "always"]
    }
}

JS file

(function() {
  'use strict';
  angular.module().controller(function () { //....code.... });
})();

I have tried the rules as per eslint documentation

"rules": {
        "wrap-iife": [2, "outside"]
 }

tried all possible values but did not succeed.


Solution

  • Found solution by using Debug mode for sublimeLinter.

    there are mixing of 2 .jshintrc files. one is the default ( which can be viewed by (context menu > JSHint > Set Linting Preferences ) and other is custom .jshintrc which located in my project root directory and also there are 2 property esnext and esversion written which I think is not valid. from this refrence

    so first clear all comments from default .jshintrc (/Users//Library/Application Support/Sublime Text 3/Packages/JSHint Gutter/.jshintrc) and remove esversion property from custom .jshintrc file and everything is working fine now.