Skip to content

Commit 6a0049c

Browse files
committed
Refactor code-style
1 parent 23e115a commit 6a0049c

File tree

4 files changed

+66
-122
lines changed

4 files changed

+66
-122
lines changed

.editorconfig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ root = true
22

33
[*]
44
indent_style = space
5-
indent_size = 4
5+
indent_size = 2
66
end_of_line = lf
77
charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
10-
11-
[*.{json,remarkrc,eslintrc,sh}]
12-
indent_size = 2
13-
14-
[*.md]
15-
trim_trailing_whitespace = false

index.js

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,18 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2016 Titus Wormer
4-
* @license MIT
5-
* @module rehype:lint:util:script-supporting
6-
*/
7-
81
'use strict';
92

10-
/* eslint-env commonjs */
11-
12-
/*
13-
* Dependencies.
14-
*/
3+
/* Expose. */
4+
module.exports = scriptSupporting;
155

6+
/* Dependencies. */
167
var is = require('hast-util-is-element');
178

18-
/*
19-
* Tag-names.
20-
*/
21-
9+
/* Tag-names. */
2210
var names = [
23-
'script',
24-
'template'
11+
'script',
12+
'template'
2513
];
2614

27-
/**
28-
* Check if a node is a script-supporting element
29-
*
30-
* @param {*} node - Thing to check.
31-
* @return {boolean} - Whether a node is script-supporting.
32-
*/
15+
/* Check if a node is a script-supporting element */
3316
function scriptSupporting(node) {
34-
return is(node, names);
17+
return is(node, names);
3518
}
36-
37-
/*
38-
* Expose.
39-
*/
40-
41-
module.exports = scriptSupporting;

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,31 @@
2929
],
3030
"devDependencies": {
3131
"browserify": "^13.0.0",
32-
"eslint": "^2.0.0",
3332
"esmangle": "^1.0.1",
3433
"istanbul": "^0.4.0",
35-
"jscs": "^3.0.0",
36-
"jscs-jsdoc": "^2.0.0",
3734
"remark": "^4.0.0",
3835
"remark-comment-config": "^3.0.0",
3936
"remark-github": "^4.0.1",
4037
"remark-lint": "^3.0.0",
4138
"remark-usage": "^3.0.0",
4239
"remark-validate-links": "^3.0.0",
43-
"tape": "^4.4.0"
40+
"tape": "^4.4.0",
41+
"xo": "^0.17.0"
4442
},
4543
"scripts": {
4644
"build-md": "remark . --quiet --frail",
4745
"build-bundle": "browserify index.js --bare -s hastUtilScriptSupporting > hast-util-script-supporting.js",
4846
"build-mangle": "esmangle hast-util-script-supporting.js > hast-util-script-supporting.min.js",
4947
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
50-
"lint-api": "eslint .",
51-
"lint-style": "jscs --reporter inline .",
52-
"lint": "npm run lint-api && npm run lint-style",
48+
"lint": "xo",
5349
"test-api": "node test.js",
5450
"test-coverage": "istanbul cover test.js",
5551
"test": "npm run build && npm run lint && npm run test-coverage"
52+
},
53+
"xo": {
54+
"space": true,
55+
"ignores": [
56+
"hast-util-is-element.js"
57+
]
5658
}
5759
}

test.js

Lines changed: 48 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,55 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2016 Titus Wormer
4-
* @license MIT
5-
* @module hast:util:script-supporting
6-
* @fileoverview Test suite for `script-supporting`.
7-
*/
8-
91
'use strict';
102

11-
/* eslint-env node */
12-
13-
/*
14-
* Module dependencies.
15-
*/
16-
3+
/* Dependencies. */
174
var test = require('tape');
185
var scriptSupporting = require('./index.js');
196

20-
/*
21-
* Tests.
22-
*/
23-
7+
/* Tests. */
248
test('scriptSupporting', function (t) {
25-
t.equal(
26-
scriptSupporting(),
27-
false,
28-
'should return `false` without node'
29-
);
30-
31-
t.equal(
32-
scriptSupporting(null),
33-
false,
34-
'should return `false` with `null`'
35-
);
36-
37-
t.equal(
38-
scriptSupporting({
39-
'type': 'text'
40-
}),
41-
false,
42-
'should return `false` when without `element`'
43-
);
44-
45-
t.equal(
46-
scriptSupporting({
47-
'type': 'element'
48-
}),
49-
false,
50-
'should return `false` when with invalid `element`'
51-
);
52-
53-
t.equal(
54-
scriptSupporting({
55-
'type': 'element',
56-
'tagName': 'a',
57-
'properties': {
58-
'href': '#alpha',
59-
'title': 'Bravo'
60-
},
61-
'children': [{
62-
'type': 'text',
63-
'value': 'Charlie'
64-
}]
65-
}),
66-
false,
67-
'should return `false` when without not script-supporting'
68-
);
69-
70-
t.equal(
71-
scriptSupporting({
72-
'type': 'element',
73-
'tagName': 'template',
74-
'children': [{
75-
'type': 'text',
76-
'value': 'Delta'
77-
}]
78-
}),
79-
true,
80-
'should return `true` when with script-supporting'
81-
);
82-
83-
t.end();
9+
t.equal(
10+
scriptSupporting(),
11+
false,
12+
'should return `false` without node'
13+
);
14+
15+
t.equal(
16+
scriptSupporting(null),
17+
false,
18+
'should return `false` with `null`'
19+
);
20+
21+
t.equal(
22+
scriptSupporting({type: 'text'}),
23+
false,
24+
'should return `false` when without `element`'
25+
);
26+
27+
t.equal(
28+
scriptSupporting({type: 'element'}),
29+
false,
30+
'should return `false` when with invalid `element`'
31+
);
32+
33+
t.equal(
34+
scriptSupporting({
35+
type: 'element',
36+
tagName: 'a',
37+
properties: {href: '#alpha', title: 'Bravo'},
38+
children: [{type: 'text', value: 'Charlie'}]
39+
}),
40+
false,
41+
'should return `false` when without not script-supporting'
42+
);
43+
44+
t.equal(
45+
scriptSupporting({
46+
type: 'element',
47+
tagName: 'template',
48+
children: [{type: 'text', value: 'Delta'}]
49+
}),
50+
true,
51+
'should return `true` when with script-supporting'
52+
);
53+
54+
t.end();
8455
});

0 commit comments

Comments
 (0)