Skip to content

Commit bfd357b

Browse files
committed
Update eslint, jscs style guidelines
1 parent 20193ac commit bfd357b

File tree

6 files changed

+45
-132
lines changed

6 files changed

+45
-132
lines changed

.eslintrc

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"extends": "eslint:recommended",
3-
"env": {
4-
"node": true,
5-
"browser": true
6-
},
73
"rules": {
84
"quotes": [2, "single"]
95
}

.jscs.json

+14-120
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@
88
"retext-equality.js",
99
"retext-equality.min.js"
1010
],
11+
"preset": "yandex",
12+
"requireQuotedKeysInObjects": true,
13+
"disallowQuotedKeysInObjects": false,
14+
"maximumLineLength": {
15+
"value": 79,
16+
"allExcept": [
17+
"regex",
18+
"urlComments"
19+
]
20+
},
1121
"jsDoc": {
1222
"checkAnnotations": "jsdoc3",
23+
"checkParamExistence": true,
1324
"checkParamNames": true,
1425
"checkRedundantAccess": true,
1526
"checkRedundantParams": true,
@@ -19,126 +30,9 @@
1930
"enforceExistence": true,
2031
"requireHyphenBeforeDescription": true,
2132
"requireNewlineAfterDescription": true,
22-
"requireParamTypes": true,
2333
"requireParamDescription": true,
34+
"requireParamTypes": true,
35+
"requireReturnDescription": true,
2436
"requireReturnTypes": true
25-
},
26-
"requireCurlyBraces": [
27-
"if",
28-
"else",
29-
"for",
30-
"while",
31-
"do",
32-
"try",
33-
"catch"
34-
],
35-
"requireSpaceAfterKeywords": [
36-
"if",
37-
"else",
38-
"for",
39-
"while",
40-
"do",
41-
"switch",
42-
"return",
43-
"try",
44-
"catch"
45-
],
46-
"requireSpaceBeforeBlockStatements": true,
47-
"requireParenthesesAroundIIFE": true,
48-
"requireSpacesInConditionalExpression": true,
49-
"requireSpacesInFunctionExpression": {
50-
"beforeOpeningCurlyBrace": true
51-
},
52-
"requireSpacesInAnonymousFunctionExpression": {
53-
"beforeOpeningRoundBrace": true,
54-
"beforeOpeningCurlyBrace": true
55-
},
56-
"requireSpacesInNamedFunctionExpression": {
57-
"beforeOpeningRoundBrace": true,
58-
"beforeOpeningCurlyBrace": true
59-
},
60-
"requireBlocksOnNewline": true,
61-
"disallowEmptyBlocks": true,
62-
"disallowSpacesInsideObjectBrackets": true,
63-
"disallowSpacesInsideArrayBrackets": true,
64-
"disallowSpacesInsideParentheses": true,
65-
"requireSpacesInsideObjectBrackets": "all",
66-
"disallowDanglingUnderscores": true,
67-
"disallowSpaceAfterObjectKeys": true,
68-
"requireCommaBeforeLineBreak": true,
69-
"requireOperatorBeforeLineBreak": [
70-
"?",
71-
"+",
72-
"-",
73-
"/",
74-
"*",
75-
"=",
76-
"==",
77-
"===",
78-
"!=",
79-
"!==",
80-
">",
81-
">=",
82-
"<",
83-
"<="
84-
],
85-
"requireSpaceBeforeBinaryOperators": [
86-
"+",
87-
"-",
88-
"/",
89-
"*",
90-
"=",
91-
"==",
92-
"===",
93-
"!=",
94-
"!=="
95-
],
96-
"requireSpaceAfterBinaryOperators": [
97-
"+",
98-
"-",
99-
"/",
100-
"*",
101-
"=",
102-
"==",
103-
"===",
104-
"!=",
105-
"!=="
106-
],
107-
"disallowSpaceAfterPrefixUnaryOperators": [
108-
"++",
109-
"--",
110-
"+",
111-
"-",
112-
"~",
113-
"!"
114-
],
115-
"disallowSpaceBeforePostfixUnaryOperators": [
116-
"++",
117-
"--"
118-
],
119-
"disallowImplicitTypeConversion": [
120-
"numeric",
121-
"boolean",
122-
"binary",
123-
"string"
124-
],
125-
"requireCamelCaseOrUpperCaseIdentifiers": true,
126-
"disallowKeywords": [
127-
"with"
128-
],
129-
"disallowMultipleLineStrings": true,
130-
"disallowMultipleLineBreaks": true,
131-
"validateLineBreaks": "LF",
132-
"validateQuoteMarks": "'",
133-
"disallowMixedSpacesAndTabs": true,
134-
"disallowTrailingWhitespace": true,
135-
"disallowTrailingComma": true,
136-
"disallowKeywordsOnNewLine": [
137-
"else"
138-
],
139-
"requireLineFeedAtFileEnd": true,
140-
"requireCapitalizedConstructors": true,
141-
"safeContextKeyword": "self",
142-
"requireDotNotation": true,
143-
"disallowYodaConditions": true
37+
}
14438
}

