Permalink
Browse files

Extracted all warnings and error messages into a separate files.

I decided to go with a structure I used in Next: every message has a
code and a description. In code, we will be referencing messages only
by their codes.
  • Loading branch information...
1 parent cc64dc6 commit 6dc73c4f4d3f038d0513db82b4a34a91ce81333b @valueof valueof committed Oct 31, 2012
Showing with 205 additions and 0 deletions.
  1. +205 −0 src/shared/messages.js
View
@@ -0,0 +1,205 @@
+"use strict";
+
+var _ = require("underscore");
+
+var errors = {
+ E001: "Bad option: '{a}'.",
+ E002: "Unmatched '{a}'.",
+ E003: "Expected '{a}' to match '{b}' from line {c} and " +
+ "instead saw '{d}'.",
+ E004: "Expected '{a}' and instead saw '{b}'.",
+ E005: "Expected an identifier and instead saw '{a}'.",
+ E006: "Line breaking error '{a}'.",
+ E007: "Attempting to verride '{a}' which is a constant.",
+ E008: "Bad assignment.",
+ E009: "Missing \"use strict\" statement.",
+ E010: "Strict violation.",
+ E011: "const '{a}' has already been declared.",
+ E012: "const '{a}' is initialized to 'undefined'.",
+ E013: "Missing '{a}'.",
+ E014: "Unexpected '{a}'.",
+ E015: "Unclosed comment.",
+ E016: "A regular expression literal can be confused with '/='.",
+ E017: "Unclosed regular expression.",
+ E018: "Confusing regular expression.",
+ E019: "Unescaped '{a}'.",
+ E020: "Unbegun comment.",
+ E021: "What?", // FIXME,
+ E022: "Expected a small integer and instead saw '{a}'.",
+ E023: "Option 'validthis' can't be used in a global scope.",
+ E024: "Bad option value.",
+ E025: "Missing option value.",
+ E026: "Unexpected early end of program.",
+ E027: "Expected an operator and instead saw '{a}'.",
+ E028: "Strict violation.",
+ E029: "get/set are ES5 features.",
+ E030: "Missing property name.",
+ E031: "Expected to see a statement and instead saw a block.",
+ E032: "Constant {a} was not declared correctly.",
+ E033: "Variable {a} was not declared correctly.",
+ E034: "Function declarations are not invocable. Wrap the whole function " +
+ "invocation in parens.",
+ E035: "'with' is not allowed in strict mode.",
+ E036: "Each value should have its own case label.",
+ E037: "Missing ':' on a case clause.",
+ E038: "Missing '}' to match '{' from line {a}.",
+ E039: "Missing ']' to match '[' form line {a}.",
+ E040: "Unexpected comma.",
+ E041: "Expected a JSON value.",
+ E042: "Input is neither a string nor an array of strings.",
+ E043: "Input is empty.",
+};
+
+var warnings = {
+ W001: "'{a}' is a really bad name.",
+ W002: "Value of '{a}' may be overwritten in IE.",
+ W003: "'{a}' was used before it was defined.",
+ W004: "'{a}' is already defined.",
+ W005: "A dot following a number can be confused with a decimal point.",
+ W006: "Confusing minuses.",
+ W007: "Confusing pluses.",
+ W008: "A leading decimal point can be confused with a dot: '.{a}'.",
+ W009: "The array literal notation [] is preferrable.",
+ W010: "The object literal notation {} is preferrable.",
+ W011: "Unexpected space after '{a}'.",
+ W012: "Unexpected space before '{a}'.",
+ W013: "Missing space after '{a}'.",
+ W014: "Bad line breaking before '{a}'.",
+ W015: "Expected '{a}' to have an indentation at {b} instead at {c}.",
+ W016: "Unexpected use of '{a}'.",
+ W017: "Bad operand.",
+ W018: "Confusing use of '{a}'.",
+ W019: "Use the isNaN function to compare with NaN.",
+ W020: "Read only.",
+ W021: "'{a}' is a function.",
+ W022: "Do not assign to the exception parameter.",
+ W023: "Expected an identifier in an assignment and instead saw a " +
+ "function invocation.",
+ W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
+ W025: "Missing name in function declaration.",
+ W026: "Inner functions should be listed at the top of the outer function.",
+ W027: "Unreachable '{a}' after '{b}'.",
+ W028: "Label '{a}' on {b} statement.",
+ W029: "Label '{a}' looks like a javascript url.",
+ W030: "Expected an assignment or function call and instead saw " +
+ "an expression.",
+ W031: "Do not use 'new' for side-effects.",
+ W032: "Unnecessary semicolon.",
+ W033: "Missing semicolon.",
+ W034: "Unnecessary directive \"{a}\".",
+ W035: "Empty block.",
+ W036: "Unexpected /*member '{a}'.",
+ W037: "'{a}' is a statement label.",
+ W038: "'{a}' used out of scope.",
+ W039: "'{a}' is not allowed.",
+ W040: "Possible strict violation.",
+ W041: "Use '{a}' to compare with '{b}'.",
+ W050: "JavaScript URL.",
+ W051: "Variables should not be deleted.",
+ W052: "Unexpected '{a}'.",
+ W053: "Do not use {a} as a constructor.",
+ W054: "The Function constructor is a form of eval.",
+ W055: "A constructor name should start with an uppercase letter.",
+ W056: "Bad constructor.",
+ W057: "Weird construction. Is 'new' unnecessary?",
+ W058: "Missing '()' invoking a constructor",
+ W059: "Avoid arguments.{a}.",
+ W060: "document.write can be a form of eval.",
+ W061: "eval can be harmful.",
+ W062: "Wrap an immediate function invocation in parens " +
+ "to assist the reader in understanding that the expression " +
+ "is the result of a function, and not the function itself.",
+ W063: "Math is not a function.",
+ W064: "Missing 'new' prefix when invoking a constructor.",
+ W065: "Missing radix parameter.",
+ W066: "Implied eval. Consider passing a function instead of a string.",
+ W067: "Bad invocation.",
+ W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
+ W069: "['{a}'] is better written in dot notation.",
+ W070: "Extra comma. (it breaks older versions of IE)",
+ W071: "This function has too many statements. ({a})",
+ W072: "This function has too many parameters. ({a})",
+ W073: "Blocks are nested too deeply. ({a})",
+ W074: "This function's cyclomatic complexity is too high. ({a})",
+ W075: "Duplicate key '{a}'.",
+ W076: "Unexpected parameter '{a}' in get {b} function.",
+ W077: "Expected a single parameter in set {a} function.",
+ W078: "Setter is defined without getter.",
+ W079: "Redefinition of '{a}'.",
+ W080: "It's not necessary to initialize '{a}' to 'undefined'.",
+ W081: "Too many var statements.",
+ W082: "Function declarations should not be placed in blocks. " +
+ "Use a function expression or move the statement to the top of " +
+ "the outer function.",
+ W083: "Don't make functions within a loop.",
+ W084: "Expected a conditional expression and instead saw an " +
+ "assignment.",
+ W085: "Don't use 'with'.",
+ W086: "Expected a 'break' statement before '{a}'.",
+ W087: "Forgotten 'debugger' statement?",
+ W088: "Bad for in variable '{a}'.",
+ W089: "The body of a for in should be wrapped in an if statement to filter " +
+ "unwanted properties from the prototype.",
+ W090: "'{a}' is not a statement label.",
+ W091: "'{a}' is out of scope.",
+ W092: "Wrap the /regexp/ literal in parens to disambiguate the slash operator.",
+ W093: "Did you mean to return a conditional instead of an assignment?",
+ W094: "Unexpected comma.",
+ W095: "Expected a string and instead saw {a}.",
+ W096: "The '{a}' key may produce unexpected results.",
+ W097: "Use the function form of \"use strict\".",
+ W098: "'{a}' is defined but never used.",
+ W099: "Mixed spaces and tabs.",
+ W100: "This character may get silently deleted by one or more browsers.",
+ W101: "Line is too long.",
+ W102: "Trailing whitespace.",
+ W103: "The '{a}' property is deprecated.",
+ W104: "'{a}' is only available in JavaScript 1.7",
+ W105: "Unexpected {a} in '{b}'.",
+ W106: "Identifier '{a}' is not in camel case.",
+ W107: "Script URL",
+ W108: "Strings must use doublequote.",
+ W109: "Strings must use singlequote.",
+ W110: "Mixed double and single quotes.",
+ W111: "Unnecessary escapement.",
+ W112: "Unclosed string.",
+ W113: "Control character in string: {a}.",
+ W114: "Avoid {a}.",
+ W115: "Octal literals are not allowed in strict mode.",
+ W116: "Avoid EOL escapement.",
+ W117: "Bad escapement of EOL. Use option multistr if needed.",
+ W118: "Bad escapement.",
+ W119: "Bad number '{a}'.",
+ W120: "Don't use extra leading zeroes '{a}'.",
+ W121: "A trailing decimal point can be confused with a dot: '{a}'.",
+ W122: "Unterminated regular expression.",
+ W123: "Unexpected control character in regular expression.",
+ W124: "Unexpected escaped character '{a}' in regular expression.",
+ W125: "Unescaped '{a}'.",
+ W126: "Spaces are hard to count. Use {{a}}.",
+ W127: "Empty class.",
+ W128: "'{a}' in character sets should be escaped.",
+ W129: "Insecure '{a}'.",
+ W130: "Expected a number and instead saw '{a}'.",
+ W131: "'{a}' should not be greater than '{b}'.",
+};
+
+var info = {
+ I001: "Comma warnings can be turned off with 'laxcomma'."
+};
+
+exports.errors = {};
+exports.warnings = {};
+exports.info = {};
+
+_.each(errors, function (desc, code) {
+ exports.errors[code] = { code: code, desc: desc };
+});
+
+_.each(warnings, function (desc, code) {
+ exports.warnings[code] = { code: code, desc: desc };
+});
+
+_.each(info, function (desc, code) {
+ exports.info[code] = { code: code, desc: desc };
+});

0 comments on commit 6dc73c4

Please sign in to comment.