Socket
Socket
Sign inDemoInstall

codelyzer

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codelyzer - npm Package Compare versions

Comparing version 4.4.2 to 4.4.3

pipePrefixRule.d.ts

10

angular/metadata.d.ts

@@ -24,3 +24,3 @@ import { RawSourceMap } from 'source-map';

readonly decorator: ts.Decorator;
readonly selector: string;
readonly selector?: string;
constructor(controller: ts.ClassDeclaration, decorator: ts.Decorator, selector?: string);

@@ -31,7 +31,7 @@ }

readonly decorator: ts.Decorator;
readonly selector: string;
readonly animations: (AnimationMetadata | undefined)[];
readonly styles: (StyleMetadata | undefined)[];
readonly template: TemplateMetadata;
readonly selector?: string;
readonly animations?: (AnimationMetadata | undefined)[];
readonly styles?: (StyleMetadata | undefined)[];
readonly template?: TemplateMetadata;
constructor(controller: ts.ClassDeclaration, decorator: ts.Decorator, selector?: string, animations?: (AnimationMetadata | undefined)[], styles?: (StyleMetadata | undefined)[], template?: TemplateMetadata);
}

@@ -8,3 +8,3 @@ import * as ts from 'typescript';

private _fileResolver;
private _urlResolver;
private _urlResolver?;
constructor(_fileResolver: FileResolver, _urlResolver?: AbstractResolver);

@@ -18,3 +18,3 @@ read(d: ts.ClassDeclaration): DirectiveMetadata | undefined;

protected readComponentStylesMetadata(dec: ts.Decorator, external: MetadataUrls): Maybe<(StyleMetadata | undefined)[] | undefined>;
private _resolve(url);
private _resolve;
}

@@ -100,3 +100,3 @@ "use strict";

node: undefined,
style: normalizeTransformed(config_1.Config.transformStyle(style)),
style: normalizeTransformed(config_1.Config.transformStyle(style, url)),
url: url

@@ -103,0 +103,0 @@ }); });

@@ -16,4 +16,4 @@ import * as compiler from '@angular/compiler';

protected _originalOptions: Lint.IOptions;
private _config;
protected _metadataReader: MetadataReader;
private _config?;
protected _metadataReader?: MetadataReader;
constructor(sourceFile: ts.SourceFile, _originalOptions: Lint.IOptions, _config?: NgWalkerConfig, _metadataReader?: MetadataReader);

@@ -20,0 +20,0 @@ visitClassDeclaration(declaration: ts.ClassDeclaration): void;

@@ -15,3 +15,3 @@ import * as ts from 'typescript';

addParentAST(parentAST: any): any;
private getMappedInterval(start, length);
private getMappedInterval;
}

@@ -15,3 +15,3 @@ import { ParseLocation, ParseSourceSpan } from './parseUtil';

Viewport = 10,
Unsupported = 11,
Unsupported = 11
}

