mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Add fix to non-externalized string warning
This commit is contained in:
parent
cdc432d939
commit
b381829341
|
@ -89,8 +89,12 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) {
|
|||
if (functionName && this.ignores[functionName]) {
|
||||
return;
|
||||
}
|
||||
var x = "foo";
|
||||
if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) {
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "Unexternalized string found: " + node.getText()));
|
||||
var s = node.getText();
|
||||
var replacement = new Lint.Replacement(node.getStart(), node.getWidth(), "nls.localize('KEY-" + s.substring(1, s.length - 1) + "', " + s + ")");
|
||||
var fix = new Lint.Fix("Unexternalitzed string", [replacement]);
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "Unexternalized string found: " + node.getText(), fix));
|
||||
return;
|
||||
}
|
||||
// We have a single quoted string outside a localize function name.
|
||||
|
@ -109,8 +113,8 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) {
|
|||
for (var i = 0; i < keyArg.properties.length; i++) {
|
||||
var property = keyArg.properties[i];
|
||||
if (isPropertyAssignment(property)) {
|
||||
var name_1 = property.name.getText();
|
||||
if (name_1 === 'key') {
|
||||
var name = property.name.getText();
|
||||
if (name === 'key') {
|
||||
var initializer = property.initializer;
|
||||
if (isStringLiteral(initializer)) {
|
||||
this.recordKey(initializer, this.messageIndex ? callInfo.callExpression.arguments[this.messageIndex] : undefined);
|
||||
|
|
|
@ -109,8 +109,12 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker {
|
|||
if (functionName && this.ignores[functionName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) {
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `Unexternalized string found: ${node.getText()}`));
|
||||
const s = node.getText();
|
||||
const replacement = new Lint.Replacement(node.getStart(), node.getWidth(), `nls.localize('KEY-${s.substring(1, s.length - 1)}', ${s})`);
|
||||
const fix = new Lint.Fix("Unexternalitzed string", [replacement]);
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `Unexternalized string found: ${node.getText()}`, fix));
|
||||
return;
|
||||
}
|
||||
// We have a single quoted string outside a localize function name.
|
||||
|
|
Loading…
Reference in a new issue