Skip to content

Commit fbc3854

Browse files
committed
Refactor code-style
1 parent 2b1211a commit fbc3854

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @typedef {import('hast').Element} Element
44
*/
55

6-
var search = /[#.]/g
6+
const search = /[#.]/g
77

88
/**
99
* Create a hast element from a simple CSS selector.
@@ -27,21 +27,17 @@ export const parseSelector =
2727
* @returns {Element}
2828
*/
2929
function (selector, defaultTagName = 'div') {
30-
var value = selector || ''
30+
const value = selector || ''
3131
/** @type {Properties} */
32-
var props = {}
33-
var start = 0
34-
/** @type {string} */
35-
var subvalue
36-
/** @type {string} */
37-
var previous
38-
/** @type {RegExpMatchArray} */
39-
var match
32+
const props = {}
33+
let start = 0
34+
/** @type {string|undefined} */
35+
let previous
4036

4137
while (start < value.length) {
4238
search.lastIndex = start
43-
match = search.exec(value)
44-
subvalue = value.slice(start, match ? match.index : value.length)
39+
const match = search.exec(value)
40+
const subvalue = value.slice(start, match ? match.index : value.length)
4541

4642
if (subvalue) {
4743
if (!previous) {

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@
7474
"trailingComma": "none"
7575
},
7676
"xo": {
77-
"prettier": true,
78-
"rules": {
79-
"no-var": "off",
80-
"prefer-arrow-callback": "off"
81-
}
77+
"prettier": true
8278
},
8379
"remarkConfig": {
8480
"plugins": [

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import test from 'tape'
22
import {parseSelector} from './index.js'
33

4-
test('parseSelector()', function (t) {
4+
test('parseSelector()', (t) => {
55
t.deepEqual(
66
parseSelector(),
77
{

0 commit comments

Comments
 (0)