diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6e47f7a36844863950cb6e9b221efbaf1c52084f..5f25b2786a785fc10a19fe6130dcebbbac71ba05 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -32,7 +32,9 @@ "type": "gulp", "task": "tslint", "label": "Run tslint", - "problemMatcher": ["$tslint4"] + "problemMatcher": [ + "$tslint4" + ] }, { "taskName": "Run tests", @@ -59,6 +61,11 @@ "type": "gulp", "task": "electron", "label": "Download electron" + }, + { + "type": "gulp", + "task": "hygiene", + "problemMatcher": [] } ] -} \ No newline at end of file +} diff --git a/build/lib/i18n.js b/build/lib/i18n.js index c602385de748d8b6525de71f00d1bc411df50024..e496f956c528e535793a495a0fa70732947ac095 100644 --- a/build/lib/i18n.js +++ b/build/lib/i18n.js @@ -162,50 +162,50 @@ var XLF = (function () { line.append(content); this.buffer.push(line.toString()); }; - return XLF; -}()); -XLF.parse = function (xlfString) { - return new Promise(function (resolve, reject) { - var parser = new xml2js.Parser(); - var files = []; - parser.parseString(xlfString, function (err, result) { - if (err) { - reject("Failed to parse XLIFF string. " + err); - } - var fileNodes = result['xliff']['file']; - if (!fileNodes) { - reject('XLIFF file does not contain "xliff" or "file" node(s) required for parsing.'); - } - fileNodes.forEach(function (file) { - var originalFilePath = file.$.original; - if (!originalFilePath) { - reject('XLIFF file node does not contain original attribute to determine the original location of the resource file.'); + XLF.parse = function (xlfString) { + return new Promise(function (resolve, reject) { + var parser = new xml2js.Parser(); + var files = []; + parser.parseString(xlfString, function (err, result) { + if (err) { + reject("Failed to parse XLIFF string. " + err); } - var language = file.$['target-language'].toLowerCase(); - if (!language) { - reject('XLIFF file node does not contain target-language attribute to determine translated language.'); + var fileNodes = result['xliff']['file']; + if (!fileNodes) { + reject('XLIFF file does not contain "xliff" or "file" node(s) required for parsing.'); } - var messages = {}; - var transUnits = file.body[0]['trans-unit']; - transUnits.forEach(function (unit) { - var key = unit.$.id; - if (!unit.target) { - return; // No translation available - } - var val = unit.target.toString(); - if (key && val) { - messages[key] = decodeEntities(val); + fileNodes.forEach(function (file) { + var originalFilePath = file.$.original; + if (!originalFilePath) { + reject('XLIFF file node does not contain original attribute to determine the original location of the resource file.'); } - else { - reject('XLIFF file does not contain full localization data. ID or target translation for one of the trans-unit nodes is not present.'); + var language = file.$['target-language'].toLowerCase(); + if (!language) { + reject('XLIFF file node does not contain target-language attribute to determine translated language.'); } + var messages = {}; + var transUnits = file.body[0]['trans-unit']; + transUnits.forEach(function (unit) { + var key = unit.$.id; + if (!unit.target) { + return; // No translation available + } + var val = unit.target.toString(); + if (key && val) { + messages[key] = decodeEntities(val); + } + else { + reject('XLIFF file does not contain full localization data. ID or target translation for one of the trans-unit nodes is not present.'); + } + }); + files.push({ messages: messages, originalFilePath: originalFilePath, language: language }); }); - files.push({ messages: messages, originalFilePath: originalFilePath, language: language }); + resolve(files); }); - resolve(files); }); - }); -}; + }; + return XLF; +}()); exports.XLF = XLF; var iso639_3_to_2 = { 'chs': 'zh-cn', diff --git a/build/lib/tslint/importPatternsRule.js b/build/lib/tslint/importPatternsRule.js index 5f11b0944efbb5d199462a4738e99781fa5ae685..e3f3fa1247928129742e356dc71b2a0c3b268d8a 100644 --- a/build/lib/tslint/importPatternsRule.js +++ b/build/lib/tslint/importPatternsRule.js @@ -51,6 +51,14 @@ var ImportPatterns = (function (_super) { ImportPatterns.prototype.visitImportDeclaration = function (node) { this._validateImport(node.moduleSpecifier.getText(), node); }; + ImportPatterns.prototype.visitCallExpression = function (node) { + _super.prototype.visitCallExpression.call(this, node); + // import('foo') statements inside the code + if (node.expression.kind === ts.SyntaxKind.ImportKeyword) { + var path = node.arguments[0]; + this._validateImport(path.getText(), node); + } + }; ImportPatterns.prototype._validateImport = function (path, node) { // remove quotes path = path.slice(1, -1); diff --git a/build/lib/tslint/importPatternsRule.ts b/build/lib/tslint/importPatternsRule.ts index 4c267fb24d979fa7518de8614427aff803de56be..6e545a6be16052c9c1a33585d9e1d61f4e264ec9 100644 --- a/build/lib/tslint/importPatternsRule.ts +++ b/build/lib/tslint/importPatternsRule.ts @@ -45,6 +45,16 @@ class ImportPatterns extends Lint.RuleWalker { this._validateImport(node.moduleSpecifier.getText(), node); } + protected visitCallExpression(node: ts.CallExpression): void { + super.visitCallExpression(node); + + // import('foo') statements inside the code + if (node.expression.kind === ts.SyntaxKind.ImportKeyword) { + const [path] = node.arguments; + this._validateImport(path.getText(), node); + } + } + private _validateImport(path: string, node: ts.Node): void { // remove quotes path = path.slice(1, -1); diff --git a/build/lib/tslint/layeringRule.js b/build/lib/tslint/layeringRule.js index 31b19f3fb10cea135a327104db98a97df813ab53..20583dec5d928b850d855b1e9624ead3e74cf1ed 100644 --- a/build/lib/tslint/layeringRule.js +++ b/build/lib/tslint/layeringRule.js @@ -63,6 +63,14 @@ var LayeringRule = (function (_super) { LayeringRule.prototype.visitImportDeclaration = function (node) { this._validateImport(node.moduleSpecifier.getText(), node); }; + LayeringRule.prototype.visitCallExpression = function (node) { + _super.prototype.visitCallExpression.call(this, node); + // import('foo') statements inside the code + if (node.expression.kind === ts.SyntaxKind.ImportKeyword) { + var path = node.arguments[0]; + this._validateImport(path.getText(), node); + } + }; LayeringRule.prototype._validateImport = function (path, node) { // remove quotes path = path.slice(1, -1); diff --git a/build/lib/tslint/layeringRule.ts b/build/lib/tslint/layeringRule.ts index 8217f11d92303fc1983c85dbd4096ed343053271..089fd764afe100cc0a1974a69daced9ec6266b21 100644 --- a/build/lib/tslint/layeringRule.ts +++ b/build/lib/tslint/layeringRule.ts @@ -61,6 +61,16 @@ class LayeringRule extends Lint.RuleWalker { this._validateImport(node.moduleSpecifier.getText(), node); } + protected visitCallExpression(node: ts.CallExpression): void { + super.visitCallExpression(node); + + // import('foo') statements inside the code + if (node.expression.kind === ts.SyntaxKind.ImportKeyword) { + const [path] = node.arguments; + this._validateImport(path.getText(), node); + } + } + private _validateImport(path: string, node: ts.Node): void { // remove quotes path = path.slice(1, -1); diff --git a/build/lib/tslint/noUnexternalizedStringsRule.js b/build/lib/tslint/noUnexternalizedStringsRule.js index d6edfc0570a73ea46dd2b4099d0698f05d58dfef..d8eb4d3801743c5c99c44bd967707629d9b50065 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.js +++ b/build/lib/tslint/noUnexternalizedStringsRule.js @@ -172,6 +172,6 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) { node = parent; } }; + NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE = '"'; return NoUnexternalizedStringsRuleWalker; }(Lint.RuleWalker)); -NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE = '"'; diff --git a/build/lib/tslint/translationRemindRule.js b/build/lib/tslint/translationRemindRule.js index d0ed1a024038d687160aa6b7ffaef15a7db7e763..0d5fc2740307a27b0abed2ad9d07d2d67edb0556 100644 --- a/build/lib/tslint/translationRemindRule.js +++ b/build/lib/tslint/translationRemindRule.js @@ -74,6 +74,6 @@ var TranslationRemindRuleWalker = (function (_super) { this.addFailureAtNode(node, "Please add '" + resource + "' to ./builds/lib/i18n.resources.json file to use translations here."); } }; + TranslationRemindRuleWalker.NLS_MODULE = 'vs/nls'; return TranslationRemindRuleWalker; }(Lint.RuleWalker)); -TranslationRemindRuleWalker.NLS_MODULE = 'vs/nls';