@@ -18,0 +18,0 @@ export interface CssAstVisitor {

@@ -11,3 +11,3 @@ export declare enum CssTokenType {

Whitespace = 8,
Invalid = 9,
Invalid = 9
}

@@ -28,3 +28,3 @@ export declare enum CssLexerMode {

STYLE_VALUE_FUNCTION = 12,
STYLE_CALC_FUNCTION = 13,
STYLE_CALC_FUNCTION = 13
}

@@ -31,0 +31,0 @@ export declare class LexedCssResult {

@@ -28,3 +28,3 @@ export declare class ParseLocation {

WARNING = 0,
ERROR = 1,
ERROR = 1
}

@@ -31,0 +31,0 @@ export declare class ParseError {

@@ -28,12 +28,12 @@ "use strict";

switch (binding.type) {
case ast.PropertyBindingType.Animation:
case 4:
subBindingLen = 'animate'.length + 1;
break;
case ast.PropertyBindingType.Attribute:
case 1:
subBindingLen = 'attr'.length + 1;
break;
case ast.PropertyBindingType.Class:
case 2:
subBindingLen = 'class'.length + 1;
break;
case ast.PropertyBindingType.Style:
case 3:
subBindingLen = 'style'.length + 1;

@@ -40,0 +40,0 @@ break;

@@ -8,3 +8,3 @@ import * as ts from 'typescript';

resolve(d: ts.Decorator): MetadataUrls;
private getProgramFilePath(d);
private getProgramFilePath;
}

@@ -51,4 +51,3 @@ "use strict";

description: 'Component selectors should follow given naming rules.',
descriptionDetails: 'See more at https://angular.io/styleguide#style-02-07, https://angular.io/styleguide#style-05-02, ' +
'and https://angular.io/styleguide#style-05-03.',
descriptionDetails: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n See more at https://angular.io/styleguide#style-02-07, https://angular.io/styleguide#style-05-02,\n and https://angular.io/styleguide#style-05-03.\n "], ["\n See more at https://angular.io/styleguide#style-02-07, https://angular.io/styleguide#style-05-02,\n and https://angular.io/styleguide#style-05-03.\n "]))),
optionExamples: [

@@ -85,4 +84,4 @@ [true, OPTION_ELEMENT, 'my-prefix', OPTION_KEBAB_CASE],

},
optionsDescription: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Options accept three obligatory items as an array:\n 1. `", "` or `", "` forces components either to be elements or attributes.\n 2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.\n 3. `", "` or `", "` allows you to pick a case.\n "], ["\n Options accept three obligatory items as an array:\n 1. \\`", "\\` or \\`", "\\` forces components either to be elements or attributes.\n 2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.\n 3. \\`", "\\` or \\`", "\\` allows you to pick a case.\n "])), OPTION_ELEMENT, OPTION_ATTRIBUTE, OPTION_KEBAB_CASE, OPTION_CAMEL_CASE),
rationale: lib_1.Utils.dedent(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n * Consistent conventions make it easy to quickly identify and reference assets of different types.\n * Makes it easier to promote and share the component in other apps.\n * Components are easy to identify in the DOM.\n * Keeps the element names consistent with the specification for Custom Elements.\n * Components have templates containing HTML and optional Angular template syntax.\n * They display content. Developers place components on the page as they would native HTML elements and WebComponents.\n * It is easier to recognize that a symbol is a component by looking at the template's HTML.\n "], ["\n * Consistent conventions make it easy to quickly identify and reference assets of different types.\n * Makes it easier to promote and share the component in other apps.\n * Components are easy to identify in the DOM.\n * Keeps the element names consistent with the specification for Custom Elements.\n * Components have templates containing HTML and optional Angular template syntax.\n * They display content. Developers place components on the page as they would native HTML elements and WebComponents.\n * It is easier to recognize that a symbol is a component by looking at the template's HTML.\n "]))),
optionsDescription: lib_1.Utils.dedent(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n Options accept three obligatory items as an array:\n 1. `", "` or `", "` forces components either to be elements or attributes.\n 2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.\n 3. `", "` or `", "` allows you to pick a case.\n "], ["\n Options accept three obligatory items as an array:\n 1. \\`", "\\` or \\`", "\\` forces components either to be elements or attributes.\n 2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.\n 3. \\`", "\\` or \\`", "\\` allows you to pick a case.\n "])), OPTION_ELEMENT, OPTION_ATTRIBUTE, OPTION_KEBAB_CASE, OPTION_CAMEL_CASE),
rationale: lib_1.Utils.dedent(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n * Consistent conventions make it easy to quickly identify and reference assets of different types.\n * Makes it easier to promote and share the component in other apps.\n * Components are easy to identify in the DOM.\n * Keeps the element names consistent with the specification for Custom Elements.\n * Components have templates containing HTML and optional Angular template syntax.\n * They display content. Developers place components on the page as they would native HTML elements and WebComponents.\n * It is easier to recognize that a symbol is a component by looking at the template's HTML.\n "], ["\n * Consistent conventions make it easy to quickly identify and reference assets of different types.\n * Makes it easier to promote and share the component in other apps.\n * Components are easy to identify in the DOM.\n * Keeps the element names consistent with the specification for Custom Elements.\n * Components have templates containing HTML and optional Angular template syntax.\n * They display content. Developers place components on the page as they would native HTML elements and WebComponents.\n * It is easier to recognize that a symbol is a component by looking at the template's HTML.\n "]))),
ruleName: 'component-selector',

@@ -95,2 +94,2 @@ type: 'style',

exports.Rule = Rule;
var templateObject_1, templateObject_2;
var templateObject_1, templateObject_2, templateObject_3;

@@ -21,3 +21,3 @@ import * as Lint from 'tslint';

protected visitNgPipe(controller: ts.ClassDeclaration, decorator: ts.Decorator): void;
private generateFailure(method, ...failureConfig);
private generateFailure;
}

@@ -33,5 +33,3 @@ "use strict";

};
Rule.FAILURE_STRING = 'In the class "%s" which have the "%s" decorator, the ' +
'"%s" hook method is not allowed. ' +
'Please, drop it.';
Rule.FAILURE_STRING = 'In the class "%s" which have the "%s" decorator, the "%s" hook method is not allowed. Please, drop it.';
return Rule;

@@ -38,0 +36,0 @@ }(Lint.Rules.AbstractRule));

@@ -25,3 +25,3 @@ import * as Lint from 'tslint';

protected visitNgViewChildren(property: ts.PropertyDeclaration, input: ts.Decorator, args: string[]): void;
private generateFailure(property, ...failureConfig);
private generateFailure;
}

@@ -33,5 +33,3 @@ "use strict";

};
Rule.FAILURE_STRING = 'In the class "%s" which have the "%s" decorator, the ' +
'"%s" decorator is not allowed. ' +
'Please, drop it.';
Rule.FAILURE_STRING = 'In the class "%s" which have the "%s" decorator, the "%s" decorator is not allowed. Please, drop it.';
return Rule;

