Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request eslint#3669 from eslint/issue-3654
Browse files Browse the repository at this point in the history
Fix: `space-after-keywords` not working for `catch`
  • Loading branch information
ilyavolodin committed Sep 5, 2015
2 parents b72dde4 + 6589658 commit 7877229
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function getPluginsConfig(pluginNames) {
try {
plugin = require(pluginNamespace + util.PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix);
loadedPlugins[pluginNameWithoutPrefix] = plugin;
} catch(err) {
} catch (err) {
debug("Failed to load plugin configuration for " + pluginNameWithoutPrefix + ". Proceeding without it.");
plugin = { rulesConfig: {}};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function parseJsonConfig(string, location, messages) {
string = string.replace(/([a-zA-Z0-9\-\/]+):/g, "\"$1\":").replace(/(\]|[0-9])\s+(?=")/, "$1,");
try {
items = JSON.parse("{" + string + "}");
} catch(ex) {
} catch (ex) {

messages.push({
fatal: true,
Expand Down Expand Up @@ -755,7 +755,7 @@ module.exports = (function() {
: rule[nodeType]
);
});
} catch(ex) {
} catch (ex) {
ex.message = "Error while loading rule '" + key + "': " + ex.message;
throw ex;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-invalid-regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function(context) {

try {
void new RegExp(node.arguments[0].value);
} catch(e) {
} catch (e) {
context.report(node, e.message);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/space-after-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = function(context) {
checkTokens(node.finalizer, context.getTokenBefore(node.finalizer), context.getFirstToken(node.finalizer));
}
},
"CatchStatement": check,
"CatchClause": check,
"WithStatement": check
};
};
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/cli-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ describe("CLIEngine", function() {
try {
fs.unlinkSync(path.resolve(".eslintcache"));
fs.unlinkSync(path.resolve(".cache/custom-cache"));
} catch(ex) {
} catch (ex) {
// we don't care if the file didn't exist
// since our intention was to remove the file
}
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/space-after-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ ruleTester.run("space-after-keywords", rule, {
{ code: "if (a) {} else foo();", options: ["always"]},
{ code: "if(a) {} else foo();", options: ["never"]},
{ code: "try {}finally {}", args: [1]},
{ code: "try {}catch (e) {}", args: [1]},
{ code: "try{} finally{}", options: ["never"]},
{ code: "try{} catch(e) {}", options: ["never"]},
{ code: "(function(){})", args: [1] },
{ code: "(function(){})", args: [1] }
],
Expand All @@ -59,8 +61,11 @@ ruleTester.run("space-after-keywords", rule, {
{ code: "if(a){}else if(b){}else {}", options: ["never"], errors: [{ message: "Keyword \"else\" must not be followed by whitespace." }]},
{ code: "try{}finally {}", args: [1], errors: [{ message: "Keyword \"try\" must be followed by whitespace." }]},
{ code: "try {}finally{}", args: [1], errors: [{ message: "Keyword \"finally\" must be followed by whitespace." }]},
{ code: "try {}catch(e) {}", args: [1], errors: [{ message: "Keyword \"catch\" must be followed by whitespace." }]},
{ code: "try{}finally {}", options: ["never"], errors: [{ message: "Keyword \"finally\" must not be followed by whitespace." }]},
{ code: "try{}catch (e) {}", options: ["never"], errors: [{ message: "Keyword \"catch\" must not be followed by whitespace." }]},
{ code: "try {}finally{}", options: ["never"], errors: [{ message: "Keyword \"try\" must not be followed by whitespace." }]},
{ code: "try {}catch(e) {}", options: ["never"], errors: [{ message: "Keyword \"try\" must not be followed by whitespace." }]},
{ code: "if\n(a) {} else\n{}", options: ["never"], errors: [{ message: "Keyword \"if\" must not be followed by whitespace." }, { message: "Keyword \"else\" must not be followed by whitespace." }]},
{ code: "if\n(a) {} else\n{}", options: ["always"], errors: [{ message: "Keyword \"if\" must not be followed by a newline." }, { message: "Keyword \"else\" must not be followed by a newline." }]},
{ code: "do\n{} while\n(0)", options: ["always"], errors: [{ message: "Keyword \"do\" must not be followed by a newline." }, { message: "Keyword \"while\" must not be followed by a newline." }]}
Expand Down

0 comments on commit 7877229

Please sign in to comment.