Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
else {
// Relative import paths that are not reaching up to the containment path
// are not allowed to import certain file names
if (disallowedInternalFileNames.indexOf(importFileName) !== -1)
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING2));
}
}
}
}
// call the base version of this visitor to actually parse this node
_super.prototype.visitImportDeclaration.call(this, node);
};
return ImportsContainmentWalker;
}(Lint.RuleWalker));
function getSourceFilePathRelativeToContainmentPath(sourceFilePath, containmentPath) {
// In run-time, the source file path can be a full path from "C:\XXX\YYY\ZZZ"
// So we just try to match a part of the path with the containment dir
var indexOfContainmentPath = sourceFilePath.lastIndexOf(containmentPath);
//throw Error("indexOfContainmentDir: " + indexOfContainmentDir + ", absoluteSourceDirPath: " + absoluteSourceDirPath);
// Check if the file resides under the containment path
if (indexOfContainmentPath !== -1) {
var relativeSourceFilePath = sourceFilePath.substr(indexOfContainmentPath);
return relativeSourceFilePath;
}
return undefined;
}
function getMyOptions(options) {
var myOptions = options[0]; // "src/app";
if (!myOptions)
return undefined;
function UnderscorePrefixWalker() {
Lint.RuleWalker.apply(this, arguments);
}
return;
}
if (node.left.kind === ts.SyntaxKind.Identifier && this.variableNode.name.getText() === node.left.getText()) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
else if (node.left.kind === ts.SyntaxKind.ArrayLiteralExpression) {
var els = node.left.elements;
if (els.some(function (el) { return el.getText() === _this.variableNode.getText(); })) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
}
}
_super.prototype.visitBinaryExpression.call(this, node);
};
return NoExAssignWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vRXhBc3NpZ25SdWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLCtCQUFpQztBQUNqQyw2QkFBK0I7QUFDL0IsMENBQXFEO0FBRXJEO0lBQTBCLHdCQUF1QjtJQUFqRDs7SUFPQSxDQUFDO0lBSlEsb0JBQUssR0FBWixVQUFhLFVBQXlCO1FBQ3BDLElBQU0sTUFBTSxHQUFHLElBQUksZ0JBQWdCLENBQUMsVUFBVSxFQUFFLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQ25FLE1BQU0sQ0FBQyxJQUFJLENBQUMsZUFBZSxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3RDLENBQUM7SUFDSCxXQUFDO0FBQUQsQ0FQQSxBQU9DLENBUHlCLElBQUksQ0FBQyxLQUFLLENBQUMsWU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STRING = {
always: 'Requires a space',
never: 'Unexpected space(s)'
};
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
const walker = new BlockSpacingWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
}
}
class BlockSpacingWalker extends Lint.RuleWalker {
private always: boolean;
constructor(sourceFile: ts.SourceFile, options: Lint.IOptions) {
super(sourceFile, options);
this.always = this.hasOption(OPTION_ALWAYS) || (this.getOptions() && this.getOptions().length === 0);
}
protected visitNode(node: ts.Node): void {
if (node.kind === ts.SyntaxKind.Block || node.kind === ts.SyntaxKind.CaseBlock) {
this.checkSpacingInsideBraces(node);
}
super.visitNode(node);
}
private checkSpacingInsideBraces(node: ts.Node): void {
_this.OPERATORS = [ts.SyntaxKind.EqualsEqualsToken, ts.SyntaxKind.EqualsEqualsEqualsToken, ts.SyntaxKind.ExclamationEqualsToken, ts.SyntaxKind.ExclamationEqualsEqualsToken];
return _this;
}
UseIsnanWalker.prototype.visitBinaryExpression = function (node) {
this.validateUseIsnan(node);
_super.prototype.visitBinaryExpression.call(this, node);
};
UseIsnanWalker.prototype.validateUseIsnan = function (node) {
if (this.OPERATORS.indexOf(node.operatorToken.kind) !== -1) {
if (node.left.getText() === 'NaN' || node.right.getText() === 'NaN') {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
}
};
return UseIsnanWalker;
}(Lint.RuleWalker));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3VzZUlzbmFuUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSwrQkFBaUM7QUFDakMsNkJBQStCO0FBRS9CO0lBQTBCLHdCQUF1QjtJQUFqRDs7SUFPQSxDQUFDO0lBSlEsb0JBQUssR0FBWixVQUFhLFVBQXlCO1FBQ3BDLElBQU0sTUFBTSxHQUFHLElBQUksY0FBYyxDQUFDLFVBQVUsRUFBRSx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QUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUM7WUFDN0YsQ0FBQztRQUNILENBQUM7SUFDSCxDQUFDO0lBQ0gscUJBQUM7QUFBRCxDQWZBLEFBZUMsQ0FmNEIsSUFBSSxDQUFDLFVBQVUsR0FlM0MiLCJmaWxlIjoicnVsZXMvdXNlSXNuYW5SdWxlLmpzIiwic291cmNlUm9vdCI6IkM6XFx0c2xpbnQtZXNsaW50LXJ1bGVzXFxzcmMifQ==
`
],
typescriptOnly: false,
type: 'style'
};
public static MISSING_SPACE_MESSAGE = 'there must be a space inside this paren.';
public static REJECTED_SPACE_MESSAGE = 'there should be no spaces inside this paren.';
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
const walker = new SpaceInParensWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
}
}
class SpaceInParensWalker extends Lint.RuleWalker {
private spaced: boolean;
private exceptionsArrayOptions: string[] = [];
private braceException: boolean;
private bracketException: boolean;
private parenException: boolean;
private empty: boolean;
constructor(sourceFile: ts.SourceFile, options: Lint.IOptions) {
super(sourceFile, options);
const ruleOptions = this.getOptions();
this.spaced = this.hasOption('always');
if (ruleOptions[1]) {
this.exceptionsArrayOptions = (ruleOptions.length === 2) ? ruleOptions[1].exceptions : [] ;
if (this.exceptionsArrayOptions.length) {
this.braceException = this.exceptionsArrayOptions.indexOf('{}') !== -1;
case ts.SyntaxKind.BinaryExpression:
if (token_1.isAssignmentToken(node.operatorToken)) {
return this.isConstant(node.right);
}
return this.isConstant(node.left) && this.isConstant(node.right);
case ts.SyntaxKind.ConditionalExpression:
return this.isConstant(node.condition);
case ts.SyntaxKind.PrefixUnaryExpression:
return this.isConstant(node.operand);
case ts.SyntaxKind.ParenthesizedExpression:
return this.isConstant(node.expression);
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VSxDQUFFLElBQW1DLENBQUMsVUFBVSxDQUFDLENBQUM7UUFDNUUsQ0FBQztRQUVELE1BQU0sQ0FBQyxLQUFLLENBQUM7SUFDZixDQUFDO0lBQ0gsZ0NBQUM7QUFBRCxDQTNGQSxBQTJGQyxDQTNGdUMsSUFBSSxDQUFDLFVBQVUsR0EyRnREIiwiZmlsZSI6InJ1bGVzL25vQ29uc3RhbnRDb25kaXRpb25SdWxlLmpzIiwic291cmNlUm9vdCI6IkM6XFx0c2xpbnQtZXNsaW50LXJ1bGVzXFxzcmMifQ==
}
}
Rule.metadata = {
ruleName: 'adf-license-banner',
type: 'maintainability',
description: ``,
descriptionDetails: ``,
rationale: ``,
options: null,
optionsDescription: `Not configurable.`,
typescriptOnly: true,
};
Rule.FAILURE_STRING = 'Missing license header in this TypeScript ' +
'file Every TypeScript file of the library needs to have the Alfresco license banner at the top.';
exports.Rule = Rule;
class ADFLicenseBannerRule extends Lint.RuleWalker {
constructor(sourceFile, options) {
super(sourceFile, options);
const fileGlobs = options.ruleArguments;
this.licensePath = options.ruleArguments[1];
const relativeFilePath = path.relative(process.cwd(), sourceFile.fileName);
this._enabled = fileGlobs.some(p => minimatch(relativeFilePath, p));
}
visitSourceFile(sourceFile) {
if (!this._enabled) {
return;
}
const fileContent = sourceFile.getFullText();
const licenseBanner = fs.readFileSync(this.licensePath, 'utf8');
const licenseCommentPos = fileContent.indexOf(licenseBanner);
const tslintFix = Lint.Replacement.appendText(0, licenseBanner + '\n\n');
if (licenseCommentPos !== 0) {
}
}
]
`
],
typescriptOnly: false,
type: 'maintainability'
};
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
const walker = new IndentWalker(sourceFile, this.getOptions());
return this.applyWithWalker(walker);
}
}
class IndentWalker extends Lint.RuleWalker {
private srcFile: ts.SourceFile;
private srcText: string;
private caseIndentStore: { [key: number]: number } = {};
private varIndentStore: { [key: number]: number } = {};
constructor(sourceFile: ts.SourceFile, options: Lint.IOptions) {
super(sourceFile, options);
OPTIONS = {
SwitchCase: 0,
VariableDeclarator: {
var: DEFAULT_VARIABLE_INDENT,
let: DEFAULT_VARIABLE_INDENT,
const: DEFAULT_VARIABLE_INDENT
},
outerIIFEBody: null,
FunctionDeclaration: {