Skip to content

Commit e2fa2fd

Browse files
committed
Refactor code-style
1 parent 0f64921 commit e2fa2fd

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

index.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* @property {HtmlNode|CommentNode} node
1818
*/
1919

20-
var commentExpression = /\s*([a-zA-Z\d-]+)(\s+([\s\S]*))?\s*/
20+
const commentExpression = /\s*([a-zA-Z\d-]+)(\s+([\s\S]*))?\s*/
2121

22-
var markerExpression = new RegExp(
22+
const markerExpression = new RegExp(
2323
'(\\s*<!--' + commentExpression.source + '-->\\s*)'
2424
)
2525

@@ -29,30 +29,23 @@ var markerExpression = new RegExp(
2929
* @returns {Marker|null}
3030
*/
3131
export function commentMarker(node) {
32-
/** @type {RegExpMatchArray} */
33-
var match
34-
/** @type {number} */
35-
var offset
36-
/** @type {MarkerParameters} */
37-
var parameters
38-
3932
if (
4033
node &&
4134
typeof node === 'object' &&
4235
// @ts-ignore hush
4336
(node.type === 'html' || node.type === 'comment')
4437
) {
4538
// @ts-ignore hush
46-
match = node.value.match(
39+
const match = node.value.match(
4740
// @ts-ignore hush
4841
node.type === 'comment' ? commentExpression : markerExpression
4942
)
5043

5144
// @ts-ignore hush
5245
if (match && match[0].length === node.value.length) {
5346
// @ts-ignore hush
54-
offset = node.type === 'comment' ? 1 : 2
55-
parameters = parseParameters(match[offset + 1] || '')
47+
const offset = node.type === 'comment' ? 1 : 2
48+
const parameters = parseParameters(match[offset + 1] || '')
5649

5750
if (parameters) {
5851
return {
@@ -77,7 +70,7 @@ export function commentMarker(node) {
7770
*/
7871
function parseParameters(value) {
7972
/** @type {MarkerParameters} */
80-
var parameters = {}
73+
const parameters = {}
8174

8275
return value
8376
.replace(
@@ -98,7 +91,7 @@ function parseParameters(value) {
9891
// eslint-disable-next-line max-params
9992
function replacer(_, $1, $2, $3, $4) {
10093
/** @type {MarkerParameterValue} */
101-
var value = $2 || $3 || $4 || ''
94+
let value = $2 || $3 || $4 || ''
10295

10396
if (value === 'true' || value === '') {
10497
value = true

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@
6161
"trailingComma": "none"
6262
},
6363
"xo": {
64-
"prettier": true,
65-
"rules": {
66-
"no-var": "off",
67-
"prefer-arrow-callback": "off"
68-
}
64+
"prettier": true
6965
},
7066
"remarkConfig": {
7167
"plugins": [

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import test from 'tape'
88
import {commentMarker} from './index.js'
99

10-
test('commentMaker(node)', function (t) {
10+
test('commentMaker(node)', (t) => {
1111
t.equal(commentMarker(), null, 'should work without node')
1212

1313
/** @type {Paragraph} */
@@ -145,7 +145,7 @@ test('commentMaker(node)', function (t) {
145145
t.end()
146146
})
147147

148-
test('comment node', function (t) {
148+
test('comment node', (t) => {
149149
/** @type {Literal & {type: 'comment'}} */
150150
let comment = {type: 'comment', value: ' '}
151151

0 commit comments

Comments
 (0)