forked from palantir/tslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for error templates in tests (palantir#2481)
Add the ability to use placeholders in message substitutions. Syntax is inspired by python. It uses node's `util.format()` under the hood.
- Loading branch information
Showing
8 changed files
with
212 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {} from 'foo'; | ||
|
||
let noSubstitution; | ||
~~~~~~~~~~~~~~ [Identifier 'noSubstitution' is never reassigned; use 'const' instead of 'let'.] | ||
let noFormat; | ||
~~~~~~~~ [no_format] | ||
let format; | ||
~~~~~~ [let_base % ('format')] | ||
let formatMultiArgs; | ||
~~~~~~~~~~~~~~~ [base % ('formatMultiArgs', 'let')] | ||
var formatMultiArgsTrailingComma; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [base % ('formatMultiArgsTrailingComma', 'var', )] | ||
let indirection; | ||
~~~~~~~~~~~ [let % ('indirection')] | ||
var indirection2; | ||
~~~~~~~~~~~~ [var % ('indirection2')] | ||
let indirection3; | ||
~~~~~~~~~~~~ [partial_format % ('let')] | ||
var formatInSubstitution; | ||
~~~~~~~~~~~~~~~~~~~~ [preformatted] | ||
let worksWithEscape; | ||
~~~~~~~~~~~~~~~ [full_substitution % ('Identifier \'worksWithEscape\' is never reassigned; use \'const\' instead of \'let\'.')] | ||
var worksWithDoubleQuotes; | ||
~~~~~~~~~~~~~~~~~~~~~ [full_substitution % ("Identifier 'worksWithDoubleQuotes' is never reassigned; use 'const' instead of 'var'.")] | ||
let doesntTrimSpaces; | ||
~~~~~~~~~~~~~~~~ [base3 % ("Identifier 'doesntTrimSpaces' is never reassigned; ", " 'let'")] | ||
|
||
[no_format]: Identifier 'noFormat' is never reassigned; use 'const' instead of 'let'. | ||
[base]: Identifier '%s' is never reassigned; use 'const' instead of '%s'. | ||
[let_base]: Identifier '%s' is never reassigned; use 'const' instead of 'let'. | ||
[base2]: Identifier '%%s' is never reassigned; use 'const' instead of '%s'. | ||
[let]: base2 % ('let') | ||
[var]: base2 % ('var') | ||
[partial_format]: base % ('indirection3') | ||
[preformatted]: base % ('formatInSubstitution', 'var') | ||
[full_substitution]: %s | ||
[base3]: %suse 'const' instead of%s. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"prefer-const": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,3 +194,4 @@ declare let ambient = 0; | |
declare namespace ambient { | ||
let foo = 0; | ||
} | ||
|
Oops, something went wrong.