1- 'use strict'
2-
3- const deglob = require ( 'deglob' )
4- const find = require ( 'find-file-up' )
5- const Githost = require ( 'find-githost' )
6- const engine = require ( 'unified-engine' )
7- const color = require ( 'supports-color' ) . stdout
8- const fromCallback = require ( 'catering' ) . fromCallback
9- const processor = require ( 'remark' )
10- const path = require ( 'path' )
11- const fs = require ( 'fs' )
1+ import deglob from 'deglob'
2+ import find from 'find-file-up'
3+ import Githost from 'find-githost'
4+ import engine from 'unified-engine'
5+ import { stdout as color } from 'supports-color'
6+ import { fromCallback } from 'catering'
7+ import defaultReporter from 'vfile-reporter-shiny'
8+ import processor from 'remark'
9+ import remarkCommonChangelog from 'remark-common-changelog'
10+ import remarkGithub from 'remark-github'
11+ import remarkAutolinkReferences from 'remark-autolink-references'
12+ import remarkToc from 'remark-toc'
13+ import remarkCollapse from 'remark-collapse'
14+ import path from 'node:path'
15+ import fs from 'node:fs'
16+ import linter from './lint.js'
1217
1318const kPromise = Symbol ( 'promise' )
1419
@@ -46,7 +51,7 @@ function hallmark (options, callback) {
4651 reporter = reporter . _ [ 0 ]
4752 }
4853 } else {
49- reporter = require ( 'vfile-reporter-shiny' )
54+ reporter = defaultReporter
5055 }
5156
5257 const paddedTable = rc . paddedTable !== false
@@ -73,23 +78,23 @@ function hallmark (options, callback) {
7378 reporter,
7479 reporterOptions,
7580 plugins : [
76- [ require ( 'remark-common-changelog' ) , { cwd, fix, pkg, repository, ...changelog } ] ,
77- [ require ( 'remark-github' ) , { repository } ] ,
81+ [ remarkCommonChangelog , { cwd, fix, pkg, repository, ...changelog } ] ,
82+ [ remarkGithub , { repository } ] ,
7883
7984 // Does nothing unless configured
8085 rc . autolinkReferences
81- ? [ require ( 'remark-autolink-references' ) , {
86+ ? [ remarkAutolinkReferences , {
8287 ...rc . autolinkReferences ,
8388 fix
8489 } ]
8590 : null ,
8691
8792 // TODO: https://github.com/vweevers/hallmark/issues/36
88- toc ? [ require ( 'remark-toc' ) , { tight : true } ] : null ,
89- toc ? [ require ( 'remark-collapse' ) , collapseToc ( ) ] : null ,
93+ toc ? [ remarkToc , { tight : true } ] : null ,
94+ toc ? [ remarkCollapse , collapseToc ( ) ] : null ,
9095
9196 fix ? fixers : null ,
92- require ( './lint.js' ) ( { fix, repository, paddedTable, validateLinks } ) ,
97+ linter ( { fix, repository, paddedTable, validateLinks } ) ,
9398 plugins
9499 ] . filter ( Boolean ) ,
95100 settings : {
@@ -121,7 +126,7 @@ function hallmark (options, callback) {
121126 return callback [ kPromise ]
122127}
123128
124- exports . lint = function ( options , callback ) {
129+ export function lint ( options , callback ) {
125130 if ( typeof options === 'function' ) {
126131 callback = options
127132 options = { }
@@ -130,7 +135,7 @@ exports.lint = function (options, callback) {
130135 return hallmark ( { ...options , fix : false } , callback )
131136}
132137
133- exports . fix = function ( options , callback ) {
138+ export function fix ( options , callback ) {
134139 if ( typeof options === 'function' ) {
135140 callback = options
136141 options = { }
@@ -139,28 +144,29 @@ exports.fix = function (options, callback) {
139144 return hallmark ( { ...options , fix : true } , callback )
140145}
141146
142- exports . cc = { }
143- exports . cc . add = function ( target , options , callback ) {
144- if ( ! target ) {
145- throw new TypeError ( 'First argument "target" is required' )
146- } else if ( typeof target !== 'string' ) {
147- throw new TypeError ( 'First argument "target" must be a string' )
148- }
147+ export const cc = {
148+ add : function ( target , options , callback ) {
149+ if ( ! target ) {
150+ throw new TypeError ( 'First argument "target" is required' )
151+ } else if ( typeof target !== 'string' ) {
152+ throw new TypeError ( 'First argument "target" must be a string' )
153+ }
149154
150- if ( typeof options === 'function' ) {
151- callback = options
152- options = { }
153- } else if ( options == null ) {
154- options = { }
155- }
155+ if ( typeof options === 'function' ) {
156+ callback = options
157+ options = { }
158+ } else if ( options == null ) {
159+ options = { }
160+ }
156161
157- const changelog = {
158- commits : options . commits !== false ,
159- ...options . changelog ,
160- add : target
161- }
162+ const changelog = {
163+ commits : options . commits !== false ,
164+ ...options . changelog ,
165+ add : target
166+ }
162167
163- return hallmark ( { ...options , changelog, fix : true } , callback )
168+ return hallmark ( { ...options , changelog, fix : true } , callback )
169+ }
164170}
165171
166172function read ( file , cwd ) {
0 commit comments