diff --git a/.jscsrc b/.jscsrc index 3b7a6ac..beb1b61 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,10 +1,63 @@ { - "excludeFiles": [ - "./**/node_modules/**", - "./coverage/**", - "./node_modules/**" - ], - + "disallowEmptyBlocks": true, + "disallowIdenticalDestructuringNames": true, + "disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"], + "disallowKeywordsOnNewLine": ["else"], + "disallowKeywords": ["with", "void"], + "disallowMixedSpacesAndTabs": true, + "disallowMultipleLineBreaks": true, + "disallowMultipleLineStrings": true, + "disallowMultipleSpaces": true, + "disallowNestedTernaries": true, + "disallowNewlineBeforeBlockStatements": true, + "disallowOperatorBeforeLineBreak": ["."], + "disallowPaddingNewlinesInBlocks": { "open": false, "close": true }, + "disallowParenthesesAroundArrowParam": true, + "disallowQuotedKeysInObjects": true, + "disallowSpaceAfterObjectKeys": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforeComma": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "disallowSpaceBeforeSemicolon": true, + "disallowSpacesInCallExpression": true, + "disallowSpacesInFunctionDeclaration": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInsideArrayBrackets": "all", + "disallowSpacesInsideBrackets": true, + "disallowSpacesInsideObjectBrackets": true, + "disallowSpacesInsideParentheses": true, + "disallowSpacesInsideParenthesizedExpression": true, + "disallowTrailingComma": true, + "disallowTrailingWhitespace": true, + "disallowUnusedParams": true, + "disallowYodaConditions": true, + "jsDoc": { + "checkAnnotations": true, + "checkParamExistence": true, + "requireParamTypes": true, + "checkRedundantParams": true, + "checkReturnTypes": true, + "checkRedundantReturns": true, + "requireReturnTypes": true, + "checkTypes": "strictNativeCase", + "checkRedundantAccess": "enforceLeadingUnderscore", + "leadingUnderscoreAccess": true, + "disallowNewlineAfterDescription": true, + "requireParamDescription": true, + "requireReturnDescription": true + }, + "maximumLineLength": 80, + "maximumNumberOfLines": 3000, + "maxErrors": 5, + "requireAlignedMultilineParams": "firstParam", + "requireBlocksOnNewline": true, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "requireCapitalizedConstructors": true, + "requireCommaBeforeLineBreak": true, "requireCurlyBraces": [ "if", "else", @@ -14,64 +67,61 @@ "try", "catch" ], - - "requireSpaceBeforeBlockStatements": true, + "requireDollarBeforejQueryAssignment": true, + "requireDotNotation": true, + "requireLineBreakAfterVariableAssignment": true, + "requireObjectKeysOnNewLine": true, + "requireOperatorBeforeLineBreak": true, + "requirePaddingNewLinesAfterUseStrict": true, + "requirePaddingNewLinesBeforeExport": true, + "requirePaddingNewLinesInObjects": true, "requireParenthesesAroundIIFE": true, - "requireSpacesInConditionalExpression": { - "afterTest": true, - "beforeConsequent": true, - "afterConsequent": true, - "beforeAlternate": true - }, - + "requireSemicolons": true, + "requireShorthandArrowFunctions": true, + "requireSpaceAfterBinaryOperators": true, + "requireSpaceAfterComma": true, + "requireSpaceAfterKeywords": true, + "requireSpaceAfterLineComment": true, + "requireSpaceBeforeBinaryOperators": true, + "requireSpaceBeforeBlockStatements": 1, + "requireSpaceBeforeKeywords": [ + "else", + "while", + "catch" + ], + "requireSpaceBeforeObjectValues": true, + "requireSpaceBetweenArguments": true, "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, - "requireSpacesInNamedFunctionExpression": { + "requireSpacesInConditionalExpression": true, + "requireSpacesInForStatement": true, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true }, - - "requireBlocksOnNewline": true, - "disallowEmptyBlocks": true, - "disallowSpacesInsideObjectBrackets": "all", - "disallowSpacesInsideArrayBrackets": "all", - "disallowSpacesInsideParentheses": true, - "disallowQuotedKeysInObjects": true, - "disallowSpaceAfterObjectKeys": true, - "requireSpaceBeforeObjectValues": true, - "requireCommaBeforeLineBreak": true, - "requireOperatorBeforeLineBreak": true, - "disallowSpaceAfterPrefixUnaryOperators": true, - "disallowSpaceBeforePostfixUnaryOperators": true, - "requireSpaceBeforeBinaryOperators": true, - "requireSpaceAfterBinaryOperators": true, - "disallowImplicitTypeConversion": [ - "numeric", "boolean", "binary", "string" - ], - "requireCamelCaseOrUpperCaseIdentifiers": true, - "disallowKeywords": ["with", "let", "void"], - "disallowMultipleLineBreaks": true, - "disallowMixedSpacesAndTabs": true, - "disallowTrailingWhitespace": true, - "disallowTrailingComma": true, - "disallowKeywordsOnNewLine": ["else", "catch"], - "maximumLineLength": 80, - "requireCapitalizedConstructors": true, - "requireDotNotation": true, - "disallowYodaConditions": true, - "disallowNewlineBeforeBlockStatements": true, - "validateLineBreaks": "LF", - "validateQuoteMarks": "'", + "requireSpacesInFunction": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInGenerator": { + "beforeStar": true + }, + "requireSpacesInNamedFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "safeContextKeyword": ["self"], + "validateAlignedFunctionParameters": true, "validateIndentation": "\t", + "validateLineBreaks": "LF", "validateParameterSeparator": ", ", - "validateJSDoc": { - "checkParamNames": true, - "checkRedundantParams": true, - "requireParamTypes": true - }, - "safeContextKeyword": ["self"] -} + "validateQuoteMarks": "'", + "excludeFiles": [ + "./**/node_modules/**", + "./coverage/**", + "./node_modules/**", + "./test/cases/**" + ], +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 42f716d..c45d80e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,6 @@ node_js: - "0.12" - "1" - "2" - - "3" \ No newline at end of file + - "3" + - "4" + - "5" \ No newline at end of file diff --git a/lib/ConstructorTokenizer.js b/lib/ConstructorTokenizer.js index dc6436d..b596983 100644 --- a/lib/ConstructorTokenizer.js +++ b/lib/ConstructorTokenizer.js @@ -85,7 +85,7 @@ ConstructorTokenizer.prototype._currentState = STATES.NO; /** * Gets next token in source. - * @returns {{state: (number), start: number, end: number}} + * @returns {{state: (number), start: number, end: number}} Token descriptor. */ ConstructorTokenizer.prototype.next = function () { if (this._currentState === STATES.ILLEGAL || diff --git a/lib/ServiceLocator.js b/lib/ServiceLocator.js index 94b0fe3..525656b 100644 --- a/lib/ServiceLocator.js +++ b/lib/ServiceLocator.js @@ -192,10 +192,10 @@ function throwIfNotFunction(constructor) { /** * Throws error if specified type name is not a string. - * @param {String} type Type name to check. + * @param {string} type Type name to check. */ function throwIfNotString(type) { - if (typeof(type) === 'string') { + if (typeof (type) === 'string') { return; } @@ -282,5 +282,4 @@ function getParameterNames(constructor) { } } return result; - } \ No newline at end of file diff --git a/package.json b/package.json index abf8281..0e2437b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "catberry-locator", - "version": "1.1.7", + "version": "1.1.8", "author": "Denis Rechkunov ", "description": "Service Locator component for Catberry Framework", "homepage": "https://github.com/catberry/catberry-locator", @@ -23,11 +23,11 @@ }, "main": "./lib/ServiceLocator.js", "devDependencies": { - "istanbul-harmony": "~0.3.1", - "codecov.io": "^0.1.2", - "mocha": "^2.1.0", - "jscs": "~1.6.2", - "jshint": "^2.6.0" + "istanbul": "~0.4.0", + "codecov.io": "~0.1.6", + "mocha": "^2.3.3", + "jscs": "^2.5.1", + "jshint": "^2.8.0" }, "engines": { "node": ">=0.10" diff --git a/test/lib/ConstructorTokenizer.js b/test/lib/ConstructorTokenizer.js index cc51d25..6bba3ca 100644 --- a/test/lib/ConstructorTokenizer.js +++ b/test/lib/ConstructorTokenizer.js @@ -411,6 +411,5 @@ function areTokensEqual(actual, expected) { actual[i].start, expected[i].start ); assert.strictEqual(actual[i].end, expected[i].end); - } } \ No newline at end of file diff --git a/test/lib/ServiceLocator.js b/test/lib/ServiceLocator.js index 935fd9f..218d53f 100644 --- a/test/lib/ServiceLocator.js +++ b/test/lib/ServiceLocator.js @@ -33,8 +33,10 @@ var assert = require('assert'), ServiceLocator = require('../../lib/ServiceLocator'); -function Constructor($testModule1, testArgument1, $testModule2, testArgument2, - $testModule3) { +// jscs:disable disallowUnusedParams +function Constructor( + $testModule1, testArgument1, $testModule2, testArgument2, $testModule3 + ) { this.args = arguments; } @@ -166,7 +168,7 @@ describe('ServiceLocator', function () { module3Parameters.testArgument1, 'Wrong parameter resolution'); - //TestModule4 + // TestModule4 assert.equal(rootModule.args[2].args[2].args.length, 0, 'Wrong argument count'); }); @@ -222,21 +224,13 @@ describe('ServiceLocator', function () { function () { var locator = new ServiceLocator(); - function Implementation1() { + function Implementation1() { } - } - - function Implementation2() { - - } - - function Implementation3() { - - } + function Implementation2() { } - function AnotherImplementation() { + function Implementation3() { } - } + function AnotherImplementation() { } locator.register('type', Implementation1); locator.register('type', Implementation2); @@ -251,7 +245,6 @@ describe('ServiceLocator', function () { 'Wrong type resolution'); assert.equal(instances[2] instanceof Implementation1, true, 'Wrong type resolution'); - }); it('should return empty array if specified type was not found', @@ -277,12 +270,10 @@ describe('ServiceLocator', function () { var locator = new ServiceLocator(), testArgument = 'testArgumentValue'; - function TestModule() { - - } + function TestModule() { } function ModuleToResolve($testType, testArgument) { - assert.equal($testType instanceof TestModule, true); + assert.equal($testType instanceof TestModule, true); assert.strictEqual(testArgument, testArgument); } @@ -298,8 +289,7 @@ describe('ServiceLocator', function () { function () { var locator = new ServiceLocator(); - function ModuleToResolve() { - } + function ModuleToResolve() { } var instance = locator.resolveInstance(ModuleToResolve);