@@ -38,0 +36,0 @@ }(Lint.Rules.AbstractRule));

@@ -27,2 +27,3 @@ export { Rule as AngularWhitespaceRule } from './angularWhitespaceRule';

export { Rule as PipeNamingRule } from './pipeNamingRule';
export { Rule as PipePrefixRule } from './pipePrefixRule';
export { Rule as PreferInlineDecorator } from './preferInlineDecoratorRule';

@@ -29,0 +30,0 @@ export { Rule as PreferOutputReadonlyRule } from './preferOutputReadonlyRule';

@@ -58,2 +58,4 @@ "use strict";

exports.PipeNamingRule = pipeNamingRule_1.Rule;
var pipePrefixRule_1 = require("./pipePrefixRule");
exports.PipePrefixRule = pipePrefixRule_1.Rule;
var preferInlineDecoratorRule_1 = require("./preferInlineDecoratorRule");

@@ -60,0 +62,0 @@ exports.PreferInlineDecorator = preferInlineDecoratorRule_1.Rule;

@@ -25,10 +25,10 @@ import { IOptions, IRuleMetadata, RuleFailure, Rules } from 'tslint/lib';

protected visitNgComponent(metadata: ComponentMetadata): void;
private getLinesCount(source);
private getInlineAnimationsLinesCount(metadata);
private validateInlineAnimations(metadata);
private getInlineStylesLinesCount(metadata);
private validateInlineStyles(metadata);
private getTemplateLinesCount(metadata);
private hasInlineTemplate(metadata);
private validateInlineTemplate(metadata);
private getLinesCount;
private getInlineAnimationsLinesCount;
private validateInlineAnimations;
private getInlineStylesLinesCount;
private validateInlineStyles;
private getTemplateLinesCount;
private hasInlineTemplate;
private validateInlineTemplate;
}

@@ -17,2 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var _a, _b;
var sprintf_js_1 = require("sprintf-js");

@@ -169,2 +170,1 @@ var lib_1 = require("tslint/lib");

var templateObject_1;
var _a, _b;

@@ -7,4 +7,4 @@ import * as Lint from 'tslint';

private static readonly walkerBuilder;
private static decoratorIsAttribute(dec);
private static decoratorIsAttribute;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
}

@@ -40,6 +40,3 @@ "use strict";

};
Rule.FAILURE_STRING = 'In the constructor of class "%s",' +
' the parameter "%s" uses the @Attribute decorator, ' +
'which is considered as a bad practice. Please,' +
' consider construction of type "@Input() %s: string"';
Rule.FAILURE_STRING = 'In the constructor of class "%s", the parameter "%s" uses the @Attribute decorator, which is considered as a bad practice. Please, consider construction of type "@Input() %s: string"';
Rule.walkerBuilder = walkerFn_1.all(walkerFn_1.validate(ts.SyntaxKind.Constructor)(function (node) {

@@ -46,0 +43,0 @@ return function_1.Maybe.lift(node.parent)

@@ -10,4 +10,4 @@ import * as Lint from 'tslint';

visitClassDeclaration(node: ts.ClassDeclaration): void;
private validateInterfaces(node);
private validateMethods(node);
private validateInterfaces;
private validateMethods;
}

@@ -12,2 +12,6 @@ "use strict";

})();
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -31,5 +35,3 @@ var sprintf_js_1 = require("sprintf-js");

optionsDescription: 'Not configurable.',
rationale: 'A directive typically should not use both DoCheck and OnChanges to respond ' +
'to changes on the same input, as ngOnChanges will continue to be called when the ' +
'default change detector detects changes.',
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n A directive typically should not use both DoCheck and OnChanges to respond\n to changes on the same input, as ngOnChanges will continue to be called when the\n default change detector detects changes.\n "], ["\n A directive typically should not use both DoCheck and OnChanges to respond\n to changes on the same input, as ngOnChanges will continue to be called when the\n default change detector detects changes.\n "]))),
ruleName: 'no-conflicting-life-cycle-hooks',

@@ -80,1 +82,2 @@ type: 'maintainability',

exports.ClassMetadataWalker = ClassMetadataWalker;
var templateObject_1;

@@ -11,3 +11,3 @@ import { IRuleMetadata, RuleFailure, Rules, RuleWalker } from 'tslint/lib';

visitCallExpression(node: CallExpression): void;
private validateCallExpression(callExpression);
private validateCallExpression;
}

@@ -15,4 +15,4 @@ import * as Lint from 'tslint';

protected visitNgInput(property: ts.PropertyDeclaration, input: ts.Decorator, args: string[]): void;
private canPropertyBeAliased(propertyAlias, propertyName);
private validateInput(property, input, args);
private canPropertyBeAliased;
private validateInput;
}

@@ -12,2 +12,6 @@ "use strict";

})();
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -36,5 +40,3 @@ var sprintf_js_1 = require("sprintf-js");

};
Rule.FAILURE_STRING = 'In the class "%s", the directive input property "%s" should not be renamed. ' +
'However, you should use an alias when the directive name is also an input property, and the directive name' +
" doesn't describe the property. In this last case, you can disable this rule with `tslint:disable-next-line:no-input-rename`.";
Rule.FAILURE_STRING = Lint.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n In the class \"%s\", the directive input property \"%s\" should not be renamed.\n However, you should use an alias when the directive name is also an input property, and the directive name\n doesn't describe the property. In this last case, you can disable this rule with `tslint:disable-next-line:no-input-rename`.\n "], ["\n In the class \"%s\", the directive input property \"%s\" should not be renamed.\n However, you should use an alias when the directive name is also an input property, and the directive name\n doesn't describe the property. In this last case, you can disable this rule with \\`tslint:disable-next-line:no-input-rename\\`.\n "])));
return Rule;

@@ -113,1 +115,2 @@ }(Lint.Rules.AbstractRule));

exports.InputMetadataWalker = InputMetadataWalker;
var templateObject_1;

@@ -13,3 +13,3 @@ import * as Lint from 'tslint';

visitCallExpression(node: ts.CallExpression): void;
private validateCallExpression(node);
private validateCallExpression;
}

@@ -12,3 +12,3 @@ import * as Lint from 'tslint';

protected visitNgOutput(property: ts.PropertyDeclaration, output: ts.Decorator, args: string[]): void;
private validateOutput(property, args);
private validateOutput;
}

@@ -15,4 +15,4 @@ import { IRuleMetadata, RuleFailure, Rules } from 'tslint/lib';

protected visitNgOutput(property: PropertyDeclaration, output: Decorator, args: string[]): void;
private canPropertyBeAliased(propertyAlias, propertyName);
private validateOutput(property, output, args);
private canPropertyBeAliased;
private validateOutput;
}

@@ -12,3 +12,8 @@ "use strict";

})();
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });
var lib_1 = require("tslint/lib");
var propertyDecoratorBase_1 = require("./propertyDecoratorBase");

