Skip to content

Commit cdf6219

Browse files
committed
Update code-style guidelines
1 parent 14fb292 commit cdf6219

File tree

5 files changed

+56
-145
lines changed

5 files changed

+56
-145
lines changed

.eslintrc

Lines changed: 0 additions & 4 deletions
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

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

index.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2015 Titus Wormer
4+
* @license MIT
5+
* @module mdast:util:heading-range
6+
* @fileoverview Markdown heading as ranges in mdast.
7+
*/
8+
19
'use strict';
210

11+
/* eslint-env commonjs */
12+
313
/*
414
* Dependencies.
515
*/
@@ -16,7 +26,7 @@ var splice = [].splice;
1626
* Transform a string into an applicable expression.
1727
*
1828
* @param {string} value - Value to transform.
19-
* @return {RegExp}
29+
* @return {RegExp} - Expression.
2030
*/
2131
function toExpression(value) {
2232
return new RegExp('^(' + value + ')$', 'i');
@@ -26,14 +36,14 @@ function toExpression(value) {
2636
* Wrap an expression into an assertion function.
2737
*
2838
* @param {RegExp} expression - Expression to test.
29-
* @return {Function}
39+
* @return {Function} - Assertion.
3040
*/
3141
function wrapExpression(expression) {
3242
/**
3343
* Assert `value` matches the bound `expression`.
3444
*
3545
* @param {string} value - Value to check.
36-
* @return {boolean}
46+
* @return {boolean} - Whether `value` matches.
3747
*/
3848
function assertion(value) {
3949
return expression.test(value);
@@ -46,7 +56,7 @@ function wrapExpression(expression) {
4656
* Check if `node` is a heading.
4757
*
4858
* @param {Node} node - Node to check.
49-
* @return {boolean}
59+
* @return {boolean} - Whether `node` is a heading.
5060
*/
5161
function isHeading(node) {
5262
return node && node.type === 'heading';
@@ -58,8 +68,8 @@ function isHeading(node) {
5868
* @param {Node} node - Node to check.
5969
* @param {number?} depth - Depth to search for.
6070
* @param {function(string): boolean} test - Tester.
61-
*
62-
* @return {boolean}
71+
* @return {boolean} - Whether `node` is an opening
72+
* heading.
6373
*/
6474
function isOpeningHeading(node, depth, test) {
6575
return depth === null && isHeading(node) && test(toString(node), node);
@@ -70,7 +80,8 @@ function isOpeningHeading(node, depth, test) {
7080
*
7181
* @param {Node} node - Node to check.
7282
* @param {number?} depth - Depth of the opening heading.
73-
* @return {boolean}
83+
* @return {boolean} - Whether `node` is a closing
84+
* heading.
7485
*/
7586
function isClosingHeading(node, depth) {
7687
return depth && isHeading(node) && node.depth <= depth;
@@ -154,7 +165,7 @@ function search(root, test, callback) {
154165
* search for.
155166
* @param {Function} callback - Callback invoked when
156167
* found.
157-
* @return {function(node)}
168+
* @return {function(node)} - Attacher.
158169
*/
159170
function wrapper(heading, callback) {
160171
var test = heading;

mdast-util-heading-range.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mdastUtilHeadingRange = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2+
/**
3+
* @author Titus Wormer
4+
* @copyright 2015 Titus Wormer
5+
* @license MIT
6+
* @module mdast:util:heading-range
7+
* @fileoverview Markdown heading as ranges in mdast.
8+
*/
9+
210
'use strict';
311

12+
/* eslint-env commonjs */
13+
414
/*
515
* Dependencies.
616
*/
@@ -17,7 +27,7 @@ var splice = [].splice;
1727
* Transform a string into an applicable expression.
1828
*
1929
* @param {string} value - Value to transform.
20-
* @return {RegExp}
30+
* @return {RegExp} - Expression.
2131
*/
2232
function toExpression(value) {
2333
return new RegExp('^(' + value + ')$', 'i');
@@ -27,14 +37,14 @@ function toExpression(value) {
2737
* Wrap an expression into an assertion function.
2838
*
2939
* @param {RegExp} expression - Expression to test.
30-
* @return {Function}
40+
* @return {Function} - Assertion.
3141
*/
3242
function wrapExpression(expression) {
3343
/**
3444
* Assert `value` matches the bound `expression`.
3545
*
3646
* @param {string} value - Value to check.
37-
* @return {boolean}
47+
* @return {boolean} - Whether `value` matches.
3848
*/
3949
function assertion(value) {
4050
return expression.test(value);
@@ -47,7 +57,7 @@ function wrapExpression(expression) {
4757
* Check if `node` is a heading.
4858
*
4959
* @param {Node} node - Node to check.
50-
* @return {boolean}
60+
* @return {boolean} - Whether `node` is a heading.
5161
*/
5262
function isHeading(node) {
5363
return node && node.type === 'heading';
@@ -59,8 +69,8 @@ function isHeading(node) {
5969
* @param {Node} node - Node to check.
6070
* @param {number?} depth - Depth to search for.
6171
* @param {function(string): boolean} test - Tester.
62-
*
63-
* @return {boolean}
72+
* @return {boolean} - Whether `node` is an opening
73+
* heading.
6474
*/
6575
function isOpeningHeading(node, depth, test) {
6676
return depth === null && isHeading(node) && test(toString(node), node);
@@ -71,7 +81,8 @@ function isOpeningHeading(node, depth, test) {
7181
*
7282
* @param {Node} node - Node to check.
7383
* @param {number?} depth - Depth of the opening heading.
74-
* @return {boolean}
84+
* @return {boolean} - Whether `node` is a closing
85+
* heading.
7586
*/
7687
function isClosingHeading(node, depth) {
7788
return depth && isHeading(node) && node.depth <= depth;
@@ -155,7 +166,7 @@ function search(root, test, callback) {
155166
* search for.
156167
* @param {Function} callback - Callback invoked when
157168
* found.
158-
* @return {function(node)}
169+
* @return {function(node)} - Attacher.
159170
*/
160171
function wrapper(heading, callback) {
161172
var test = heading;

test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @copyright 2015 Titus Wormer
44
* @license MIT
55
* @module mdast:util:heading-range:script
6-
* @fileoverview Markdown heading as ranges in mdast.
6+
* @fileoverview Test suite for `mdast-util-heading-range`.
77
*/
88

99
'use strict';
@@ -24,7 +24,7 @@ var heading = require('./');
2424
* @param {Object} t - Test.
2525
* @param {string} value - Value to process.
2626
* @param {*} options - configuration.
27-
* @return {string}
27+
* @return {string} - Processed value.
2828
*/
2929
function process(t, value, options) {
3030
return remark().use(function (processor, name) {
@@ -322,7 +322,8 @@ test('mdast-util-heading-range()', function (t) {
322322
remark().use(function (processor) {
323323
processor.use(heading('foo', function (start, nodes, end) {
324324
t.equal(nodes.length, 3);
325-
return [start].concat(nodes, end)
325+
326+
return [start].concat(nodes, end);
326327
}));
327328
}).process([
328329
'# Alpha',

0 commit comments

Comments
 (0)