1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | module.exports = function(context) {
|
11 |
|
12 | "use strict";
|
13 |
|
14 | var inCatch = false,
|
15 | exceptionName = null;
|
16 |
|
17 | return {
|
18 |
|
19 | "CatchClause": function(node) {
|
20 | inCatch = true;
|
21 | exceptionName = node.param.name;
|
22 | },
|
23 |
|
24 | "CatchClause:exit": function() {
|
25 | inCatch = false;
|
26 | exceptionName = null;
|
27 | },
|
28 |
|
29 | "AssignmentExpression": function(node) {
|
30 |
|
31 | if (inCatch) {
|
32 |
|
33 | if (node.left.name === exceptionName) {
|
34 | context.report(node, "Do not assign to the exception parameter.");
|
35 | }
|
36 | }
|
37 | }
|
38 |
|
39 | };
|
40 |
|
41 | };
|