@@ -25,10 +30,6 @@ var Rule = (function (_super) {

Rule.metadata = {
description: 'Use @ContentChild, @ContentChildren, @ViewChild or @ViewChildren instead of the `queries` property of ' +
'`@Component` or `@Directive` metadata.',
description: 'Use @ContentChild, @ContentChildren, @ViewChild or @ViewChildren instead of the `queries` property of `@Component` or `@Directive` metadata.',
options: null,
optionsDescription: 'Not configurable.',
rationale: 'The property associated with `@ContentChild`, `@ContentChildren`, `@ViewChild` or `@ViewChildren` ' +
"can be modified only in a single place: in the directive's class. If you use the `queries` metadata " +
'property, you must modify both the property declaration inside the controller, and the metadata ' +
'associated with the directive.',
rationale: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n The property associated with @ContentChild, @ContentChildren, @ViewChild or @ViewChildren\n can be modified only in a single place: in the directive's class. If you use the queries metadata\n property, you must modify both the property declaration inside the controller, and the metadata\n associated with the directive.\n "], ["\n The property associated with @ContentChild, @ContentChildren, @ViewChild or @ViewChildren\n can be modified only in a single place: in the directive's class. If you use the queries metadata\n property, you must modify both the property declaration inside the controller, and the metadata\n associated with the directive.\n "]))),
ruleName: 'no-queries-parameter',

@@ -42,1 +43,2 @@ type: 'style',

exports.Rule = Rule;
var templateObject_1;

@@ -14,3 +14,3 @@ import * as Lint from 'tslint';

protected visitNgStyleHelper(style: CssAst, context: ComponentMetadata, styleMetadata: StyleMetadata, baseStart: number): void;
private validateStyles(style, context, styleMetadata, baseStart);
private validateStyles;
}

@@ -45,3 +45,3 @@ "use strict";

var classBindings = (node.inputs || [])
.filter(function (b) { return b.type === compiler_1.PropertyBindingType.Class; })
.filter(function (b) { return b.type === 2; })
.map(function (b) { return b.name; })

@@ -91,3 +91,3 @@ .join(' ');

attribute: function (ast) {
return (ast.inputs || []).some(function (i) { return i.type === compiler_1.PropertyBindingType.Attribute; });
return (ast.inputs || []).some(function (i) { return i.type === 1; });
},

@@ -94,0 +94,0 @@ class: function (ast) {

{
"name": "codelyzer",
"version": "4.4.2",
"version": "4.4.3",
"description": "Linting for Angular applications, following angular.io/styleguide.",

@@ -50,3 +50,3 @@ "main": "index.js",

"dependencies": {
"app-root-path": "^2.0.1",
"app-root-path": "^2.1.0",
"css-selector-tokenizer": "^0.7.0",

@@ -53,0 +53,0 @@ "cssauron": "^1.4.0",

@@ -11,3 +11,3 @@ import * as Lint from 'tslint';

protected visitNgPipe(controller: ts.ClassDeclaration, decorator: ts.Decorator): void;
private validatePipe(className, decorator);
private validatePipe;
}

@@ -22,5 +22,5 @@ import * as Lint from 'tslint';

protected visitNgPipe(controller: ts.ClassDeclaration, decorator: ts.Decorator): void;
private validateProperties(className, pipe);
private validateProperty(className, property);
private getFailureMessage(className, pipeName);
private validateProperties;
private validateProperty;
private getFailureMessage;
}

@@ -60,3 +60,3 @@ "use strict";

Rule.metadata = {
deprecationMessage: "You can name your pipes only " + OPTION_CAMEL_CASE + ". If you try to use snake-case then your application will not compile.",
deprecationMessage: "You can name your pipes only " + OPTION_CAMEL_CASE + ". If you try to use snake-case then your application will not compile. For prefix validation use pipe-prefix rule.",
description: 'Enforce consistent case and prefix for pipes.',

@@ -63,0 +63,0 @@ optionExamples: [

@@ -17,3 +17,3 @@ import { IOptions, IRuleMetadata, RuleFailure, Rules } from 'tslint/lib';

protected visitPropertyDecorator(decorator: Decorator): void;
private validateDecorator(decorator, property);
private validateDecorator;
}

@@ -11,3 +11,3 @@ import { IRuleMetadata, RuleFailure, Rules } from 'tslint/lib';

protected visitNgOutput(property: PropertyDeclaration, output: Decorator, args: string[]): void;
private validateOutput(property);
private validateOutput;
}

@@ -20,3 +20,3 @@ import * as compiler from '@angular/compiler';

abstract getPrefixFailure(prefixes: string[]): string;
private getValidSelectors(selectors);
private getValidSelectors;
}

@@ -27,6 +27,6 @@ export declare class SelectorValidatorWalker extends Lint.RuleWalker {

visitClassDeclaration(node: ts.ClassDeclaration): void;
private validateDecorator(className, decorator);
private validateSelector(className, arg);
private validateProperty(p);
private extractMainSelector(expression);
private validateDecorator;
private validateSelector;
private validateProperty;
private extractMainSelector;
}

@@ -5,4 +5,4 @@ import { IRuleMetadata, RuleFailure, Rules } from 'tslint/lib';

static readonly metadata: IRuleMetadata;
static readonly DEFAULT_MAX_COMPLEXITY: number;
static readonly FAILURE_STRING: string;
static readonly DEFAULT_MAX_COMPLEXITY: number;
apply(sourceFile: SourceFile): RuleFailure[];

@@ -9,0 +9,0 @@ isEnabled(): boolean;

@@ -50,4 +50,4 @@ "use strict";

};
Rule.DEFAULT_MAX_COMPLEXITY = 3;
Rule.FAILURE_STRING = "The condition complexity (cost '%s') exceeded the defined limit (cost '%s'). The conditional expression should be moved into the component.";
Rule.DEFAULT_MAX_COMPLEXITY = 3;
return Rule;

@@ -54,0 +54,0 @@ }(lib_1.Rules.AbstractRule));

