JSHint does not recognize missing `use strict` in files without functions #1388

Closed
goloroden opened this Issue Nov 27, 2013 · 2 comments

Comments

Projects
None yet
3 participants

Sample file foo.js:

y = 35;

var x = {
  foo: 'bar'
};

module.exports = x;

Then, run jshint with detection of stict and globalStrict both enabled.

Expected behavior:

  • JSHint should complain about y defined, but not declared.
  • JSHint should complain about missing 'use strict'; statement.

Actual behavior:

  • JSHint complains about y defined, but not declared.
  • JSHint does NOT complain about missing 'use strict'; statement.

JSHint version 2.3.0.

valueof added a commit that referenced this issue Dec 25, 2013

Owner

valueof commented Dec 25, 2013

Fixed.

@valueof valueof closed this Dec 25, 2013

Contributor

julienw commented Jan 2, 2014

Mmm this regressed this with "globalstrict: true":

(function() {
  'use strict';

  var a = 'toto';
  a = a + 'plop';
})();

I think "globalstrict" is not supposed to force using it in global, but only to allow it.

julienw added a commit to julienw/jshint that referenced this issue Jan 2, 2014

julienw added a commit to julienw/jshint that referenced this issue Jan 2, 2014

valueof added a commit that referenced this issue Jan 3, 2014

Issue #1451: Fix a regression caused by #1388
Signed-off-by: Anton Kovalyov <anton@kovalyov.net>

valueof added a commit that referenced this issue Jan 3, 2014

jugglinmike added a commit to jugglinmike/jshint that referenced this issue Oct 21, 2014

jugglinmike added a commit to jugglinmike/jshint that referenced this issue Oct 21, 2014

Issue #1451: Fix a regression caused by #1388
Signed-off-by: Anton Kovalyov <anton@kovalyov.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment