This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15449|Reply: 0

[TypeScript] vs code TSLint common error solution

[Copy link]
Posted on 10/12/2018 1:39:49 PM | | |
TSLint is a Typescrip{filter}t validation tool for detecting code.

TSLint: comment must start with a space (comment-format)

Comments must start with a space (comment-format)

That is, // must be followed by a space.

"Missing semicolon." : "Missing semicolon."
"Use the function form of \"use strict\"." : "Define function using standardization.",
"Unexpected space after '-'." : "There should be no space after '-'.",
"Expected a JSON value." : "Please pass in a JSON value.",
"Mixed spaces and tabs.": "Spaces and tabs repeat.",
"Unsafe character." : "Unsafe character."
"Line too long.": "The characters in this line exceed the set maximum length.",
"Trailing whitespace.": "There are too many useless spaces at the end of this line.".
"scrip{filter}t URL." : "script URL.",
"Unexpected {a} in '{b}'." : "{a}.",
"Unexpected '{a}'." : "'{a}'.",
"Strings must use doublequotes."
"Unnecessary escapement." : "No escapement required."
"Control character in string: {a}." : "The character of Control appears in string",
"Avoid \\'." : "Avoid \\",
"Avoid \\v." : "Avoid \\v",
"avoid \\x-." : "avoid \\x-",
"Bad escapement." : "Wrong escape character",
"Bad number '{a}'." : "Bad number '{a}'",
"Missing space after '{a}'." : "Missing space after '{a}'",
"Don't use extra leading zeros '{a}'." : "Don't use extra 0s in front of '{a}'",
“Avoid 0x-. ‘ {a}'." : "Avoid using 0x-. ' {a}’.”,
"A trailing decimal point can be confused with a dot '{a}'." : "Use a dot trailing decimal point in '{a}'",
"Unexpected comment." : "Comments should not appear here",
"Unescaped '{a}'." : "Unescaped '{a}'",
"Unexpected control character in regular expression." : "The control character appeared in regular expression",
"Unexpected escaped character '{a}' in regular expression." : "Unexpected escaped character '{a}' appeared in regular expression",
"Expected '{a}' and instead saw '{b}'." : "Should replace '{b}' with '{a}'",
“Spaces are hard to count. Use {{a}}." : "Spaces are difficult to count, please use {{a}}",
"Insecure '{a}'." : "Insecure '{a}'",
"Empty class." : "empty class",
"Expected a number and instead saw '{a}'.":"Should be replaced with '{a}'",
"'{a}' should not be greater than '{b}'."
"'hasOwnProperty' is a really bad name.": "'hasOwnProperty' is a keyword",
"'{a}' was used before it was defined.": "'{a}' was used before it was defined.",
"'{a}' is already defined.":"'{a}' is repeatedly defined",
"A dot following a number can be confused with a decimal point.": "A dot following a number can be mistaken for a decimal point in decimal",
"Confusing minusses" : "confusing negative expression-",
"Confusing plusses." : "confusing positive expression+",
"Unmatched '{a}'." : "Unmatched '{a}'",
"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.": "In line {c} it is necessary to match '{a}' and '{b}' instead of '{d}'",
"Unexpected early end of program.": "Unexpected early end of program",
“A leading decimal point can be confused with a dot: ‘. {a}'.":"The dot before '{a}' is easily confused with a decimal point",
"Use the array literal notation [].": "Use the symbol of the array []",
"Expected an operator and instead saw '{a}'.":"Need to replace '{a}' with a symbol",
"Unexpected space after '{a}'.": "No space after '{a}'",
"Unexpected space before '{a}'.": "No space before '{a}'",
"Bad line breaking before '{a}'.": "Wrong line break before '{a}'",
"Expected '{a}' to have an indentation at {b} instead at {c}.": "'{a}' needs to be indented at {c} instead of {b}",
"Line breaking error '{a}'.":"Line break error '{a}'",
"Unexpected use of '{a}'.":"'{a}' cannot be used here",
"Bad operand.": "Wrong operand",
"Use the isNaN function to compare with NaN.": "Use the isNaN to compare with NaN",
"Confusing use of '{a}'.": "confusing use of '{a}'",
"Read only.": "Read only",
"'{a}' is a function.":"'{a}' is a function",
'Bad assignment.': 'Wrong assignment',
"Do not assign to the exception parameter.": "Do not assign values to additional parameters",
"Expected an identifier in an assignment and instead saw a function invocation.": "There needs to be an identifier in the assignment statement, not a call to a method",
"Expected an identifier and instead saw '{a}' (a reserved word).":"There needs to be an identifier instead of '{a}' (a reserved word)",
"Missing name in function declaration.": "Missing name in method declaration",
"Expected an identifier and instead saw '{a}'.":"There needs to be an identifier instead of '{a}'",
"Inner functions should be listed at the top of the outer function." ,
"Unreachable '{a}' after '{b}'.":"Unable to get '{a}' after '{b}'",
"Unnecessary semicolon."
"Label '{a}' on {b} statement.": "Put '{a}' on {b}'s statement",
"Label '{a}' looks like a javascrip{filter}t url.": "'{a}' looks like a js link",
"Expected an assignment or function call and instead saw an expression": "Requires an assignment or function call instead of an expression.",
"Do not use 'new' for side effects.": "Do not use 'new' statement.",
"Unnecessary\"use strict\".":"Unnecessary\"use strict\".",
"Missing \"use strict\" statement.":"Missing \"use strict\" statement",
"Empty block.": "empty module",
"Unexpected /*member '{a}'.":"The /* element '{a}'.",
"'{a}' is a statement label.": "'{a}' is a statement",
"'{a}' used out of scope.":"'{a}' used out of scope",
"'{a}' is not allowed.":"'{a}'",
"'{a}' is not defined.": "'{a}' is not defined",
"Use '{a}' to compare with '{b}'.": "Use '{a}' to compare with '{b}'",
"Variables should not be deleted.": "Variables need to be deleted",
"Use the object literal notation {}.":"Use the object's literal notation {}",
"Do not use {a} as a constructor.": "Do not use {a} as a constructor",
“The Function constructor is eval.”:“The Function constructor is eval.”,
"A constructor name should start with an uppercase letter.": "The name of a constructor must begin with a capital letter.",
"Bad constructor.": "Wrong constructor",
“Weird construction. Delete 'new'.": "The constructor is wrong, please delete 'new'",
"Missing '()' invoking a constructor.":"Missing parentheses ()",
“Avoid arguments. {a}.":"Avoid parameter. {a}.”,
"document.write can be a form of eval.":"document.write is a form of eval",
'eval is evil.': "Try not to use eval",
"Math is not a function.": "Math is not a function",
"Missing 'new' prefix when invoking a constructor.": "'new' is missing here",
"Missing radix parameter.": "Missing parameter",
“Implied eval is evil. Pass a function instead of a string.": "Pass a function instead of a string",
"Bad invocation.": "Wrong invocation",
"['{a}'] is better written in dot notation.":"['{a}'] is best used dot. way",
"Extra comma.": "Extra comma",
"Don't make functions within a loop.": "Don't create functions in a loop",
"Unexpected parameter '{a}' in get {b} function.":"The parameter '{a}' should not be used in the {b} method",
"Duplicate member '{a}'.":"Duplicate '{a}'",
"Expected to see a statement and instead saw a block.": "This should be a statement statement.",
"Too many var statements.": "Statements of too many var",
"Redefinition of '{a}'.":"'{a}' is repeatedly defined",
"It is not necessary to initialize '{a}' to 'undefined'."
"Expected a conditional expression and instead saw an assignment.": "An expression is needed here, not an assignment statement",
"Expected a 'break' statement before 'case'.",
"Expected a 'break' statement before 'default.":" 'break' is required before 'default'.",
"This 'switch' should be an 'if'.",
"All 'debugger' statements should be removed.": "Please delete the 'debugger' statement",
"'{a}' is not a statement label.",
"Expected an assignment or function call and instead saw an expression.": "Requires a statement or function call instead of an expression",
“Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.":"The function's declaration cannot be placed in an if-like block, it needs to be placed on top of the outer function."


Here are some examples of some tips you encounter in your project:

1 [W099]:Mixed spaces and tabs

This error is the most common, meaning that in the same line, spaces and tab indentation are mixed, and the modification is very simple, usually delete the tab indentation and change it all to space. For convenience, we can set the editor's tab indentation to 2 or 4 spaces instead of the original indentation.

2 [W030]:Expected an assignment or function call and instead saw an expression

This error is very weird, I use the following code to prompt this error index-1 <0 ? index = 0:index = index - 1;  This is a comma expression, but JSLInt thinks that it should not be an expression here, but a function, so if you care about this error, change it to an if else statement

3 [W041]:Use '===' to compare with ...

This mistake means that if we use congruence instead of equal, if the data types on both sides of the expression are the same, it is recommended to use congruence to judge

4 [W033]:Missing semicolon

missing semicolons; This is usually forgotten by yourself, but one thing to note is that for structures with only one sentence, semicolons also need to be written later. For example: if(index<0) {index=tcount-1} is correctly written as if(index<0) {index=tcount-1; }, I often forget to write semicolons here, sweat...

There are also some error prompts, so let's change them accordingly, and cultivate your own good code style and writing habits.





Previous:Modify the method of port mapping for docker containers
Next:Map usage, method calling
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com