@@ -1,6 +0,8 @@

import * as Lint from 'tslint';
import * as ts from 'typescript';
export declare class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[];
import { IRuleMetadata, RuleFailure, Rules } from 'tslint/lib';
import { SourceFile } from 'typescript';
export declare class Rule extends Rules.AbstractRule {
static readonly metadata: IRuleMetadata;
static readonly FAILURE_STRING_NEGATED_PIPE: string;
static readonly FAILURE_STRING_UNSTRICT_EQUALITY: string;
apply(sourceFile: SourceFile): RuleFailure[];
}

@@ -12,8 +12,15 @@ "use strict";

})();
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });
var Lint = require("tslint");
var compiler_1 = require("@angular/compiler");
var lib_1 = require("tslint/lib");
var ngWalker_1 = require("./angular/ngWalker");
var recursiveAngularExpressionVisitor_1 = require("./angular/templates/recursiveAngularExpressionVisitor");
var ast = require("@angular/compiler");
var unstrictEqualityOperator = '==';
var isAsyncBinding = function (ast) {
return ast instanceof compiler_1.BindingPipe && ast.name === 'async';
};
var TemplateToNgTemplateVisitor = (function (_super) {

@@ -24,32 +31,27 @@ __extends(TemplateToNgTemplateVisitor, _super);

}
TemplateToNgTemplateVisitor.prototype.visitBinary = function (expr, context) {
if (!this.isAsyncBinding(expr.left)) {
return _super.prototype.visitBinary.call(this, expr, context);
TemplateToNgTemplateVisitor.prototype.visitBinary = function (ast, context) {
this.validateBinary(ast);
_super.prototype.visitBinary.call(this, ast, context);
};
TemplateToNgTemplateVisitor.prototype.visitPrefixNot = function (ast, context) {
this.validatePrefixNot(ast);
_super.prototype.visitPrefixNot.call(this, ast, context);
};
TemplateToNgTemplateVisitor.prototype.validateBinary = function (ast) {
var left = ast.left, operation = ast.operation, right = ast.right;
if (!isAsyncBinding(left) || !(right instanceof compiler_1.LiteralPrimitive) || right.value !== false || operation !== unstrictEqualityOperator) {
return;
}
if (!(expr.right instanceof ast.LiteralPrimitive) || expr.right.value !== false || expr.operation !== unstrictEqualityOperator) {
return _super.prototype.visitBinary.call(this, expr, context);
}
var endLeftSpan = expr.left.span.end, startRightSpan = expr.right.span.start, _a = expr.span, spanEnd = _a.end, spanStart = _a.start;
var operator = this.codeWithMap.code.slice(endLeftSpan, startRightSpan);
var operatorStart = /^.*==/.exec(operator)[0].length - unstrictEqualityOperator.length;
this.addFailureFromStartToEnd(spanStart, spanEnd, 'Async pipes must use strict equality `===` when comparing with `false`', [
new Lint.Replacement(this.getSourcePosition(endLeftSpan) + operatorStart, unstrictEqualityOperator.length, '===')
]);
_super.prototype.visitBinary.call(this, expr, context);
this.generateFailure(ast, Rule.FAILURE_STRING_UNSTRICT_EQUALITY);
};
TemplateToNgTemplateVisitor.prototype.visitPrefixNot = function (expr, context) {
if (!this.isAsyncBinding(expr.expression)) {
return _super.prototype.visitPrefixNot.call(this, expr, context);
TemplateToNgTemplateVisitor.prototype.validatePrefixNot = function (ast) {
var expression = ast.expression;
if (!isAsyncBinding(expression)) {
return;
}
var _a = expr.span, spanEnd = _a.end, spanStart = _a.start;
var absoluteStart = this.getSourcePosition(spanStart);
var expressionSource = this.codeWithMap.code.slice(spanStart, spanEnd);
var concreteWidth = spanEnd - spanStart - / *$/.exec(expressionSource)[0].length;
this.addFailureFromStartToEnd(spanStart, spanEnd, 'Async pipes can not be negated, use (observable | async) === false instead', [
new Lint.Replacement(absoluteStart + concreteWidth, 1, ' === false '),
new Lint.Replacement(absoluteStart, 1, '')
]);
this.generateFailure(ast, Rule.FAILURE_STRING_NEGATED_PIPE);
};
TemplateToNgTemplateVisitor.prototype.isAsyncBinding = function (expr) {
return expr instanceof ast.BindingPipe && expr.name === 'async';
TemplateToNgTemplateVisitor.prototype.generateFailure = function (ast, errorMessage) {
var _a = ast.span, spanEnd = _a.end, spanStart = _a.start;
this.addFailureFromStartToEnd(spanStart, spanEnd, errorMessage);
};

@@ -69,14 +71,15 @@ return TemplateToNgTemplateVisitor;

Rule.metadata = {
ruleName: 'templates-no-negated-async',
type: 'functionality',
description: 'Ensures that strict equality is used when evaluating negations on async pipe output.',
rationale: 'Async pipe evaluate to `null` before the observable or promise emits, which can lead to layout thrashing as' +
' components load. Prefer strict `=== false` checks instead.',
options: null,
optionsDescription: 'Not configurable.',
typescriptOnly: true,
hasFix: true
rationale: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Async pipe evaluate to `null` before the observable or promise emits, which can lead to layout thrashing as\n components load. Prefer strict `=== false` checks instead.\n "], ["\n Async pipe evaluate to \\`null\\` before the observable or promise emits, which can lead to layout thrashing as\n components load. Prefer strict \\`=== false\\` checks instead.\n "]))),
ruleName: 'templates-no-negated-async',
type: 'functionality',
typescriptOnly: true
};
Rule.FAILURE_STRING_NEGATED_PIPE = 'Async pipes can not be negated, use (observable | async) === false instead';
Rule.FAILURE_STRING_UNSTRICT_EQUALITY = 'Async pipes must use strict equality `===` when comparing with `false`';
return Rule;
}(Lint.Rules.AbstractRule));
}(lib_1.Rules.AbstractRule));
exports.Rule = Rule;
var templateObject_1;

@@ -12,3 +12,8 @@ "use strict";

})();
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });
var lib_1 = require("tslint/lib");
var propertyDecoratorBase_1 = require("./propertyDecoratorBase");

