Skip to content

Commit

Permalink
JSHintBear: Deprecate - "globalstrict" -> "strict"
Browse files Browse the repository at this point in the history
The `strict` parameter has been created rather than the `globalstrict`
which was used earlier. Deprecate this in the bear also.

Fixes #270
  • Loading branch information
AbdealiLoKo committed Sep 3, 2016
1 parent 22cdc8a commit db8a2de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
18 changes: 13 additions & 5 deletions bears/js/JSHintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class JSHintBear:

@staticmethod
@deprecate_settings(es_version='use_es6_syntax',
javascript_strictness=(
"allow_global_strict",
lambda x: "global" if x else True),
cyclomatic_complexity='maxcomplexity',
allow_unused_variables=('prohibit_unused', negate),
max_parameters='maxparams',
Expand Down Expand Up @@ -90,14 +93,14 @@ def generate_config(filename, file,
allow_debugger: bool=False,
allow_assignment_comparisions: bool=False,
allow_eval: bool=False,
allow_global_strict: bool=False,
allow_increment: bool=False,
allow_proto: bool=False,
allow_scripturls: bool=False,
allow_singleton: bool=False,
allow_this_statements: bool=False,
allow_with_statements: bool=False,
use_mozilla_extension: bool=False,
javascript_strictness: bool_or_str=True,
allow_noyield: bool=False,
allow_eqnull: bool=False,
allow_last_semicolon: bool=False,
Expand Down Expand Up @@ -184,9 +187,6 @@ def generate_config(filename, file,
:param allow_eval:
This options suppresses warnings about the use of ``eval``
function.
:param allow_global_strict:
This option suppresses warnings about the use of global strict
mode.
:param allow_increment:
This option suppresses warnings about the use of unary increment
and decrement operators.
Expand All @@ -209,6 +209,14 @@ def generate_config(filename, file,
:param use_mozilla_extension:
This options tells JSHint that your code uses Mozilla JavaScript
extensions.
:param javascript_strictness:
Determines what sort of strictness to use in the JavaScript code.
The possible options are:
- "global" - there must be a ``"use strict";`` at global level
- "implied" - lint the code as if there is a ``"use strict";``
- "False" - disable warnings about strict mode
- "True" - there must be a ``"use strict";`` at function level
:param allow_noyield:
This option suppresses warnings about generator functions with no
``yield`` statement in them.
Expand Down Expand Up @@ -333,7 +341,7 @@ def generate_config(filename, file,
"debug": allow_debugger,
"boss": allow_assignment_comparisions,
"evil": allow_eval,
"globalstrict": allow_global_strict,
"strict": javascript_strictness,
"plusplus": allow_increment,
"proto": allow_proto,
"scripturl": allow_scripturls,
Expand Down
17 changes: 11 additions & 6 deletions tests/js/JSHintBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
}());
"""

test_es6 = """
# Test strictness and ES6
test_file4 = """
"use strict";
var foo = {
bar: 1,
baz: 2
Expand All @@ -30,6 +33,7 @@
console.log(bar, baz);
"""


jshintconfig = os.path.join(os.path.dirname(__file__),
"test_files",
"jshintconfig.json")
Expand All @@ -42,7 +46,8 @@
"shadow": "False",
"allow_last_semicolon": "True",
"es_version": 3,
"allow_latedef": "no_func"}
"allow_latedef": "no_func",
"javascript_strictness": "False"}


JSHintBearTest = verify_local_bear(JSHintBear,
Expand All @@ -67,11 +72,11 @@
JSHintBearDeprecationTest = verify_local_bear(
JSHintBear,
valid_files=(),
invalid_files=(test_es6,),
settings={"use_es6_syntax": 'False'})
invalid_files=(test_file4,),
settings={"use_es6_syntax": 'False', "allow_global_strict": 'False'})

JSHintBearDeprecation2Test = verify_local_bear(
JSHintBear,
valid_files=(test_es6,),
valid_files=(test_file4,),
invalid_files=(),
settings={"use_es6_syntax": 'True'})
settings={"use_es6_syntax": 'True', "allow_global_strict": 'True'})

0 comments on commit db8a2de

Please sign in to comment.