forked from microsoft/azuredatastudio
-
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.
Merge from vscode 966b87d (microsoft#4696)
- Loading branch information
Anthony Dresser
authored
Mar 26, 2019
1 parent
b1393ae
commit 0d8ef95
Showing
268 changed files
with
5,873 additions
and
3,348 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
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,54 @@ | ||
"use strict"; | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ts = require("typescript"); | ||
const Lint = require("tslint"); | ||
const path_1 = require("path"); | ||
class Rule extends Lint.Rules.AbstractRule { | ||
apply(sourceFile) { | ||
if (/vs(\/|\\)editor(\/|\\)standalone(\/|\\)/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)common(\/|\\)standalone(\/|\\)/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)editor.api/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)editor.main/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)editor.worker/.test(sourceFile.fileName)) { | ||
return this.applyWithWalker(new NoNlsInStandaloneEditorRuleWalker(sourceFile, this.getOptions())); | ||
} | ||
return []; | ||
} | ||
} | ||
exports.Rule = Rule; | ||
class NoNlsInStandaloneEditorRuleWalker extends Lint.RuleWalker { | ||
constructor(file, opts) { | ||
super(file, opts); | ||
} | ||
visitImportEqualsDeclaration(node) { | ||
if (node.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) { | ||
this._validateImport(node.moduleReference.expression.getText(), node); | ||
} | ||
} | ||
visitImportDeclaration(node) { | ||
this._validateImport(node.moduleSpecifier.getText(), node); | ||
} | ||
visitCallExpression(node) { | ||
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); | ||
} | ||
} | ||
_validateImport(path, node) { | ||
// remove quotes | ||
path = path.slice(1, -1); | ||
// resolve relative paths | ||
if (path[0] === '.') { | ||
path = path_1.join(this.getSourceFile().fileName, path); | ||
} | ||
if (/vs(\/|\\)nls/.test(path)) { | ||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `Not allowed to import vs/nls in standalone editor modules. Use standaloneStrings.ts`)); | ||
} | ||
} | ||
} |
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,67 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as ts from 'typescript'; | ||
import * as Lint from 'tslint'; | ||
import { join } from 'path'; | ||
|
||
export class Rule extends Lint.Rules.AbstractRule { | ||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { | ||
if ( | ||
/vs(\/|\\)editor(\/|\\)standalone(\/|\\)/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)common(\/|\\)standalone(\/|\\)/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)editor.api/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)editor.main/.test(sourceFile.fileName) | ||
|| /vs(\/|\\)editor(\/|\\)editor.worker/.test(sourceFile.fileName) | ||
) { | ||
return this.applyWithWalker(new NoNlsInStandaloneEditorRuleWalker(sourceFile, this.getOptions())); | ||
} | ||
|
||
return []; | ||
} | ||
} | ||
|
||
class NoNlsInStandaloneEditorRuleWalker extends Lint.RuleWalker { | ||
|
||
constructor(file: ts.SourceFile, opts: Lint.IOptions) { | ||
super(file, opts); | ||
} | ||
|
||
protected visitImportEqualsDeclaration(node: ts.ImportEqualsDeclaration): void { | ||
if (node.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) { | ||
this._validateImport(node.moduleReference.expression.getText(), node); | ||
} | ||
} | ||
|
||
protected visitImportDeclaration(node: ts.ImportDeclaration): void { | ||
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); | ||
|
||
// resolve relative paths | ||
if (path[0] === '.') { | ||
path = join(this.getSourceFile().fileName, path); | ||
} | ||
|
||
if ( | ||
/vs(\/|\\)nls/.test(path) | ||
) { | ||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `Not allowed to import vs/nls in standalone editor modules. Use standaloneStrings.ts`)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.