@@ -29,6 +34,3 @@ var Rule = (function (_super) {

optionsDescription: 'Not configurable.',
rationale: 'The property associated with `@HostBinding` or the method associated with `@HostListener` ' +
"can be modified only in a single place: in the directive's class. If you use the `host` metadata " +
'property, you must modify both the property declaration inside the controller, and the metadata ' +
'associated with the directive.',
rationale: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n The property associated with @HostBinding or the method associated with @HostListener\n can be modified only in a single place: in the directive's class. If you use the host metadata\n property, you must modify both the property declaration inside the controller, and the metadata\n associated with the directive.\n "], ["\n The property associated with @HostBinding or the method associated with @HostListener\n can be modified only in a single place: in the directive's class. If you use the host metadata\n property, you must modify both the property declaration inside the controller, and the metadata\n associated with the directive.\n "]))),
ruleName: 'use-host-property-decorator',

@@ -42,1 +44,2 @@ type: 'style',

exports.Rule = Rule;
var templateObject_1;

@@ -33,3 +33,3 @@ "use strict";

optionsDescription: 'Not configurable.',
rationale: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n * It is easier and more readable to identify which properties in a class are inputs.\n * If you ever need to rename the property name associated with `@Input`, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an input.\n "], ["\n * It is easier and more readable to identify which properties in a class are inputs.\n * If you ever need to rename the property name associated with \\`@Input\\`, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an input.\n "]))),
rationale: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n * It is easier and more readable to identify which properties in a class are inputs.\n * If you ever need to rename the property name associated with @Input, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an input.\n "], ["\n * It is easier and more readable to identify which properties in a class are inputs.\n * If you ever need to rename the property name associated with @Input, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an input.\n "]))),
ruleName: 'use-input-property-decorator',

@@ -36,0 +36,0 @@ type: 'style',

@@ -12,5 +12,5 @@ import * as Lint from 'tslint';

visitClassDeclaration(node: ts.ClassDeclaration): void;
private extractInterfaces(node);
private validateMethods(methods, interfaces, className);
private isMethodValidHook(methodName, interfaces);
private extractInterfaces;
private validateMethods;
private isMethodValidHook;
}

@@ -79,3 +79,3 @@ "use strict";

var hookName = methodName.slice(2);
_this.addFailureAtNode(name, sprintf_js_1.sprintf(Rule.FAILURE_STRING, hookName, Rule.HOOKS_PREFIX + hookName, className));
_this.addFailureAtNode(name, sprintf_js_1.sprintf(Rule.FAILURE_STRING, hookName, "" + Rule.HOOKS_PREFIX + hookName, className));
}

