diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-10-10 11:26:59 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-10-10 11:26:59 +0300 |
commit | 3799ac8973bb0bd08efe7a2af27808e5917183cc (patch) | |
tree | eef0fd6849bbe4f50576bded7c01c816ebec3004 /lib | |
parent | 86182afa7f3c6d6159e2ade7b88306ab1f62832b (diff) | |
download | tracifyjs-3799ac8973bb0bd08efe7a2af27808e5917183cc.tar.gz tracifyjs-3799ac8973bb0bd08efe7a2af27808e5917183cc.zip |
add `--lint` and display {file} in scope_warnings
Diffstat (limited to 'lib')
-rw-r--r-- | lib/scope.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/scope.js b/lib/scope.js index f705428e..7edce0e5 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -500,8 +500,9 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){ // XXX: this also warns about JS standard names, // i.e. Object, Array, parseInt etc. Should add a list of // exceptions. - AST_Node.warn("Undeclared symbol: {name} [{line},{col}]", { + AST_Node.warn("Undeclared symbol: {name} [{file}:{line},{col}]", { name: node.name, + file: node.start.file, line: node.start.line, col: node.start.col }); @@ -516,9 +517,10 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){ if (sym && (sym.undeclared() || (sym.global() && sym.scope !== sym.definition().scope))) { - AST_Node.warn("{msg}: {name} [{line},{col}]", { + AST_Node.warn("{msg}: {name} [{file}:{line},{col}]", { msg: sym.undeclared() ? "Accidental global?" : "Assignment to global", name: sym.name, + file: sym.start.file, line: sym.start.line, col: sym.start.col }); @@ -528,14 +530,15 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){ && node instanceof AST_SymbolRef && node.undeclared() && node.name == "eval") { - AST_Node.warn("Eval is used [{line},{col}]", node.start); + AST_Node.warn("Eval is used [{file}:{line},{col}]", node.start); } if (options.unreferenced && node instanceof AST_SymbolDeclaration && node.unreferenced()) { - AST_Node.warn("{type} {name} is declared but not referenced [{line},{col}]", { + AST_Node.warn("{type} {name} is declared but not referenced [{file}:{line},{col}]", { type: node instanceof AST_Label ? "Label" : "Symbol", name: node.name, + file: node.start.file, line: node.start.line, col: node.start.col }); @@ -543,8 +546,9 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){ if (options.func_arguments && node instanceof AST_Lambda && node.uses_arguments) { - AST_Node.warn("arguments used in function {name} [{line},{col}]", { + AST_Node.warn("arguments used in function {name} [{file}:{line},{col}]", { name: node.name ? node.name.name : "anonymous", + file: node.start.file, line: node.start.line, col: node.start.col }); @@ -552,8 +556,10 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){ if (options.nested_defuns && node instanceof AST_Defun && !(tw.parent() instanceof AST_Scope)) { - AST_Node.warn("Function {name} declared in nested statement [{line},{col}]", { + AST_Node.warn("Function {name} declared in nested statement \"{type}\" [{file}:{line},{col}]", { name: node.name.name, + type: tw.parent().TYPE, + file: node.start.file, line: node.start.line, col: node.start.col }); |