javascriptjslintjshintgrunt-contrib-jshint

Missing "use strict" even though it's already declared at top of file


Am getting this Missing "use strict" statement even though it's decalred at the top of the file, which confuses me. This error appears twice, for lines 10 and 12.

'user strict';
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
  host : 'http://localhost:9200'
});
client.search({
  index: 'twitter',
  type: 'tweets'
}).then(function (resp) {
  var hits = resp.hits.hits;
}, function (err) {
  console.trace(err.message);
});

The code above is largely copy and paste from http://www.fullscale.co/elasticjs/


Solution

  • It appears you've made a typo.

    It should be

    'use strict';
    

    If you want to read more about 'use strict', how to use it and what it actually does, you can view the following page:

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode