Skip to content

Commit d79b94f

Browse files
committed
ESLintBear: Handle corner case if eslint fails
If eslint fails to run, for example if it gets an invalid config file it does not know how to handle, earlier the bear would throw a JSON Decoding error because it wouldn't know how to parse "" (an empty string). Now this case is handled, and it gracefull doesn't try to create results in such cases. Fixes coala#727
1 parent 5c308a2 commit d79b94f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

bears/js/ESLintBear.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def generate_config(filename, file):
4848
return '{"extends": "eslint:recommended"}'
4949

5050
def process_output(self, output, filename, file):
51-
if not file:
51+
if not file or not output:
5252
return
5353

5454
output = json.loads(output)

tests/js/ESLintBearTest.py

+9
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@
3838
ESLintBear,
3939
valid_files=(test_good, ''),
4040
invalid_files=(test_syntax_error, test_bad))
41+
42+
# If there is an invalid config file, the results cannot be found. So, no
43+
# file gives a result.
44+
ESLintBearWithUnloadablePluginTest = verify_local_bear(
45+
ESLintBear,
46+
valid_files=(test_bad, test_good),
47+
invalid_files=(),
48+
settings={"eslint_config": os.path.join(test_dir,
49+
"eslintconfig_badplugin.json")})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"plugins": ["invalid_plugin_should_throw_error"],
4+
"rules": {
5+
"consistent-return": 2,
6+
"indent" : [1, 4],
7+
"no-else-return" : 1,
8+
"semi" : [1, "always"],
9+
"space-unary-ops" : [2, {
10+
"words": true,
11+
"nonwords": true
12+
}]
13+
}
14+
}

0 commit comments

Comments
 (0)