mirror of
https://github.com/Microsoft/vscode
synced 2024-11-05 18:29:38 +00:00
3fcb671444
Upgrades our build scripts to target ES2017 since they are run on modern versions of node This allows us to remove shims for es6 features such as `Object.assign`, and also remove a few extra typings packages
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
"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 path_1 = require("path");
|
|
const Lint = require("tslint");
|
|
class Rule extends Lint.Rules.AbstractRule {
|
|
apply(sourceFile) {
|
|
return this.applyWithWalker(new ImportPatterns(sourceFile, this.getOptions()));
|
|
}
|
|
}
|
|
exports.Rule = Rule;
|
|
class ImportPatterns extends Lint.RuleWalker {
|
|
constructor(file, opts) {
|
|
super(file, opts);
|
|
this.imports = Object.create(null);
|
|
}
|
|
visitImportDeclaration(node) {
|
|
let path = node.moduleSpecifier.getText();
|
|
// remove quotes
|
|
path = path.slice(1, -1);
|
|
if (path[0] === '.') {
|
|
path = path_1.join(path_1.dirname(node.getSourceFile().fileName), path);
|
|
}
|
|
if (this.imports[path]) {
|
|
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `Duplicate imports for '${path}'.`));
|
|
}
|
|
this.imports[path] = true;
|
|
}
|
|
}
|