mws-tslint-rules
Advanced tools
Comparing version 0.0.15 to 0.0.16
{ | ||
"name": "mws-tslint-rules", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"author": "Various Person", | ||
@@ -11,3 +11,4 @@ "peerDependencies": { | ||
"start": "gulp", | ||
"gulp": "gulp" | ||
"gulp": "gulp", | ||
"prepublishOnly": "gulp" | ||
}, | ||
@@ -14,0 +15,0 @@ "description": "MWS custom set of TSLint rules", |
@@ -24,5 +24,5 @@ "use strict"; | ||
}; | ||
Rule.EMPTY_LINE_MISSING_BEFORE_RETURN_STRING = 'Return statement should have empty line before it'; | ||
return Rule; | ||
}(abstractRule_1.AbstractRule)); | ||
Rule.EMPTY_LINE_MISSING_BEFORE_RETURN_STRING = 'Return statement should have empty line before it'; | ||
exports.Rule = Rule; | ||
@@ -29,0 +29,0 @@ var EmptyLineBeforeReturnStatementWalker = (function (_super) { |
@@ -24,11 +24,11 @@ "use strict"; | ||
}; | ||
Rule.EMPTY_LINE_MISSING_IF_STATEMENT_STRING = '\'if\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_DO_STATEMENT_STRING = '\'do\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_WHILE_STATEMENT_STRING = '\'while\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_FOR_STATEMENT_STRING = '\'for\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_FOR_IN_STATEMENT_STRING = '\'for in\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_FOR_OF_STATEMENT_STRING = '\'for of\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_SWITCH_STATEMENT_STRING = '\'switch\' block should start end end with empty line'; | ||
return Rule; | ||
}(abstractRule_1.AbstractRule)); | ||
Rule.EMPTY_LINE_MISSING_IF_STATEMENT_STRING = '\'if\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_DO_STATEMENT_STRING = '\'do\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_WHILE_STATEMENT_STRING = '\'while\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_FOR_STATEMENT_STRING = '\'for\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_FOR_IN_STATEMENT_STRING = '\'for in\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_FOR_OF_STATEMENT_STRING = '\'for of\' block should start end end with empty line'; | ||
Rule.EMPTY_LINE_MISSING_SWITCH_STATEMENT_STRING = '\'switch\' block should start end end with empty line'; | ||
exports.Rule = Rule; | ||
@@ -35,0 +35,0 @@ var EmptyLinesAtBlockStatementWalker = (function (_super) { |
@@ -24,6 +24,6 @@ "use strict"; | ||
}; | ||
Rule.EMPTY_LINE_MISSING_BEFORE_VARIABLE_DECLARATION_BLOCK_STRING = 'Variable declaration block should start with empty line'; | ||
Rule.EMPTY_LINE_MISSING_AFTER_VARIABLE_DECLARATION_BLOCK_STRING = 'Variable declaration block should end with empty line'; | ||
return Rule; | ||
}(abstractRule_1.AbstractRule)); | ||
Rule.EMPTY_LINE_MISSING_BEFORE_VARIABLE_DECLARATION_BLOCK_STRING = 'Variable declaration block should start with empty line'; | ||
Rule.EMPTY_LINE_MISSING_AFTER_VARIABLE_DECLARATION_BLOCK_STRING = 'Variable declaration block should end with empty line'; | ||
exports.Rule = Rule; | ||
@@ -30,0 +30,0 @@ var EmptyLinesAtVariableStatementWalker = (function (_super) { |
@@ -30,5 +30,5 @@ "use strict"; | ||
}; | ||
Rule.FAILURE_STRING = 'Module imports sorted incorrectly'; | ||
return Rule; | ||
}(abstractRule_1.AbstractRule)); | ||
Rule.FAILURE_STRING = 'Module imports sorted incorrectly'; | ||
exports.Rule = Rule; | ||
@@ -127,40 +127,40 @@ var SortingImportWalker = (function (_super) { | ||
}; | ||
SortingImportWalker.metadata = { | ||
ruleName: 'sorting-import', | ||
description: '', | ||
hasFix: true, | ||
optionsDescription: (_a = ["sorting imports"], _a.raw = ["sorting imports"], Lint.Utils.dedent(_a)), | ||
options: { | ||
type: 'object', | ||
properties: { | ||
'orderImportType': { | ||
type: 'string', | ||
enum: defaultImportTypeSortingOrder | ||
}, | ||
'orderSortingType': { | ||
type: 'string', | ||
enum: 'MIN_TO_MAX_LENGTH' | ||
} | ||
}, | ||
additionalProperties: false, | ||
}, | ||
optionExamples: [ | ||
true, | ||
[true, { | ||
'orderSortingType': 'MAX_TO_MIN_LENGTH' | ||
}], | ||
[true, { | ||
'orderImportType': ['NAMED', 'SIDE_EFFECT', 'NAMESPACE', 'NAMED_WITHOUT_BRACKETS', 'EQUALS'] | ||
}], | ||
[true, { | ||
'orderImportType': ['NAMED', 'SIDE_EFFECT', 'NAMESPACE', 'NAMED_WITHOUT_BRACKETS', 'EQUALS'], | ||
'orderSortingType': 'MAX_TO_MIN_LENGTH' | ||
}] | ||
], | ||
type: 'maintainability', | ||
typescriptOnly: false | ||
}; | ||
return SortingImportWalker; | ||
}(Lint.RuleWalker)); | ||
SortingImportWalker.metadata = { | ||
ruleName: 'sorting-import', | ||
description: '', | ||
hasFix: true, | ||
optionsDescription: (_a = ["sorting imports"], _a.raw = ["sorting imports"], Lint.Utils.dedent(_a)), | ||
options: { | ||
type: 'object', | ||
properties: { | ||
'orderImportType': { | ||
type: 'string', | ||
enum: defaultImportTypeSortingOrder | ||
}, | ||
'orderSortingType': { | ||
type: 'string', | ||
enum: 'MIN_TO_MAX_LENGTH' | ||
} | ||
}, | ||
additionalProperties: false, | ||
}, | ||
optionExamples: [ | ||
true, | ||
[true, { | ||
'orderSortingType': 'MAX_TO_MIN_LENGTH' | ||
}], | ||
[true, { | ||
'orderImportType': ['NAMED', 'SIDE_EFFECT', 'NAMESPACE', 'NAMED_WITHOUT_BRACKETS', 'EQUALS'] | ||
}], | ||
[true, { | ||
'orderImportType': ['NAMED', 'SIDE_EFFECT', 'NAMESPACE', 'NAMED_WITHOUT_BRACKETS', 'EQUALS'], | ||
'orderSortingType': 'MAX_TO_MIN_LENGTH' | ||
}] | ||
], | ||
type: 'maintainability', | ||
typescriptOnly: false | ||
}; | ||
var _a; | ||
//# sourceMappingURL=sortingImportRule.js.map |
@@ -23,6 +23,6 @@ "use strict"; | ||
}; | ||
Rule.RETURN_TYPE_MISSING = 'Missing return statement after method declaration'; | ||
Rule.ARGUMENT_TYPE_MISSING = 'Missing argument type in method declaration'; | ||
return Rule; | ||
}(abstractRule_1.AbstractRule)); | ||
Rule.RETURN_TYPE_MISSING = 'Missing return statement after method declaration'; | ||
Rule.ARGUMENT_TYPE_MISSING = 'Missing argument type in method declaration'; | ||
exports.Rule = Rule; | ||
@@ -35,26 +35,15 @@ var TypesAInMethodDeclarationWalker = (function (_super) { | ||
TypesAInMethodDeclarationWalker.prototype.visitMethodDeclaration = function (node) { | ||
var methodBody = node.body ? node.body.getText() : ''; | ||
var methodText = node.getText(); | ||
var methodDeclaration = methodText.replace(methodBody, ''); | ||
this.checkMethodReturnType(node, methodDeclaration); | ||
this.checkMethodArgumentsType(node, methodDeclaration); | ||
this.checkMethodReturnType(node); | ||
this.checkMethodArgumentsType(node); | ||
_super.prototype.visitMethodDeclaration.call(this, node); | ||
}; | ||
TypesAInMethodDeclarationWalker.prototype.checkMethodReturnType = function (node, methodDeclaration) { | ||
var regExp = new RegExp('\\):'); | ||
if (!regExp.test(methodDeclaration)) { | ||
TypesAInMethodDeclarationWalker.prototype.checkMethodReturnType = function (node) { | ||
if (!node.type) { | ||
this.addFailureAt(node.getStart(), node.getWidth(), Rule.RETURN_TYPE_MISSING); | ||
} | ||
}; | ||
TypesAInMethodDeclarationWalker.prototype.checkMethodArgumentsType = function (node, methodDeclaration) { | ||
TypesAInMethodDeclarationWalker.prototype.checkMethodArgumentsType = function (node) { | ||
var _this = this; | ||
var regExp = new RegExp('\\(.+\\)'); | ||
var argumentsRegExp = new RegExp(':.+'); | ||
var argumentsMatch = methodDeclaration.match(regExp); | ||
if (!argumentsMatch) { | ||
return; | ||
} | ||
var argumentsArray = argumentsMatch[0].slice(1, -1).split(','); | ||
argumentsArray.forEach(function (element) { | ||
if (!argumentsRegExp.test(element)) { | ||
node.parameters.forEach(function (parameter) { | ||
if (!parameter.type) { | ||
_this.addFailureAt(node.getStart(), node.getWidth(), Rule.ARGUMENT_TYPE_MISSING); | ||
@@ -61,0 +50,0 @@ } |
@@ -23,7 +23,7 @@ "use strict"; | ||
}; | ||
Rule.FAILURE_METHOD_STRING = 'White space is not allowed between method name and ()'; | ||
Rule.FAILURE_FUNCTION_STRING = 'There must be whitespace between function and ()'; | ||
Rule.FAILURE_NAMED_FUNCTION_STRING = 'White space is not allowed between function name and ()'; | ||
return Rule; | ||
}(abstractRule_1.AbstractRule)); | ||
Rule.FAILURE_METHOD_STRING = 'White space is not allowed between method name and ()'; | ||
Rule.FAILURE_FUNCTION_STRING = 'There must be whitespace between function and ()'; | ||
Rule.FAILURE_NAMED_FUNCTION_STRING = 'White space is not allowed between function name and ()'; | ||
exports.Rule = Rule; | ||
@@ -30,0 +30,0 @@ var NoSpaceInMethodDeclarationWalker = (function (_super) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71128
922