Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
91
node_modules/codelyzer/README.md
generated
vendored
Normal file
91
node_modules/codelyzer/README.md
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
# Codelyzer
|
||||
|
||||
[](https://youtu.be/bci-Z6nURgE)
|
||||
|
||||
A set of tslint rules for static code analysis of Angular 2 TypeScript projects.
|
||||
|
||||
You can run the static code analyzer over web apps, NativeScript, Ionic, etc.
|
||||
|
||||
## Install
|
||||
|
||||
`npm install --save-dev codelyzer`
|
||||
|
||||
Then hop to your `tslint.json` and add rulesDirectory which points to codelyzer, like this:
|
||||
```json
|
||||
{
|
||||
"rulesDirectory": [
|
||||
"node_modules/codelyzer"
|
||||
],
|
||||
"rules":{
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now you can apply codelyzer rules to your tslint config. Enjoy!
|
||||
|
||||
## Recommended configuration
|
||||
|
||||
Below you can find a recommended configuration which is based on the [Angular 2 Style Guide](https://angular.io/styleguide).
|
||||
|
||||
```json
|
||||
{
|
||||
"directive-selector-name": [true, "camelCase"],
|
||||
"component-selector-name": [true, "kebab-case"],
|
||||
"directive-selector-type": [true, "attribute"],
|
||||
"component-selector-type": [true, "element"],
|
||||
"directive-selector-prefix": [true, "sg"],
|
||||
"component-selector-prefix": [true, "sg"],
|
||||
"use-input-property-decorator": true,
|
||||
"use-output-property-decorator": true,
|
||||
"use-host-property-decorator": true,
|
||||
"no-attribute-parameter-decorator": true,
|
||||
"no-input-rename": true,
|
||||
"no-output-rename": true,
|
||||
"no-forward-ref" :true,
|
||||
"use-life-cycle-interface": true,
|
||||
"use-pipe-transform-interface": true,
|
||||
"pipe-naming": [true, "camelCase", "sg"],
|
||||
"component-class-suffix": true,
|
||||
"directive-class-suffix": true,
|
||||
"import-destructuring-spacing": true
|
||||
}
|
||||
```
|
||||
|
||||
## Roadmap
|
||||
|
||||
- [x] Directive selector type.
|
||||
- [x] Directive selector name convention.
|
||||
- [x] Directive selector name prefix.
|
||||
- [x] Component selector type.
|
||||
- [x] Component selector name convention.
|
||||
- [x] Component selector name prefix.
|
||||
- [x] Use `@Input` instead of `inputs` decorator property.
|
||||
- [x] Use `@Output` instead of `outputs` decorator property.
|
||||
- [x] Use `@HostListeners` and `@HostBindings` instead of `host` decorator property.
|
||||
- [x] Implement life-cycle hooks explicitly.
|
||||
- [x] Implement Pipe transform interface for pipes.
|
||||
- [x] Proper naming for pipes (kebab-case, optionally prefixed).
|
||||
- [x] Do not rename outputs.
|
||||
- [x] Do not rename inputs.
|
||||
- [x] Do not use `forwardRef`.
|
||||
- [x] Do not use the `@Attribute` decorator.
|
||||
- [x] Proper naming of directives and components (name plus `(Directive|Component)` suffix).
|
||||
- [ ] Do not use `nativeElement` injected with `ElementRef`.
|
||||
- [ ] Externalize template above *n* lines of code.
|
||||
- [ ] Rise a warning for impure pipes.
|
||||
- [ ] Do not declare global providers.
|
||||
- [ ] Follow convention for naming the routes.
|
||||
- [ ] Use `@Injectable` instead of `@Inject`.
|
||||
- [ ] Single export per module, except facade modules.
|
||||
- [ ] Proper naming of modules (kebab-case followed by module type followed by extension for regular modules, module name plus extension name for facades).
|
||||
- [ ] Verify if used directive is declared in the current component or any parent component.
|
||||
- [ ] Verify that property or method used in the template exists in the current context.
|
||||
- [ ] Locate component templates in the same directory.
|
||||
- [ ] Locate tests in the same directory (rise optional warning when no test file is found).
|
||||
- [ ] Rise warning on complex logic inside of the templates.
|
||||
- [ ] Do not manipulate elements referenced within the template.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
39
node_modules/codelyzer/componentClassSuffixRule.js
generated
vendored
Normal file
39
node_modules/codelyzer/componentClassSuffixRule.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var ng2Walker_1 = require("./util/ng2Walker");
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ClassMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.validate = function (className) {
|
||||
return /.*Component$/.test(className);
|
||||
};
|
||||
Rule.FAILURE = "The name of the class %s should end with the suffix Component (https://goo.gl/5X1TE7)";
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ClassMetadataWalker = (function (_super) {
|
||||
__extends(ClassMetadataWalker, _super);
|
||||
function ClassMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
ClassMetadataWalker.prototype.visitNg2Component = function (controller, decorator) {
|
||||
var name = controller.name;
|
||||
var className = name.text;
|
||||
if (!Rule.validate(className)) {
|
||||
this.addFailure(this.createFailure(name.getStart(), name.getWidth(), sprintf_js_1.sprintf.apply(this, [Rule.FAILURE, className])));
|
||||
}
|
||||
};
|
||||
return ClassMetadataWalker;
|
||||
}(ng2Walker_1.Ng2Walker));
|
||||
exports.ClassMetadataWalker = ClassMetadataWalker;
|
21
node_modules/codelyzer/componentSelectorNameRule.js
generated
vendored
Normal file
21
node_modules/codelyzer/componentSelectorNameRule.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var selectorNameBase_1 = require('./selectorNameBase');
|
||||
var selectorValidator_1 = require('./util/selectorValidator');
|
||||
var FAILURE_STRING = 'The selector of the component "%s" should be named %s (https://goo.gl/mBg67Z)';
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
var validator = selectorValidator_1.SelectorValidator.camelCase;
|
||||
if (value[1] === 'kebab-case') {
|
||||
validator = selectorValidator_1.SelectorValidator.kebabCase;
|
||||
}
|
||||
_super.call(this, ruleName, value, disabledIntervals, validator, FAILURE_STRING, selectorNameBase_1.COMPONENT_TYPE.COMPONENT);
|
||||
}
|
||||
return Rule;
|
||||
}(selectorNameBase_1.SelectorRule));
|
||||
exports.Rule = Rule;
|
20
node_modules/codelyzer/componentSelectorPrefixRule.js
generated
vendored
Normal file
20
node_modules/codelyzer/componentSelectorPrefixRule.js
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var selectorNameBase_1 = require('./selectorNameBase');
|
||||
var selectorValidator_1 = require('./util/selectorValidator');
|
||||
var FAILURE_SINGLE = 'The selector of the component "%s" should have prefix "%s" (https://goo.gl/cix8BY)';
|
||||
var FAILURE_MANY = 'The selector of the component "%s" should have one of the prefixes: %s (https://goo.gl/cix8BY)';
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
var prefixExpression = (value.slice(1) || []).join('|');
|
||||
var FAIL_MESSAGE = value.length > 2 ? FAILURE_MANY : FAILURE_SINGLE;
|
||||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator.multiPrefix(prefixExpression), FAIL_MESSAGE, selectorNameBase_1.COMPONENT_TYPE.COMPONENT);
|
||||
}
|
||||
return Rule;
|
||||
}(selectorNameBase_1.SelectorRule));
|
||||
exports.Rule = Rule;
|
17
node_modules/codelyzer/componentSelectorTypeRule.js
generated
vendored
Normal file
17
node_modules/codelyzer/componentSelectorTypeRule.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var selectorNameBase_1 = require('./selectorNameBase');
|
||||
var selectorValidator_1 = require('./util/selectorValidator');
|
||||
var FAILURE_STRING = 'The selector of the component "%s" should be used as %s (https://goo.gl/llsqKR)';
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator[value[1]], FAILURE_STRING, selectorNameBase_1.COMPONENT_TYPE.COMPONENT);
|
||||
}
|
||||
return Rule;
|
||||
}(selectorNameBase_1.SelectorRule));
|
||||
exports.Rule = Rule;
|
39
node_modules/codelyzer/directiveClassSuffixRule.js
generated
vendored
Normal file
39
node_modules/codelyzer/directiveClassSuffixRule.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var ng2Walker_1 = require("./util/ng2Walker");
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ClassMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.validate = function (className) {
|
||||
return /.*Directive/.test(className);
|
||||
};
|
||||
Rule.FAILURE = "The name of the class %s should end with the suffix Directive (https://goo.gl/5X1TE7)";
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ClassMetadataWalker = (function (_super) {
|
||||
__extends(ClassMetadataWalker, _super);
|
||||
function ClassMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
ClassMetadataWalker.prototype.visitNg2Directive = function (controller, decorator) {
|
||||
var name = controller.name;
|
||||
var className = name.text;
|
||||
if (!Rule.validate(className)) {
|
||||
this.addFailure(this.createFailure(name.getStart(), name.getWidth(), sprintf_js_1.sprintf.apply(this, [Rule.FAILURE, className])));
|
||||
}
|
||||
};
|
||||
return ClassMetadataWalker;
|
||||
}(ng2Walker_1.Ng2Walker));
|
||||
exports.ClassMetadataWalker = ClassMetadataWalker;
|
21
node_modules/codelyzer/directiveSelectorNameRule.js
generated
vendored
Normal file
21
node_modules/codelyzer/directiveSelectorNameRule.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var selectorNameBase_1 = require('./selectorNameBase');
|
||||
var selectorValidator_1 = require('./util/selectorValidator');
|
||||
var FAILURE_STRING = 'The selector of the directive "%s" should be named %s (https://goo.gl/QS8kEs)';
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
var validator = selectorValidator_1.SelectorValidator.camelCase;
|
||||
if (value[1] === 'kebab-case') {
|
||||
validator = selectorValidator_1.SelectorValidator.kebabCase;
|
||||
}
|
||||
_super.call(this, ruleName, value, disabledIntervals, validator, FAILURE_STRING, selectorNameBase_1.COMPONENT_TYPE.DIRECTIVE);
|
||||
}
|
||||
return Rule;
|
||||
}(selectorNameBase_1.SelectorRule));
|
||||
exports.Rule = Rule;
|
20
node_modules/codelyzer/directiveSelectorPrefixRule.js
generated
vendored
Normal file
20
node_modules/codelyzer/directiveSelectorPrefixRule.js
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var selectorNameBase_1 = require('./selectorNameBase');
|
||||
var selectorValidator_1 = require('./util/selectorValidator');
|
||||
var FAILURE_SINGLE = 'The selector of the directive "%s" should have prefix "%s" (https://goo.gl/uacjKR)';
|
||||
var FAILURE_MANY = 'The selector of the directive "%s" should have one of the prefixes: %s (https://goo.gl/uacjKR)';
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
var prefixExpression = (value.slice(1) || []).join('|');
|
||||
var FAIL_MESSAGE = value.length > 2 ? FAILURE_MANY : FAILURE_SINGLE;
|
||||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator.multiPrefix(prefixExpression), FAIL_MESSAGE, selectorNameBase_1.COMPONENT_TYPE.DIRECTIVE);
|
||||
}
|
||||
return Rule;
|
||||
}(selectorNameBase_1.SelectorRule));
|
||||
exports.Rule = Rule;
|
17
node_modules/codelyzer/directiveSelectorTypeRule.js
generated
vendored
Normal file
17
node_modules/codelyzer/directiveSelectorTypeRule.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var selectorNameBase_1 = require('./selectorNameBase');
|
||||
var selectorValidator_1 = require('./util/selectorValidator');
|
||||
var FAILURE_STRING = 'The selector of the directive "%s" should be used as %s (https://goo.gl/QS8kEs)';
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
_super.call(this, ruleName, value, disabledIntervals, selectorValidator_1.SelectorValidator[value[1]], FAILURE_STRING, selectorNameBase_1.COMPONENT_TYPE.DIRECTIVE);
|
||||
}
|
||||
return Rule;
|
||||
}(selectorNameBase_1.SelectorRule));
|
||||
exports.Rule = Rule;
|
44
node_modules/codelyzer/importDestructuringSpacingRule.js
generated
vendored
Normal file
44
node_modules/codelyzer/importDestructuringSpacingRule.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var ts = require('typescript');
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ImportDestructuringSpacingWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.FAILURE_STRING = 'You need to leave whitespaces inside of the import statement\'s curly braces (https://goo.gl/25R7qr)';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ImportDestructuringSpacingWalker = (function (_super) {
|
||||
__extends(ImportDestructuringSpacingWalker, _super);
|
||||
function ImportDestructuringSpacingWalker(sourceFile, options) {
|
||||
_super.call(this, sourceFile, options);
|
||||
this.scanner = ts.createScanner(ts.ScriptTarget.ES5, false, ts.LanguageVariant.Standard, sourceFile.text);
|
||||
}
|
||||
ImportDestructuringSpacingWalker.prototype.visitImportDeclaration = function (node) {
|
||||
var importClause = node.importClause;
|
||||
if (importClause != null && importClause.namedBindings != null) {
|
||||
var text = importClause.namedBindings.getText();
|
||||
if (!this.checkForWhiteSpace(text)) {
|
||||
this.addFailure(this.createFailure(importClause.namedBindings.getStart(), importClause.namedBindings.getWidth(), Rule.FAILURE_STRING));
|
||||
}
|
||||
}
|
||||
_super.prototype.visitImportDeclaration.call(this, node);
|
||||
};
|
||||
ImportDestructuringSpacingWalker.prototype.checkForWhiteSpace = function (text) {
|
||||
if (/\s*\*\s+as\s+[^\s]/.test(text)) {
|
||||
return true;
|
||||
}
|
||||
return /{\s[^]*\s}/.test(text);
|
||||
};
|
||||
return ImportDestructuringSpacingWalker;
|
||||
}(Lint.SkippableTokenAwareRuleWalker));
|
61
node_modules/codelyzer/noAttributeParameterDecoratorRule.js
generated
vendored
Normal file
61
node_modules/codelyzer/noAttributeParameterDecoratorRule.js
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ConstructorMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
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"';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ConstructorMetadataWalker = (function (_super) {
|
||||
__extends(ConstructorMetadataWalker, _super);
|
||||
function ConstructorMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
ConstructorMetadataWalker.prototype.visitConstructorDeclaration = function (node) {
|
||||
var syntaxKind = SyntaxKind.current();
|
||||
var parentName = "";
|
||||
var parent = node.parent;
|
||||
if (parent.kind === syntaxKind.ClassExpression) {
|
||||
parentName = parent.parent.name.text;
|
||||
}
|
||||
else if (parent.kind = syntaxKind.ClassDeclaration) {
|
||||
parentName = parent.name.text;
|
||||
}
|
||||
(node.parameters || []).forEach(this.validateParameter.bind(this, parentName));
|
||||
_super.prototype.visitConstructorDeclaration.call(this, node);
|
||||
};
|
||||
ConstructorMetadataWalker.prototype.validateParameter = function (className, parameter) {
|
||||
var _this = this;
|
||||
var parameterName = parameter.name.text;
|
||||
if (parameter.decorators) {
|
||||
parameter.decorators.forEach(function (decorator) {
|
||||
var baseExpr = decorator.expression || {};
|
||||
var expr = baseExpr.expression || {};
|
||||
var name = expr.text;
|
||||
if (name == 'Attribute') {
|
||||
var failureConfig = [className, parameterName, parameterName];
|
||||
failureConfig.unshift(Rule.FAILURE_STRING);
|
||||
_this.addFailure(_this.createFailure(parameter.getStart(), parameter.getWidth(), sprintf_js_1.sprintf.apply(_this, failureConfig)));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return ConstructorMetadataWalker;
|
||||
}(Lint.RuleWalker));
|
||||
exports.ConstructorMetadataWalker = ConstructorMetadataWalker;
|
50
node_modules/codelyzer/noForwardRefRule.js
generated
vendored
Normal file
50
node_modules/codelyzer/noForwardRefRule.js
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ExpressionCallMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.FAILURE_IN_CLASS = 'Avoid using forwardRef in class "%s"';
|
||||
Rule.FAILURE_IN_VARIABLE = 'Avoid using forwardRef in variable "%s"';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ExpressionCallMetadataWalker = (function (_super) {
|
||||
__extends(ExpressionCallMetadataWalker, _super);
|
||||
function ExpressionCallMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
ExpressionCallMetadataWalker.prototype.visitCallExpression = function (node) {
|
||||
this.validateCallExpression(node);
|
||||
_super.prototype.visitCallExpression.call(this, node);
|
||||
};
|
||||
ExpressionCallMetadataWalker.prototype.validateCallExpression = function (callExpression) {
|
||||
if (callExpression.expression.text === 'forwardRef') {
|
||||
var currentNode = callExpression;
|
||||
while (currentNode.parent.parent) {
|
||||
currentNode = currentNode.parent;
|
||||
}
|
||||
var failureConfig = [];
|
||||
if (currentNode.kind === SyntaxKind.current().VariableStatement) {
|
||||
failureConfig = [Rule.FAILURE_IN_VARIABLE, currentNode.declarationList.declarations[0].name.text];
|
||||
}
|
||||
else {
|
||||
failureConfig = [Rule.FAILURE_IN_CLASS, currentNode.name.text];
|
||||
}
|
||||
this.addFailure(this.createFailure(callExpression.getStart(), callExpression.getWidth(), sprintf_js_1.sprintf.apply(this, failureConfig)));
|
||||
}
|
||||
};
|
||||
return ExpressionCallMetadataWalker;
|
||||
}(Lint.RuleWalker));
|
||||
exports.ExpressionCallMetadataWalker = ExpressionCallMetadataWalker;
|
40
node_modules/codelyzer/noInputRenameRule.js
generated
vendored
Normal file
40
node_modules/codelyzer/noInputRenameRule.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var ng2Walker_1 = require("./util/ng2Walker");
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new InputMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.FAILURE_STRING = 'In the class "%s", the directive ' +
|
||||
'input property "%s" should not be renamed.' +
|
||||
'Please, consider the following use "@Input() %s: string"';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var InputMetadataWalker = (function (_super) {
|
||||
__extends(InputMetadataWalker, _super);
|
||||
function InputMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
InputMetadataWalker.prototype.visitNg2Input = function (property, input, args) {
|
||||
var className = property.parent.name.text;
|
||||
var memberName = property.name.text;
|
||||
if (args.length != 0 && memberName != args[0]) {
|
||||
var failureConfig = [className, memberName, memberName];
|
||||
failureConfig.unshift(Rule.FAILURE_STRING);
|
||||
this.addFailure(this.createFailure(property.getStart(), property.getWidth(), sprintf_js_1.sprintf.apply(this, failureConfig)));
|
||||
}
|
||||
};
|
||||
return InputMetadataWalker;
|
||||
}(ng2Walker_1.Ng2Walker));
|
||||
exports.InputMetadataWalker = InputMetadataWalker;
|
40
node_modules/codelyzer/noOutputRenameRule.js
generated
vendored
Normal file
40
node_modules/codelyzer/noOutputRenameRule.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var ng2Walker_1 = require("./util/ng2Walker");
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new OutputMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.FAILURE_STRING = 'In the class "%s", the directive output ' +
|
||||
'property "%s" should not be renamed.' +
|
||||
'Please, consider the following use "@Output() %s = new EventEmitter();"';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var OutputMetadataWalker = (function (_super) {
|
||||
__extends(OutputMetadataWalker, _super);
|
||||
function OutputMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
OutputMetadataWalker.prototype.visitNg2Output = function (property, output, args) {
|
||||
var className = property.parent.name.text;
|
||||
var memberName = property.name.text;
|
||||
if (args.length != 0 && memberName != args[0]) {
|
||||
var failureConfig = [className, memberName, memberName];
|
||||
failureConfig.unshift(Rule.FAILURE_STRING);
|
||||
this.addFailure(this.createFailure(property.getStart(), property.getWidth(), sprintf_js_1.sprintf.apply(this, failureConfig)));
|
||||
}
|
||||
};
|
||||
return OutputMetadataWalker;
|
||||
}(ng2Walker_1.Ng2Walker));
|
||||
exports.OutputMetadataWalker = OutputMetadataWalker;
|
52
node_modules/codelyzer/package.json
generated
vendored
Normal file
52
node_modules/codelyzer/package.json
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"name": "codelyzer",
|
||||
"version": "0.0.28",
|
||||
"description": "A set of linters for Angular 2 applications, following https:/angular.io/styleguide.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"typings": "typings",
|
||||
"release": "rimraf dist && tsc && npm t && cp package.json README.md dist/src && ts-node build/links.ts --src ./dist/src",
|
||||
"test": "rimraf dist && tsc && mocha --compilers ts:ts-node/register",
|
||||
"test:watch": "npm run test -- -w",
|
||||
"tsc": "tsc",
|
||||
"tscw": "tsc -w"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mgechev/codelyzer.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Angular",
|
||||
"2",
|
||||
"style",
|
||||
"guide",
|
||||
"ng2lint",
|
||||
"lint",
|
||||
"tslint"
|
||||
],
|
||||
"author": {
|
||||
"name": "Minko Gechev",
|
||||
"email": "mgechev@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mgechev/codelyzer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mgechev/codelyzer#readme",
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"chai-spies": "^0.7.1",
|
||||
"minimalist": "1.0.0",
|
||||
"mocha": "3.0.2",
|
||||
"rimraf": "^2.5.2",
|
||||
"ts-node": "1.2.2",
|
||||
"tslint": "3.14.0",
|
||||
"typings": "1.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"tslint": "^3.9.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"sprintf-js": "^1.0.3"
|
||||
}
|
||||
}
|
60
node_modules/codelyzer/pipeImpureRule.js
generated
vendored
Normal file
60
node_modules/codelyzer/pipeImpureRule.js
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ClassMetadataWalker(sourceFile, this));
|
||||
};
|
||||
Rule.FAILURE = 'Warning: impure pipe declared in class %s.';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ClassMetadataWalker = (function (_super) {
|
||||
__extends(ClassMetadataWalker, _super);
|
||||
function ClassMetadataWalker(sourceFile, rule) {
|
||||
_super.call(this, sourceFile, rule.getOptions());
|
||||
this.rule = rule;
|
||||
}
|
||||
ClassMetadataWalker.prototype.visitClassDeclaration = function (node) {
|
||||
var className = node.name.text;
|
||||
var decorators = node.decorators || [];
|
||||
decorators.filter(function (d) {
|
||||
var baseExpr = d.expression || {};
|
||||
return baseExpr.expression.text === 'Pipe';
|
||||
}).forEach(this.validateProperties.bind(this, className));
|
||||
_super.prototype.visitClassDeclaration.call(this, node);
|
||||
};
|
||||
ClassMetadataWalker.prototype.validateProperties = function (className, pipe) {
|
||||
var argument = this.extractArgument(pipe);
|
||||
if (argument.kind === SyntaxKind.current().ObjectLiteralExpression) {
|
||||
argument.properties.filter(function (n) { return n.name.text === 'pure'; })
|
||||
.forEach(this.validateProperty.bind(this, className));
|
||||
}
|
||||
};
|
||||
ClassMetadataWalker.prototype.extractArgument = function (pipe) {
|
||||
var baseExpr = pipe.expression || {};
|
||||
var args = baseExpr.arguments || [];
|
||||
return args[0];
|
||||
};
|
||||
ClassMetadataWalker.prototype.validateProperty = function (className, property) {
|
||||
var propValue = property.initializer.getText();
|
||||
if (propValue === "false") {
|
||||
this.addFailure(this.createFailure(property.getStart(), property.getWidth(), sprintf_js_1.sprintf.apply(this, this.createFailureArray(className))));
|
||||
}
|
||||
};
|
||||
ClassMetadataWalker.prototype.createFailureArray = function (className) {
|
||||
return [Rule.FAILURE, className];
|
||||
};
|
||||
return ClassMetadataWalker;
|
||||
}(Lint.RuleWalker));
|
||||
exports.ClassMetadataWalker = ClassMetadataWalker;
|
84
node_modules/codelyzer/pipeNamingRule.js
generated
vendored
Normal file
84
node_modules/codelyzer/pipeNamingRule.js
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
var selectorValidator_1 = require("./util/selectorValidator");
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
_super.call(this, ruleName, value, disabledIntervals);
|
||||
if (value[1] === 'camelCase') {
|
||||
this.validator = selectorValidator_1.SelectorValidator.camelCase;
|
||||
}
|
||||
if (value.length > 2) {
|
||||
this.hasPrefix = true;
|
||||
var prefixExpression = (value.slice(2) || []).join('|');
|
||||
this.prefix = (value.slice(2) || []).join(',');
|
||||
this.prefixChecker = selectorValidator_1.SelectorValidator.multiPrefix(prefixExpression);
|
||||
}
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ClassMetadataWalker(sourceFile, this));
|
||||
};
|
||||
Rule.prototype.validateName = function (name) {
|
||||
return this.validator(name);
|
||||
};
|
||||
Rule.prototype.validatePrefix = function (prefix) {
|
||||
return this.prefixChecker(prefix);
|
||||
};
|
||||
Rule.FAILURE_WITHOUT_PREFIX = 'The name of the Pipe decorator of class %s should' +
|
||||
' be named camelCase, however its value is "%s".';
|
||||
Rule.FAILURE_WITH_PREFIX = 'The name of the Pipe decorator of class %s should' +
|
||||
' be named camelCase with prefix %s, however its value is "%s".';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ClassMetadataWalker = (function (_super) {
|
||||
__extends(ClassMetadataWalker, _super);
|
||||
function ClassMetadataWalker(sourceFile, rule) {
|
||||
_super.call(this, sourceFile, rule.getOptions());
|
||||
this.rule = rule;
|
||||
}
|
||||
ClassMetadataWalker.prototype.visitClassDeclaration = function (node) {
|
||||
var className = node.name.text;
|
||||
var decorators = node.decorators || [];
|
||||
decorators.filter(function (d) {
|
||||
var baseExpr = d.expression || {};
|
||||
return baseExpr.expression.text === 'Pipe';
|
||||
}).forEach(this.validateProperties.bind(this, className));
|
||||
_super.prototype.visitClassDeclaration.call(this, node);
|
||||
};
|
||||
ClassMetadataWalker.prototype.validateProperties = function (className, pipe) {
|
||||
var argument = this.extractArgument(pipe);
|
||||
if (argument.kind === SyntaxKind.current().ObjectLiteralExpression) {
|
||||
argument.properties.filter(function (n) { return n.name.text === 'name'; })
|
||||
.forEach(this.validateProperty.bind(this, className));
|
||||
}
|
||||
};
|
||||
ClassMetadataWalker.prototype.extractArgument = function (pipe) {
|
||||
var baseExpr = pipe.expression || {};
|
||||
var args = baseExpr.arguments || [];
|
||||
return args[0];
|
||||
};
|
||||
ClassMetadataWalker.prototype.validateProperty = function (className, property) {
|
||||
var propName = property.initializer.text;
|
||||
var isValidName = this.rule.validateName(propName);
|
||||
var isValidPrefix = (this.rule.hasPrefix ? this.rule.validatePrefix(propName) : true);
|
||||
if (!isValidName || !isValidPrefix) {
|
||||
this.addFailure(this.createFailure(property.getStart(), property.getWidth(), sprintf_js_1.sprintf.apply(this, this.createFailureArray(className, propName))));
|
||||
}
|
||||
};
|
||||
ClassMetadataWalker.prototype.createFailureArray = function (className, pipeName) {
|
||||
if (this.rule.hasPrefix) {
|
||||
return [Rule.FAILURE_WITH_PREFIX, className, this.rule.prefix, pipeName];
|
||||
}
|
||||
return [Rule.FAILURE_WITHOUT_PREFIX, className, pipeName];
|
||||
};
|
||||
return ClassMetadataWalker;
|
||||
}(Lint.RuleWalker));
|
||||
exports.ClassMetadataWalker = ClassMetadataWalker;
|
68
node_modules/codelyzer/propertyDecoratorBase.js
generated
vendored
Normal file
68
node_modules/codelyzer/propertyDecoratorBase.js
generated
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var ts = require('typescript');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
var UsePropertyDecorator = (function (_super) {
|
||||
__extends(UsePropertyDecorator, _super);
|
||||
function UsePropertyDecorator(config, ruleName, value, disabledIntervals) {
|
||||
_super.call(this, ruleName, value, disabledIntervals);
|
||||
this.config = config;
|
||||
}
|
||||
UsePropertyDecorator.formatFailureString = function (config, decoratorName, className) {
|
||||
var decorators = config.decoratorName;
|
||||
if (decorators instanceof Array) {
|
||||
decorators = decorators.map(function (d) { return ("\"@" + d + "\""); }).join(', ');
|
||||
}
|
||||
else {
|
||||
decorators = "\"@" + decorators + "\"";
|
||||
}
|
||||
return sprintf_js_1.sprintf(config.errorMessage, decoratorName, className, config.propertyName, decorators);
|
||||
};
|
||||
UsePropertyDecorator.prototype.apply = function (sourceFile) {
|
||||
var documentRegistry = ts.createDocumentRegistry();
|
||||
var languageServiceHost = Lint.createLanguageServiceHost('file.ts', sourceFile.getFullText());
|
||||
return this.applyWithWalker(new DirectiveMetadataWalker(sourceFile, this.getOptions(), ts.createLanguageService(languageServiceHost, documentRegistry), this.config));
|
||||
};
|
||||
return UsePropertyDecorator;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.UsePropertyDecorator = UsePropertyDecorator;
|
||||
var DirectiveMetadataWalker = (function (_super) {
|
||||
__extends(DirectiveMetadataWalker, _super);
|
||||
function DirectiveMetadataWalker(sourceFile, options, languageService, config) {
|
||||
_super.call(this, sourceFile, options);
|
||||
this.config = config;
|
||||
this.languageService = languageService;
|
||||
this.typeChecker = languageService.getProgram().getTypeChecker();
|
||||
}
|
||||
DirectiveMetadataWalker.prototype.visitClassDeclaration = function (node) {
|
||||
(node.decorators || []).forEach(this.validateDecorator.bind(this, node.name.text));
|
||||
_super.prototype.visitClassDeclaration.call(this, node);
|
||||
};
|
||||
DirectiveMetadataWalker.prototype.validateDecorator = function (className, decorator) {
|
||||
var baseExpr = decorator.expression || {};
|
||||
var expr = baseExpr.expression || {};
|
||||
var name = expr.text;
|
||||
var args = baseExpr.arguments || [];
|
||||
var arg = args[0];
|
||||
if (/^(Component|Directive)$/.test(name) && arg) {
|
||||
this.validateProperty(className, name, arg);
|
||||
}
|
||||
};
|
||||
DirectiveMetadataWalker.prototype.validateProperty = function (className, decoratorName, arg) {
|
||||
var _this = this;
|
||||
if (arg.kind === SyntaxKind.current().ObjectLiteralExpression) {
|
||||
arg.properties.filter(function (prop) { return prop.name.text === _this.config.propertyName; })
|
||||
.forEach(function (prop) {
|
||||
var p = prop;
|
||||
_this.addFailure(_this.createFailure(p.getStart(), p.getWidth(), UsePropertyDecorator.formatFailureString(_this.config, decoratorName, className)));
|
||||
});
|
||||
}
|
||||
};
|
||||
return DirectiveMetadataWalker;
|
||||
}(Lint.RuleWalker));
|
91
node_modules/codelyzer/selectorNameBase.js
generated
vendored
Normal file
91
node_modules/codelyzer/selectorNameBase.js
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var ts = require('typescript');
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
(function (COMPONENT_TYPE) {
|
||||
COMPONENT_TYPE[COMPONENT_TYPE["COMPONENT"] = 0] = "COMPONENT";
|
||||
COMPONENT_TYPE[COMPONENT_TYPE["DIRECTIVE"] = 1] = "DIRECTIVE";
|
||||
COMPONENT_TYPE[COMPONENT_TYPE["ANY"] = 2] = "ANY";
|
||||
})(exports.COMPONENT_TYPE || (exports.COMPONENT_TYPE = {}));
|
||||
var COMPONENT_TYPE = exports.COMPONENT_TYPE;
|
||||
;
|
||||
var SelectorRule = (function (_super) {
|
||||
__extends(SelectorRule, _super);
|
||||
function SelectorRule(ruleName, value, disabledIntervals, validator, failureString, target) {
|
||||
if (target === void 0) { target = COMPONENT_TYPE.ANY; }
|
||||
_super.call(this, ruleName, value, disabledIntervals);
|
||||
this.validator = validator;
|
||||
this.failureString = failureString;
|
||||
this.target = target;
|
||||
}
|
||||
SelectorRule.prototype.apply = function (sourceFile) {
|
||||
var documentRegistry = ts.createDocumentRegistry();
|
||||
var languageServiceHost = Lint.createLanguageServiceHost('file.ts', sourceFile.getFullText());
|
||||
var languageService = ts.createLanguageService(languageServiceHost, documentRegistry);
|
||||
return this.applyWithWalker(new SelectorNameValidatorWalker(sourceFile, languageService, this));
|
||||
};
|
||||
SelectorRule.prototype.getFailureString = function (failureConfig) {
|
||||
return sprintf_js_1.sprintf(this.failureString, failureConfig.className, this.getOptions().ruleArguments, failureConfig.selector);
|
||||
};
|
||||
SelectorRule.prototype.validate = function (selector) {
|
||||
return this.validator(selector);
|
||||
};
|
||||
Object.defineProperty(SelectorRule.prototype, "targetType", {
|
||||
get: function () {
|
||||
return this.target;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return SelectorRule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.SelectorRule = SelectorRule;
|
||||
var SelectorNameValidatorWalker = (function (_super) {
|
||||
__extends(SelectorNameValidatorWalker, _super);
|
||||
function SelectorNameValidatorWalker(sourceFile, languageService, rule) {
|
||||
_super.call(this, sourceFile, rule.getOptions());
|
||||
this.rule = rule;
|
||||
this.languageService = languageService;
|
||||
this.typeChecker = languageService.getProgram().getTypeChecker();
|
||||
}
|
||||
SelectorNameValidatorWalker.prototype.visitClassDeclaration = function (node) {
|
||||
(node.decorators || []).forEach(this.validateDecorator.bind(this, node.name.text));
|
||||
_super.prototype.visitClassDeclaration.call(this, node);
|
||||
};
|
||||
SelectorNameValidatorWalker.prototype.validateDecorator = function (className, decorator) {
|
||||
var baseExpr = decorator.expression || {};
|
||||
var expr = baseExpr.expression || {};
|
||||
var name = expr.text;
|
||||
var args = baseExpr.arguments || [];
|
||||
var arg = args[0];
|
||||
if (this.rule.targetType === COMPONENT_TYPE.ANY ||
|
||||
name === 'Component' && this.rule.targetType === COMPONENT_TYPE.COMPONENT ||
|
||||
name === 'Directive' && this.rule.targetType === COMPONENT_TYPE.DIRECTIVE) {
|
||||
this.validateSelector(className, arg);
|
||||
}
|
||||
};
|
||||
SelectorNameValidatorWalker.prototype.validateSelector = function (className, arg) {
|
||||
var _this = this;
|
||||
if (arg.kind === SyntaxKind.current().ObjectLiteralExpression) {
|
||||
arg.properties.filter(function (prop) { return prop.name.text === 'selector'; })
|
||||
.forEach(function (prop) {
|
||||
var p = prop;
|
||||
if (isSupportedKind(p.initializer.kind) && !_this.rule.validate(p.initializer.text)) {
|
||||
var error = _this.rule.getFailureString({ selector: p.initializer.text, className: className });
|
||||
_this.addFailure(_this.createFailure(p.initializer.getStart(), p.initializer.getWidth(), error));
|
||||
}
|
||||
});
|
||||
}
|
||||
function isSupportedKind(kind) {
|
||||
var current = SyntaxKind.current();
|
||||
return [current.StringLiteral, current.NoSubstitutionTemplateLiteral].some(function (kindType) { return kindType === kind; });
|
||||
}
|
||||
};
|
||||
return SelectorNameValidatorWalker;
|
||||
}(Lint.RuleWalker));
|
19
node_modules/codelyzer/useHostPropertyDecoratorRule.js
generated
vendored
Normal file
19
node_modules/codelyzer/useHostPropertyDecoratorRule.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var propertyDecoratorBase_1 = require('./propertyDecoratorBase');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
_super.call(this, {
|
||||
decoratorName: ['HostBindings', 'HostListeners'],
|
||||
propertyName: 'host',
|
||||
errorMessage: 'Use @HostBindings and @HostListeners instead of the host property (https://goo.gl/zrdmKr)'
|
||||
}, ruleName, value, disabledIntervals);
|
||||
}
|
||||
return Rule;
|
||||
}(propertyDecoratorBase_1.UsePropertyDecorator));
|
||||
exports.Rule = Rule;
|
19
node_modules/codelyzer/useInputPropertyDecoratorRule.js
generated
vendored
Normal file
19
node_modules/codelyzer/useInputPropertyDecoratorRule.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var propertyDecoratorBase_1 = require('./propertyDecoratorBase');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
_super.call(this, {
|
||||
decoratorName: 'Input',
|
||||
propertyName: 'inputs',
|
||||
errorMessage: 'Use the @Input property decorator instead of the inputs property (https://goo.gl/U0lrdN)'
|
||||
}, ruleName, value, disabledIntervals);
|
||||
}
|
||||
return Rule;
|
||||
}(propertyDecoratorBase_1.UsePropertyDecorator));
|
||||
exports.Rule = Rule;
|
77
node_modules/codelyzer/useLifeCycleInterfaceRule.js
generated
vendored
Normal file
77
node_modules/codelyzer/useLifeCycleInterfaceRule.js
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ClassMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.FAILURE_SINGLE = 'Implement lifecycle hook interfaces (https://goo.gl/w1Nwk3)';
|
||||
Rule.FAILURE_MANY = 'Implement lifecycle hook interfaces (https://goo.gl/w1Nwk3)';
|
||||
Rule.HOOKS_PREFIX = 'ng';
|
||||
Rule.LIFE_CYCLE_HOOKS_NAMES = [
|
||||
"OnChanges",
|
||||
"OnInit",
|
||||
"DoCheck",
|
||||
"AfterContentInit",
|
||||
"AfterContentChecked",
|
||||
"AfterViewInit",
|
||||
"AfterViewChecked",
|
||||
"OnDestroy"
|
||||
];
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ClassMetadataWalker = (function (_super) {
|
||||
__extends(ClassMetadataWalker, _super);
|
||||
function ClassMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
ClassMetadataWalker.prototype.visitClassDeclaration = function (node) {
|
||||
var syntaxKind = SyntaxKind.current();
|
||||
var className = node.name.text;
|
||||
var interfaces = [];
|
||||
if (node.heritageClauses) {
|
||||
var interfacesClause = node.heritageClauses.filter(function (h) { return h.token === syntaxKind.ImplementsKeyword; });
|
||||
if (interfacesClause.length !== 0) {
|
||||
interfaces = interfacesClause[0].types.map(function (t) { return t.expression.text; });
|
||||
}
|
||||
}
|
||||
var missing = this.extractMissing(node.members, syntaxKind, interfaces);
|
||||
if (missing.length !== 0) {
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), sprintf_js_1.sprintf.apply(this, this.formatFailure(className, missing))));
|
||||
}
|
||||
_super.prototype.visitClassDeclaration.call(this, node);
|
||||
};
|
||||
ClassMetadataWalker.prototype.extractMissing = function (members, syntaxKind, interfaces) {
|
||||
var ngMembers = members.filter(function (m) { return m.kind === syntaxKind.MethodDeclaration; })
|
||||
.map(function (m) { return m.name.text; })
|
||||
.filter(function (n) { return (n && n.substr(0, 2) === Rule.HOOKS_PREFIX); })
|
||||
.map(function (n) { return n.substr(2, n.lenght); })
|
||||
.filter(function (n) { return Rule.LIFE_CYCLE_HOOKS_NAMES.indexOf(n) !== -1; });
|
||||
return ngMembers.filter(function (m) { return interfaces.indexOf(m) === -1; });
|
||||
};
|
||||
ClassMetadataWalker.prototype.formatFailure = function (className, missing) {
|
||||
var failureConfig;
|
||||
if (missing.length === 1) {
|
||||
failureConfig = [Rule.FAILURE_SINGLE, className, Rule.HOOKS_PREFIX + missing[0], missing[0]];
|
||||
}
|
||||
else {
|
||||
var joinedNgMissing = missing.map(function (m) { return Rule.HOOKS_PREFIX + m; }).join(', ');
|
||||
var joinedMissingInterfaces = missing.join(', ');
|
||||
failureConfig = [Rule.FAILURE_MANY, className, joinedNgMissing, joinedMissingInterfaces];
|
||||
}
|
||||
return failureConfig;
|
||||
};
|
||||
return ClassMetadataWalker;
|
||||
}(Lint.RuleWalker));
|
||||
exports.ClassMetadataWalker = ClassMetadataWalker;
|
19
node_modules/codelyzer/useOutputPropertyDecoratorRule.js
generated
vendored
Normal file
19
node_modules/codelyzer/useOutputPropertyDecoratorRule.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var propertyDecoratorBase_1 = require('./propertyDecoratorBase');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(ruleName, value, disabledIntervals) {
|
||||
_super.call(this, {
|
||||
decoratorName: 'Output',
|
||||
propertyName: 'outputs',
|
||||
errorMessage: 'Use the @Output property decorator instead of the outputs property (https://goo.gl/U0lrdN)'
|
||||
}, ruleName, value, disabledIntervals);
|
||||
}
|
||||
return Rule;
|
||||
}(propertyDecoratorBase_1.UsePropertyDecorator));
|
||||
exports.Rule = Rule;
|
54
node_modules/codelyzer/usePipeTransformInterfaceRule.js
generated
vendored
Normal file
54
node_modules/codelyzer/usePipeTransformInterfaceRule.js
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var sprintf_js_1 = require('sprintf-js');
|
||||
var SyntaxKind = require('./util/syntaxKind');
|
||||
var Rule = (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Rule.prototype.apply = function (sourceFile) {
|
||||
return this.applyWithWalker(new ClassMetadataWalker(sourceFile, this.getOptions()));
|
||||
};
|
||||
Rule.FAILURE = 'The %s class has the Pipe decorator, so it should implement the PipeTransform interface';
|
||||
Rule.PIPE_INTERFACE_NAME = 'PipeTransform';
|
||||
return Rule;
|
||||
}(Lint.Rules.AbstractRule));
|
||||
exports.Rule = Rule;
|
||||
var ClassMetadataWalker = (function (_super) {
|
||||
__extends(ClassMetadataWalker, _super);
|
||||
function ClassMetadataWalker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
ClassMetadataWalker.prototype.visitClassDeclaration = function (node) {
|
||||
var decorators = node.decorators;
|
||||
if (decorators) {
|
||||
var pipes = decorators.map(function (d) { return d.expression.expression.text; }).filter(function (t) { return t === 'Pipe'; });
|
||||
if (pipes.length !== 0) {
|
||||
var className = node.name.text;
|
||||
if (!this.hasIPipeTransform(node)) {
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), sprintf_js_1.sprintf.apply(this, [Rule.FAILURE, className])));
|
||||
}
|
||||
}
|
||||
}
|
||||
_super.prototype.visitClassDeclaration.call(this, node);
|
||||
};
|
||||
ClassMetadataWalker.prototype.hasIPipeTransform = function (node) {
|
||||
var interfaces = [];
|
||||
if (node.heritageClauses) {
|
||||
var interfacesClause = node.heritageClauses
|
||||
.filter(function (h) { return h.token === SyntaxKind.current().ImplementsKeyword; });
|
||||
if (interfacesClause.length !== 0) {
|
||||
interfaces = interfacesClause[0].types.map(function (t) { return t.expression.text; });
|
||||
}
|
||||
}
|
||||
return interfaces.indexOf(Rule.PIPE_INTERFACE_NAME) !== -1;
|
||||
};
|
||||
return ClassMetadataWalker;
|
||||
}(Lint.RuleWalker));
|
||||
exports.ClassMetadataWalker = ClassMetadataWalker;
|
74
node_modules/codelyzer/util/ng2Walker.js
generated
vendored
Normal file
74
node_modules/codelyzer/util/ng2Walker.js
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Lint = require('tslint/lib/lint');
|
||||
var ts = require('typescript');
|
||||
var getDecoratorName = function (decorator) {
|
||||
var baseExpr = decorator.expression || {};
|
||||
var expr = baseExpr.expression || {};
|
||||
return expr.text;
|
||||
};
|
||||
var getDecoratorStringArgs = function (decorator) {
|
||||
var baseExpr = decorator.expression || {};
|
||||
var expr = baseExpr.expression || {};
|
||||
var args = baseExpr.arguments || [];
|
||||
return args.map(function (a) { return (a.kind === ts.SyntaxKind.StringLiteral) ? a.text : null; });
|
||||
};
|
||||
var Ng2Walker = (function (_super) {
|
||||
__extends(Ng2Walker, _super);
|
||||
function Ng2Walker() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Ng2Walker.prototype.visitClassDeclaration = function (declaration) {
|
||||
(declaration.decorators || []).forEach(this.visitClassDecorator.bind(this));
|
||||
_super.prototype.visitClassDeclaration.call(this, declaration);
|
||||
};
|
||||
Ng2Walker.prototype.visitMethodDeclaration = function (method) {
|
||||
(method.decorators || []).forEach(this.visitMethodDecorator.bind(this));
|
||||
_super.prototype.visitMethodDeclaration.call(this, method);
|
||||
};
|
||||
Ng2Walker.prototype.visitMethodDecorator = function (decorator) {
|
||||
var name = getDecoratorName(decorator);
|
||||
if (name === 'HostListener') {
|
||||
this.visitNg2HostListener(decorator.parent, decorator, getDecoratorStringArgs(decorator));
|
||||
}
|
||||
};
|
||||
Ng2Walker.prototype.visitPropertyDeclaration = function (prop) {
|
||||
(prop.decorators || []).forEach(this.visitPropertyDecorator.bind(this));
|
||||
_super.prototype.visitPropertyDeclaration.call(this, prop);
|
||||
};
|
||||
Ng2Walker.prototype.visitPropertyDecorator = function (decorator) {
|
||||
var name = getDecoratorName(decorator);
|
||||
switch (name) {
|
||||
case 'Input':
|
||||
this.visitNg2Input(decorator.parent, decorator, getDecoratorStringArgs(decorator));
|
||||
break;
|
||||
case 'Output':
|
||||
this.visitNg2Output(decorator.parent, decorator, getDecoratorStringArgs(decorator));
|
||||
break;
|
||||
case 'HostBinding':
|
||||
this.visitNg2HostBinding(decorator.parent, decorator, getDecoratorStringArgs(decorator));
|
||||
break;
|
||||
}
|
||||
};
|
||||
Ng2Walker.prototype.visitClassDecorator = function (decorator) {
|
||||
var name = getDecoratorName(decorator);
|
||||
if (name === 'Component') {
|
||||
this.visitNg2Component(decorator.parent, decorator);
|
||||
}
|
||||
else if (name === 'Directive') {
|
||||
this.visitNg2Directive(decorator.parent, decorator);
|
||||
}
|
||||
};
|
||||
Ng2Walker.prototype.visitNg2Component = function (controller, decorator) { };
|
||||
Ng2Walker.prototype.visitNg2Directive = function (controller, decorator) { };
|
||||
Ng2Walker.prototype.visitNg2Input = function (property, input, args) { };
|
||||
Ng2Walker.prototype.visitNg2Output = function (property, output, args) { };
|
||||
Ng2Walker.prototype.visitNg2HostBinding = function (property, decorator, args) { };
|
||||
Ng2Walker.prototype.visitNg2HostListener = function (method, decorator, args) { };
|
||||
return Ng2Walker;
|
||||
}(Lint.RuleWalker));
|
||||
exports.Ng2Walker = Ng2Walker;
|
25
node_modules/codelyzer/util/selectorValidator.js
generated
vendored
Normal file
25
node_modules/codelyzer/util/selectorValidator.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
exports.SelectorValidator = {
|
||||
attribute: function (selector) {
|
||||
return /^\[.+\]$/.test(selector);
|
||||
},
|
||||
element: function (selector) {
|
||||
return /^[^\[].+[^\]]$/.test(selector);
|
||||
},
|
||||
kebabCase: function (selector) {
|
||||
return /^[a-z0-9\-]+\-[a-z0-9\-]+$/.test(selector);
|
||||
},
|
||||
camelCase: function (selector) {
|
||||
return /^[a-zA-Z0-9\[\]]+$/.test(selector);
|
||||
},
|
||||
prefix: function (prefix) {
|
||||
return function (selector) {
|
||||
return new RegExp("^\\[?" + prefix).test(selector);
|
||||
};
|
||||
},
|
||||
multiPrefix: function (prefixes) {
|
||||
return function (selector) {
|
||||
return new RegExp("^\\[?(" + prefixes + ")").test(selector);
|
||||
};
|
||||
}
|
||||
};
|
1803
node_modules/codelyzer/util/syntaxKind.js
generated
vendored
Normal file
1803
node_modules/codelyzer/util/syntaxKind.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue