File tree Expand file tree Collapse file tree 5 files changed +52
-2
lines changed Expand file tree Collapse file tree 5 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 11.DS_Store 
2+ * .d.ts 
23* .log 
34coverage /
45node_modules /
Original file line number Diff line number Diff line change 1+ /** 
2+  * @typedef  {import('mdast').Heading } Heading 
3+  * @typedef  {'atx'|'atx-closed'|'setext' } Style 
4+  */ 
5+ 
6+ /** 
7+  * @param  {Heading } node 
8+  * @param  {Style } [relative] 
9+  * @returns  {Style|null } 
10+  */ 
111export  function  headingStyle ( node ,  relative )  { 
212  var  last  =  node . children [ node . children . length  -  1 ] 
313  var  depth  =  node . depth 
@@ -30,7 +40,13 @@ export function headingStyle(node, relative) {
3040  return  consolidate ( depth ,  relative ) 
3141} 
3242
33- // Get the probable style of an atx-heading, depending on preferred style. 
43+ /** 
44+  * Get the probable style of an atx-heading, depending on preferred style. 
45+  * 
46+  * @param  {number } depth 
47+  * @param  {Style } relative 
48+  * @returns  {Style|null } 
49+  */ 
3450function  consolidate ( depth ,  relative )  { 
3551  return  depth  <  3 
3652    ? 'atx' 
Original file line number Diff line number Diff line change 2727  "sideEffects" : false ,
2828  "type" : " module" 
2929  "main" : " index.js" 
30+   "types" : " index.d.ts" 
3031  "files" : [
32+     " index.d.ts" 
3133    " index.js" 
3234  ],
35+   "dependencies" : {
36+     "@types/mdast" : " ^3.0.0" 
37+   },
3338  "devDependencies" : {
39+     "@types/tape" : " ^4.0.0" 
3440    "c8" : " ^7.0.0" 
3541    "prettier" : " ^2.0.0" 
3642    "remark" : " ^13.0.0" 
3743    "remark-cli" : " ^9.0.0" 
3844    "remark-preset-wooorm" : " ^8.0.0" 
45+     "rimraf" : " ^3.0.0" 
3946    "tape" : " ^5.0.0" 
47+     "type-coverage" : " ^2.0.0" 
48+     "typescript" : " ^4.0.0" 
4049    "xo" : " ^0.39.0" 
4150  },
4251  "scripts" : {
52+     "prepack" : " npm run build && npm run format" 
53+     "build" : " rimraf \" *.d.ts\"  && tsc && type-coverage" 
4354    "format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" 
4455    "test-api" : " node test.js" 
4556    "test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js" 
46-     "test" : " npm run format && npm run test-coverage" 
57+     "test" : " npm run build && npm run  format && npm run test-coverage" 
4758  },
4859  "prettier" : {
4960    "tabWidth" : 2 ,
6475    "plugins" : [
6576      " preset-wooorm" 
6677    ]
78+   },
79+   "typeCoverage" : {
80+     "atLeast" : 100 ,
81+     "detail" : true ,
82+     "strict" : true 
6783  }
6884}
Original file line number Diff line number Diff line change @@ -4,10 +4,12 @@ import {headingStyle} from './index.js'
44
55test ( 'headingStyle' ,  function  ( t )  { 
66  t . throws ( function  ( )  { 
7+     // @ts -ignore runtime. 
78    headingStyle ( ) 
89  } ,  'should fail without node' ) 
910
1011  t . equal ( 
12+     // @ts -ignore runtime. 
1113    headingStyle ( { 
1214      type : 'heading' , 
1315      children : [ { type : 'text' ,  value : 'foo' } ] 
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