@@ -82,0 +82,0 @@ });

@@ -33,3 +33,3 @@ "use strict";

optionsDescription: 'Not configurable.',
rationale: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n * It is easier and more readable to identify which properties in a class are events.\n * If you ever need to rename the event name associated with `@Output`, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an output.\n "], ["\n * It is easier and more readable to identify which properties in a class are events.\n * If you ever need to rename the event name associated with \\`@Output\\`, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an output.\n "]))),
rationale: lib_1.Utils.dedent(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n * It is easier and more readable to identify which properties in a class are events.\n * If you ever need to rename the event name associated with @Output, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an output.\n "], ["\n * It is easier and more readable to identify which properties in a class are events.\n * If you ever need to rename the event name associated with @Output, you can modify it in a single place.\n * The metadata declaration attached to the directive is shorter and thus more readable.\n * Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an output.\n "]))),
ruleName: 'use-output-property-decorator',

@@ -36,0 +36,0 @@ type: 'style',

@@ -11,3 +11,3 @@ import { IRuleMetadata, RuleFailure, Rules, RuleWalker } from 'tslint/lib';

visitClassDeclaration(node: ClassDeclaration): void;
private validateClassDeclaration(node);
private validateClassDeclaration;
}

@@ -11,3 +11,3 @@ import { IRuleMetadata, RuleFailure, Rules, RuleWalker } from 'tslint/lib';

visitClassDeclaration(node: ClassDeclaration): void;
private validateClassDeclaration(node);
private validateClassDeclaration;
}

@@ -29,3 +29,2 @@ "use strict";

optionsDescription: 'Not configurable.',
rationale: '',
ruleName: 'use-view-encapsulation',

@@ -32,0 +31,0 @@ type: 'maintainability',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc