File tree 4 files changed +50
-3
lines changed
4 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
+ * .d.ts
2
3
* .log
3
4
coverage /
4
5
node_modules /
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @typedef {import('hast').Properties } Properties
3
+ * @typedef {import('hast').Element } Element
4
+ */
5
+
1
6
var search = / [ # . ] / g
2
7
3
- // Create a hast element from a simple CSS selector.
8
+ /**
9
+ * Create a hast element from a simple CSS selector.
10
+ *
11
+ * @param {string } [selector]
12
+ * @param {string } [name='div']
13
+ * @returns {Element }
14
+ */
4
15
export function parseSelector ( selector , name = 'div' ) {
5
16
var value = selector || ''
17
+ /** @type {Properties } */
6
18
var props = { }
7
19
var start = 0
20
+ /** @type {string } */
8
21
var subvalue
22
+ /** @type {string } */
9
23
var previous
24
+ /** @type {RegExpMatchArray } */
10
25
var match
11
26
12
27
while ( start < value . length ) {
@@ -19,7 +34,7 @@ export function parseSelector(selector, name = 'div') {
19
34
name = subvalue
20
35
} else if ( previous === '#' ) {
21
36
props . id = subvalue
22
- } else if ( props . className ) {
37
+ } else if ( Array . isArray ( props . className ) ) {
23
38
props . className . push ( subvalue )
24
39
} else {
25
40
props . className = [ subvalue ]
Original file line number Diff line number Diff line change 27
27
"sideEffects" : false ,
28
28
"type" : " module" ,
29
29
"main" : " index.js" ,
30
+ "types" : " index.d.ts" ,
30
31
"files" : [
32
+ " index.d.ts" ,
31
33
" index.js"
32
34
],
35
+ "dependencies" : {
36
+ "@types/hast" : " ^2.0.0"
37
+ },
33
38
"devDependencies" : {
39
+ "@types/tape" : " ^4.0.0" ,
34
40
"c8" : " ^7.0.0" ,
35
41
"prettier" : " ^2.0.0" ,
36
42
"remark-cli" : " ^9.0.0" ,
37
43
"remark-preset-wooorm" : " ^8.0.0" ,
44
+ "rimraf" : " ^3.0.0" ,
38
45
"tape" : " ^5.0.0" ,
46
+ "type-coverage" : " ^2.0.0" ,
47
+ "typescript" : " ^4.0.0" ,
39
48
"xo" : " ^0.39.0"
40
49
},
41
50
"scripts" : {
51
+ "prepack" : " npm run build && npm run format" ,
52
+ "build" : " rimraf \" *.d.ts\" && tsc && type-coverage" ,
42
53
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
43
54
"test-api" : " node test.js" ,
44
55
"test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js" ,
45
- "test" : " npm run format && npm run test-coverage"
56
+ "test" : " npm run build && npm run format && npm run test-coverage"
46
57
},
47
58
"prettier" : {
48
59
"tabWidth" : 2 ,
63
74
"plugins" : [
64
75
" preset-wooorm"
65
76
]
77
+ },
78
+ "typeCoverage" : {
79
+ "atLeast" : 100 ,
80
+ "detail" : true ,
81
+ "strict" : true
66
82
}
67
83
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "include" : [" *.js" ],
3
+ "compilerOptions" : {
4
+ "target" : " ES2020" ,
5
+ "lib" : [" ES2020" ],
6
+ "module" : " ES2020" ,
7
+ "moduleResolution" : " node" ,
8
+ "allowJs" : true ,
9
+ "checkJs" : true ,
10
+ "declaration" : true ,
11
+ "emitDeclarationOnly" : true ,
12
+ "allowSyntheticDefaultImports" : true ,
13
+ "skipLibCheck" : true
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments