Skip to content

Commit fa6d000

Browse files
author
Denis Rechkunov
committed
Update and fix codestyle.
1 parent 0ee4920 commit fa6d000

7 files changed

Lines changed: 161 additions & 112 deletions

File tree

.jscsrc

Lines changed: 107 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,63 @@
11
{
2-
"excludeFiles": [
3-
"./**/node_modules/**",
4-
"./coverage/**",
5-
"./node_modules/**"
6-
],
7-
2+
"disallowEmptyBlocks": true,
3+
"disallowIdenticalDestructuringNames": true,
4+
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
5+
"disallowKeywordsOnNewLine": ["else"],
6+
"disallowKeywords": ["with", "void"],
7+
"disallowMixedSpacesAndTabs": true,
8+
"disallowMultipleLineBreaks": true,
9+
"disallowMultipleLineStrings": true,
10+
"disallowMultipleSpaces": true,
11+
"disallowNestedTernaries": true,
12+
"disallowNewlineBeforeBlockStatements": true,
13+
"disallowOperatorBeforeLineBreak": ["."],
14+
"disallowPaddingNewlinesInBlocks": { "open": false, "close": true },
15+
"disallowParenthesesAroundArrowParam": true,
16+
"disallowQuotedKeysInObjects": true,
17+
"disallowSpaceAfterObjectKeys": true,
18+
"disallowSpaceAfterPrefixUnaryOperators": true,
19+
"disallowSpaceBeforeComma": true,
20+
"disallowSpaceBeforePostfixUnaryOperators": true,
21+
"disallowSpaceBeforeSemicolon": true,
22+
"disallowSpacesInCallExpression": true,
23+
"disallowSpacesInFunctionDeclaration": {
24+
"beforeOpeningRoundBrace": true
25+
},
26+
"disallowSpacesInNamedFunctionExpression": {
27+
"beforeOpeningRoundBrace": true
28+
},
29+
"disallowSpacesInsideArrayBrackets": "all",
30+
"disallowSpacesInsideBrackets": true,
31+
"disallowSpacesInsideObjectBrackets": true,
32+
"disallowSpacesInsideParentheses": true,
33+
"disallowSpacesInsideParenthesizedExpression": true,
34+
"disallowTrailingComma": true,
35+
"disallowTrailingWhitespace": true,
36+
"disallowUnusedParams": true,
37+
"disallowYodaConditions": true,
38+
"jsDoc": {
39+
"checkAnnotations": true,
40+
"checkParamExistence": true,
41+
"requireParamTypes": true,
42+
"checkRedundantParams": true,
43+
"checkReturnTypes": true,
44+
"checkRedundantReturns": true,
45+
"requireReturnTypes": true,
46+
"checkTypes": "strictNativeCase",
47+
"checkRedundantAccess": "enforceLeadingUnderscore",
48+
"leadingUnderscoreAccess": true,
49+
"disallowNewlineAfterDescription": true,
50+
"requireParamDescription": true,
51+
"requireReturnDescription": true
52+
},
53+
"maximumLineLength": 80,
54+
"maximumNumberOfLines": 3000,
55+
"maxErrors": 5,
56+
"requireAlignedMultilineParams": "firstParam",
57+
"requireBlocksOnNewline": true,
58+
"requireCamelCaseOrUpperCaseIdentifiers": true,
59+
"requireCapitalizedConstructors": true,
60+
"requireCommaBeforeLineBreak": true,
861
"requireCurlyBraces": [
962
"if",
1063
"else",
@@ -14,64 +67,61 @@
1467
"try",
1568
"catch"
1669
],
17-
18-
"requireSpaceBeforeBlockStatements": true,
70+
"requireDollarBeforejQueryAssignment": true,
71+
"requireDotNotation": true,
72+
"requireLineBreakAfterVariableAssignment": true,
73+
"requireObjectKeysOnNewLine": true,
74+
"requireOperatorBeforeLineBreak": true,
75+
"requirePaddingNewLinesAfterUseStrict": true,
76+
"requirePaddingNewLinesBeforeExport": true,
77+
"requirePaddingNewLinesInObjects": true,
1978
"requireParenthesesAroundIIFE": true,
20-
"requireSpacesInConditionalExpression": {
21-
"afterTest": true,
22-
"beforeConsequent": true,
23-
"afterConsequent": true,
24-
"beforeAlternate": true
25-
},
26-
79+
"requireSemicolons": true,
80+
"requireShorthandArrowFunctions": true,
81+
"requireSpaceAfterBinaryOperators": true,
82+
"requireSpaceAfterComma": true,
83+
"requireSpaceAfterKeywords": true,
84+
"requireSpaceAfterLineComment": true,
85+
"requireSpaceBeforeBinaryOperators": true,
86+
"requireSpaceBeforeBlockStatements": 1,
87+
"requireSpaceBeforeKeywords": [
88+
"else",
89+
"while",
90+
"catch"
91+
],
92+
"requireSpaceBeforeObjectValues": true,
93+
"requireSpaceBetweenArguments": true,
2794
"requireSpacesInAnonymousFunctionExpression": {
2895
"beforeOpeningRoundBrace": true,
2996
"beforeOpeningCurlyBrace": true
3097
},
31-
"requireSpacesInNamedFunctionExpression": {
98+
"requireSpacesInConditionalExpression": true,
99+
"requireSpacesInForStatement": true,
100+
"requireSpacesInFunctionDeclaration": {
32101
"beforeOpeningCurlyBrace": true
33102
},
34-
"disallowSpacesInNamedFunctionExpression": {
35-
"beforeOpeningRoundBrace": true
103+
"requireSpacesInFunctionExpression": {
104+
"beforeOpeningCurlyBrace": true
36105
},
37-
38-
"requireBlocksOnNewline": true,
39-
"disallowEmptyBlocks": true,
40-
"disallowSpacesInsideObjectBrackets": "all",
41-
"disallowSpacesInsideArrayBrackets": "all",
42-
"disallowSpacesInsideParentheses": true,
43-
"disallowQuotedKeysInObjects": true,
44-
"disallowSpaceAfterObjectKeys": true,
45-
"requireSpaceBeforeObjectValues": true,
46-
"requireCommaBeforeLineBreak": true,
47-
"requireOperatorBeforeLineBreak": true,
48-
"disallowSpaceAfterPrefixUnaryOperators": true,
49-
"disallowSpaceBeforePostfixUnaryOperators": true,
50-
"requireSpaceBeforeBinaryOperators": true,
51-
"requireSpaceAfterBinaryOperators": true,
52-
"disallowImplicitTypeConversion": [
53-
"numeric", "boolean", "binary", "string"
54-
],
55-
"requireCamelCaseOrUpperCaseIdentifiers": true,
56-
"disallowKeywords": ["with", "let", "void"],
57-
"disallowMultipleLineBreaks": true,
58-
"disallowMixedSpacesAndTabs": true,
59-
"disallowTrailingWhitespace": true,
60-
"disallowTrailingComma": true,
61-
"disallowKeywordsOnNewLine": ["else", "catch"],
62-
"maximumLineLength": 80,
63-
"requireCapitalizedConstructors": true,
64-
"requireDotNotation": true,
65-
"disallowYodaConditions": true,
66-
"disallowNewlineBeforeBlockStatements": true,
67-
"validateLineBreaks": "LF",
68-
"validateQuoteMarks": "'",
106+
"requireSpacesInFunction": {
107+
"beforeOpeningCurlyBrace": true
108+
},
109+
"requireSpacesInGenerator": {
110+
"beforeStar": true
111+
},
112+
"requireSpacesInNamedFunctionExpression": {
113+
"beforeOpeningCurlyBrace": true
114+
},
115+
"safeContextKeyword": ["self"],
116+
"validateAlignedFunctionParameters": true,
69117
"validateIndentation": "\t",
118+
"validateLineBreaks": "LF",
70119
"validateParameterSeparator": ", ",
71-
"validateJSDoc": {
72-
"checkParamNames": true,
73-
"checkRedundantParams": true,
74-
"requireParamTypes": true
75-
},
76-
"safeContextKeyword": ["self"]
77-
}
120+
"validateQuoteMarks": "'",
121+
"excludeFiles": [
122+
"./**/node_modules/**",
123+
"./coverage/**",
124+
"./node_modules/**",
125+
"./test/cases/**"
126+
],
127+
}

lib/Authority.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ var PORT_REGEXP = /^\d+$/,
4242
/**
4343
* Creates new instance of URI authority component parser.
4444
* https://tools.ietf.org/html/rfc3986#section-3.2
45-
* @param {String?} authorityString URI authority component string.
45+
* @param {string?} authorityString URI authority component string.
4646
* @constructor
4747
*/
4848
function Authority(authorityString) {
49-
if (typeof(authorityString) === 'string' && authorityString.length > 0) {
49+
if (typeof (authorityString) === 'string' && authorityString.length > 0) {
5050
var firstAtIndex = authorityString.indexOf('@');
5151
if (firstAtIndex !== -1) {
5252
var userInfoString = authorityString.substring(0, firstAtIndex);
@@ -60,7 +60,7 @@ function Authority(authorityString) {
6060
if (lastColonIndex === authorityString.length - 1) {
6161
this.port = '';
6262
authorityString = authorityString.substring(0, lastColonIndex);
63-
}else if (PORT_REGEXP.test(portString)) {
63+
} else if (PORT_REGEXP.test(portString)) {
6464
this.port = portString;
6565
authorityString = authorityString.substring(0, lastColonIndex);
6666
}
@@ -80,14 +80,14 @@ Authority.prototype.userInfo = null;
8080
/**
8181
* Current host.
8282
* https://tools.ietf.org/html/rfc3986#section-3.2.2
83-
* @type {String}
83+
* @type {string}
8484
*/
8585
Authority.prototype.host = null;
8686

8787
/**
8888
* Current port.
8989
* https://tools.ietf.org/html/rfc3986#section-3.2.3
90-
* @type {String}
90+
* @type {string}
9191
*/
9292
Authority.prototype.port = null;
9393

@@ -100,10 +100,10 @@ Authority.prototype.clone = function () {
100100
if (this.userInfo) {
101101
authority.userInfo = this.userInfo.clone();
102102
}
103-
if (typeof(this.host) === 'string') {
103+
if (typeof (this.host) === 'string') {
104104
authority.host = this.host;
105105
}
106-
if (typeof(this.port) === 'string') {
106+
if (typeof (this.port) === 'string') {
107107
authority.port = this.port;
108108
}
109109
return authority;

lib/Query.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ var percentEncodingHelper = require('./percentEncodingHelper');
3737
/**
3838
* Creates new instance of URI query component parser.
3939
* https://tools.ietf.org/html/rfc3986#section-3.4
40-
* @param {String?} queryString URI query component string.
40+
* @param {string?} queryString URI query component string.
4141
* @constructor
4242
*/
4343
function Query(queryString) {
44-
if (typeof(queryString) === 'string') {
44+
if (typeof (queryString) === 'string') {
4545
this.values = {};
4646

4747
queryString
@@ -57,12 +57,12 @@ function Query(queryString) {
5757
this.values[key] = [this.values[key]];
5858
}
5959

60-
var value = typeof(parts[1]) === 'string' ?
60+
var value = typeof (parts[1]) === 'string' ?
6161
percentEncodingHelper.decode(parts[1]) : null;
6262

6363
if (this.values[key] instanceof Array) {
6464
this.values[key].push(value);
65-
}else{
65+
} else {
6666
this.values[key] = value;
6767
}
6868
}, this);

lib/URI.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var Authority = require('./Authority'),
3636
percentEncodingHelper = require('./percentEncodingHelper'),
3737
Query = require('./Query');
3838

39-
// https://tools.ietf.org/html/rfc3986#appendix-B
39+
// https://tools.ietf.org/html/rfc3986#appendix-B
4040
var URI_PARSE_REGEXP = new RegExp(
4141
'^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?'
4242
),
@@ -49,31 +49,31 @@ var URI_PARSE_REGEXP = new RegExp(
4949

5050
/**
5151
* Creates new instance of URI according to RFC 3986.
52-
* @param {String?} uriString URI string to parse components.
52+
* @param {string?} uriString URI string to parse components.
5353
* @constructor
5454
*/
5555
function URI(uriString) {
56-
if (typeof(uriString) !== 'string') {
56+
if (typeof (uriString) !== 'string') {
5757
uriString = '';
5858
}
5959

6060
// https://tools.ietf.org/html/rfc3986#appendix-B
6161
var matches = uriString.match(URI_PARSE_REGEXP);
6262

6363
if (matches) {
64-
if (typeof(matches[2]) === 'string') {
64+
if (typeof (matches[2]) === 'string') {
6565
this.scheme = percentEncodingHelper.decode(matches[2]);
6666
}
67-
if (typeof(matches[4]) === 'string') {
67+
if (typeof (matches[4]) === 'string') {
6868
this.authority = new Authority(matches[4]);
6969
}
70-
if (typeof(matches[5]) === 'string') {
70+
if (typeof (matches[5]) === 'string') {
7171
this.path = percentEncodingHelper.decode(matches[5]);
7272
}
73-
if (typeof(matches[7]) === 'string') {
73+
if (typeof (matches[7]) === 'string') {
7474
this.query = new Query(matches[7]);
7575
}
76-
if (typeof(matches[9]) === 'string') {
76+
if (typeof (matches[9]) === 'string') {
7777
this.fragment = percentEncodingHelper.decode(matches[9]);
7878
}
7979
}
@@ -82,7 +82,7 @@ function URI(uriString) {
8282
/**
8383
* Current URI scheme.
8484
* https://tools.ietf.org/html/rfc3986#section-3.1
85-
* @type {String}
85+
* @type {string}
8686
*/
8787
URI.prototype.scheme = null;
8888

@@ -96,7 +96,7 @@ URI.prototype.authority = null;
9696
/**
9797
* Current URI path.
9898
* https://tools.ietf.org/html/rfc3986#section-3.3
99-
* @type {String}
99+
* @type {string}
100100
*/
101101
URI.prototype.path = null;
102102

@@ -110,7 +110,7 @@ URI.prototype.query = null;
110110
/**
111111
* Current URI fragment.
112112
* https://tools.ietf.org/html/rfc3986#section-3.5
113-
* @type {String}
113+
* @type {string}
114114
*/
115115
URI.prototype.fragment = null;
116116

@@ -136,23 +136,23 @@ URI.prototype.resolveRelative = function (baseUri) {
136136
URI.prototype.clone = function () {
137137
var uri = new URI();
138138

139-
if (typeof(this.scheme) === 'string') {
139+
if (typeof (this.scheme) === 'string') {
140140
uri.scheme = this.scheme;
141141
}
142142

143143
if (this.authority) {
144144
uri.authority = this.authority.clone();
145145
}
146146

147-
if (typeof(this.path) === 'string') {
147+
if (typeof (this.path) === 'string') {
148148
uri.path = this.path;
149149
}
150150

151151
if (this.query) {
152152
uri.query = this.query.clone();
153153
}
154154

155-
if (typeof(this.fragment) === 'string') {
155+
if (typeof (this.fragment) === 'string') {
156156
uri.fragment = this.fragment;
157157
}
158158

@@ -259,7 +259,7 @@ function transformReference(baseUri, referenceUri) {
259259
* https://tools.ietf.org/html/rfc3986#section-5.2.3
260260
* @param {URI} baseUri Components of base URI.
261261
* @param {URI} referenceUri Components of reference URI.
262-
* @returns {String} Merged path.
262+
* @returns {string} Merged path.
263263
*/
264264
function merge(baseUri, referenceUri) {
265265
if (baseUri.authority && baseUri.path === '') {
@@ -275,8 +275,8 @@ function merge(baseUri, referenceUri) {
275275
/**
276276
* Removes dots segments from URI path.
277277
* https://tools.ietf.org/html/rfc3986#section-5.2.4
278-
* @param {String} uriPath URI path with possible dot segments.
279-
* @returns {String} URI path without dot segments.
278+
* @param {string} uriPath URI path with possible dot segments.
279+
* @returns {string} URI path without dot segments.
280280
*/
281281
function removeDotSegments(uriPath) {
282282
if (!uriPath) {

0 commit comments

Comments
 (0)