index.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2015 Titus Wormer
4+
* @license MIT
5+
* @module retext:equality
6+
* @fileoverview Warn about possible insensitive,
7+
* inconsiderate language with Retext.
8+
*/
9+
110
'use strict';
211

12+
/* eslint-env commonjs */
13+
314
module.exports = require('./lib/equality.js');

lib/equality.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
'use strict';
1111

12+
/* eslint-env commonjs */
13+
1214
/*
1315
* Dependencies.
1416
*/
@@ -80,7 +82,7 @@ function byValue(object, value) {
8082
* Get a string value from a node.
8183
*
8284
* @param {NLCSTNode} node - NLCST node.
83-
* @return {string}
85+
* @return {string} - Normalized and stringified `node`.
8486
*/
8587
function toString(node) {
8688
return nlcstToString(node).replace(/['-]/g, '');
@@ -90,7 +92,7 @@ function toString(node) {
9092
* Get the value of multiple nodes
9193
*
9294
* @param {Array.<NLCSTNode>} node - NLCST nodes.
93-
* @return {string}
95+
* @return {string} - Value of `node`.
9496
*/
9597
function valueOf(node) {
9698
return nlcstToString({
@@ -526,7 +528,7 @@ function factory(file) {
526528
return;
527529
}
528530

529-
value = toString(child).toLowerCase()
531+
value = toString(child).toLowerCase();
530532
patterns = byWord.hasOwnProperty(value) ? byWord[value] : null;
531533
length = patterns ? patterns.length : 0;
532534
index = -1;
@@ -560,6 +562,7 @@ function factory(file) {
560562
* Transformer.
561563
*
562564
* @param {NLCSTNode} cst - Syntax tree.
565+
* @param {VFile} file - Virtual file.
563566
*/
564567
function transformer(cst, file) {
565568
visit(cst, 'ParagraphNode', factory(file));

script/extract.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
'use strict';
1010

11+
/* eslint-env node */
12+
1113
/*
1214
* Dependencies.
1315
*/
@@ -77,7 +79,10 @@ var data = [
7779

7880
var dups = duplicated(allData);
7981
if (dups.length !== 0) {
80-
throw new Error('"' + name + '.yml" has duplicated value(s): \n' + dups.join('\n'));
82+
throw new Error(
83+
'"' + name + '.yml" has duplicated value(s): \n' +
84+
dups.join('\n')
85+
);
8186
}
8287

8388
return yamlData;
@@ -120,7 +125,7 @@ data.forEach(function (entry) {
120125
}).filter(function (value, index, parent) {
121126
return parent.indexOf(value, index + 1) === -1;
122127
});
123-
})
128+
});
124129

125130
/*
126131
* Patch.
@@ -146,14 +151,14 @@ data.forEach(function (entry) {
146151
Object.keys(entry.inconsiderate).join(', ')
147152
);
148153
}
149-
})
154+
});
150155
}
151156
});
152157

153158
/*
154159
* Write.
155160
*/
156161

157-
data = stringify(data, 0, 2) + '\n'
162+
data = stringify(data, 0, 2) + '\n';
158163

159164
write(join(__dirname, '..', 'lib', 'patterns.json'), data);

test.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
/* eslint-env mocha */
3+
/* eslint-env node */
4+
/* jscs:disable maximumLineLength */
45

56
/*
67
* Dependencies.
@@ -16,6 +17,9 @@ var equality = require('./');
1617

1718
/**
1819
* Helper to get warnings from `equality` in `doc`.
20+
*
21+
* @param {string} doc - Document to process.
22+
* @return {Array.<VFileMessage>} - Virtual messages.
1923
*/
2024
function process(doc) {
2125
var messages;

0 commit comments

Comments
 (0)