Skip to content

Commit

Permalink
JSHintBear: Deprecate "use_es6_syntax"
Browse files Browse the repository at this point in the history
The "esnext" argument in JSHint has been deprecated in JSHint.
Hence, we deprecate this from coala and set the es_version
config instead.

Fixes #740
  • Loading branch information
AbdealiLoKo committed Sep 3, 2016
1 parent fa70e92 commit 22cdc8a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bears/js/JSHintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class JSHintBear:
CAN_DETECT = {'Formatting', 'Syntax', 'Complexity', 'Unused Code'}

@staticmethod
@deprecate_settings(cyclomatic_complexity='maxcomplexity',
@deprecate_settings(es_version='use_es6_syntax',
cyclomatic_complexity='maxcomplexity',
allow_unused_variables=('prohibit_unused', negate),
max_parameters='maxparams',
allow_missing_semicolon='allow_missing_semicol',
Expand Down Expand Up @@ -102,7 +103,6 @@ def generate_config(filename, file,
allow_last_semicolon: bool=False,
allow_func_in_loop: bool=False,
allow_expr_in_assignments: bool=False,
use_es6_syntax: bool=False,
use_es3_array: bool=False,
environment_mootools: bool=False,
environment_couch: bool=False,
Expand Down Expand Up @@ -132,7 +132,7 @@ def generate_config(filename, file,
allow_variable_shadowing: bool_or_str=False,
allow_unused_variables: bool_or_str=False,
allow_latedef: bool_or_str=False,
es_version: int=5,
es_version: bool_or_int=5,
jshint_config: str=""):
"""
:param allow_bitwise_operators:
Expand Down Expand Up @@ -225,8 +225,6 @@ def generate_config(filename, file,
:param use_es3_array:
This option tells JSHintBear ES3 array elision elements, or empty
elements are used.
:param use_es3_array:
This option tells JSHint ECMAScript 6 specific syntax is used.
:param environment_mootools:
This option defines globals exposed by the Mootools.
:param environment_couch:
Expand Down Expand Up @@ -308,6 +306,12 @@ def generate_config(filename, file,
This option is used to specify the ECMAScript version to which the
code must adhere to.
"""
# Assume that when es_version is bool, it is intended for the
# deprecated use_es6_version
if es_version is True:
es_version = 6
elif es_version is False:
es_version = 5
if not jshint_config:
options = {"bitwise": not allow_bitwise_operators,
"freeze": not allow_prototype_overwrite,
Expand Down Expand Up @@ -342,7 +346,6 @@ def generate_config(filename, file,
"lastsemic": allow_last_semicolon,
"loopfunc": allow_func_in_loop,
"expr": allow_expr_in_assignments,
"esnext": use_es6_syntax,
"elision": use_es3_array,
"mootools": environment_mootools,
"couch": environment_couch,
Expand Down
20 changes: 20 additions & 0 deletions tests/js/JSHintBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
}());
"""

test_es6 = """
var foo = {
bar: 1,
baz: 2
};
var { bar, baz } = foo;
console.log(bar, baz);
"""

jshintconfig = os.path.join(os.path.dirname(__file__),
"test_files",
Expand Down Expand Up @@ -55,3 +63,15 @@
invalid_files=(),
valid_files=(test_file3, ),
settings=settings)

JSHintBearDeprecationTest = verify_local_bear(
JSHintBear,
valid_files=(),
invalid_files=(test_es6,),
settings={"use_es6_syntax": 'False'})

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

0 comments on commit 22cdc8a

Please sign in to comment.