Skip to content

Commit 05026ce

Browse files
refactor: convert project to ESM
1 parent 61fc1b6 commit 05026ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2140
-2545
lines changed

__tests__/bin-readme.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
const path = require('path');
2-
const exec = require('child_process').exec;
3-
const tmp = require('tmp');
4-
const fs = require('fs-extra');
1+
import path from 'path';
2+
import { exec } from 'child_process';
3+
import tmp from 'tmp';
4+
import fs from 'fs-extra';
5+
import { fileURLToPath } from 'url';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
59

610
function documentation(args, options, parseJSON) {
711
return new Promise((resolve, reject) => {

__tests__/bin-watch-serve.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const path = require('path');
2-
const os = require('os');
3-
const get = require('./utils').get;
4-
const spawn = require('child_process').spawn;
5-
const fs = require('fs');
6-
const pEvent = require('p-event');
1+
import path from 'path';
2+
import os from 'os';
3+
import { get } from './utils';
4+
import { spawn } from 'child_process';
5+
import fs from 'fs';
6+
import pEvent from 'p-event';
77

88
function documentation(args, options) {
99
if (!options) {

__tests__/bin.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* global jasmine */
22

3-
const path = require('path');
4-
const os = require('os');
5-
const exec = require('child_process').exec;
6-
const tmp = require('tmp');
7-
const fs = require('fs-extra');
3+
import path from 'path';
4+
import os from 'os';
5+
import { exec } from 'child_process';
6+
import tmp from 'tmp';
7+
import fs from 'fs-extra';
88

99
function documentation(args, options, parseJSON) {
1010
if (!options) {
@@ -157,7 +157,8 @@ describe('invalid arguments', function () {
157157
});
158158
});
159159

160-
const semver = /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
160+
const semver =
161+
/\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
161162
test.skip('--config', async function () {
162163
const dst = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
163164
fs.mkdirSync(dst);

__tests__/format_type.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/*eslint max-len: 0 */
22

3-
const _formatType = require('../src/output/util/format_type');
4-
const LinkerStack = require('../src/output/util/linker_stack');
5-
const remark = require('remark');
6-
const parse = require('doctrine-temporary-fork').parse;
3+
import _formatType from '../src/output/util/format_type.js';
4+
import LinkerStack from '../src/output/util/linker_stack';
5+
import remark from 'remark';
6+
import doctrine from 'doctrine-temporary-fork';
7+
const parse = doctrine.parse;
78

89
function stringify(children) {
910
return remark().stringify({

__tests__/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const documentation = require('../src/');
2-
const os = require('os');
3-
const path = require('path');
4-
const fs = require('fs');
1+
import * as documentation from '../src/index.js';
2+
import os from 'os';
3+
import path from 'path';
4+
import fs from 'fs';
55

66
function inputs(contents) {
77
const dirEntry = os.tmpdir();

__tests__/lib/filter_access.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const filterAccess = require('../../src/filter_access');
1+
import filterAccess from '../../src/filter_access.js';
22

3-
test('filterAccess ignore', function() {
3+
test('filterAccess ignore', function () {
44
expect(
55
filterAccess(
66
['public', 'protected', 'undefined'],
@@ -14,7 +14,7 @@ test('filterAccess ignore', function() {
1414
).toEqual([]);
1515
});
1616

17-
test('filterAccess public, protected, undefined, no private', function() {
17+
test('filterAccess public, protected, undefined, no private', function () {
1818
expect(
1919
filterAccess(
2020
['public', 'protected', 'undefined'],
@@ -46,7 +46,7 @@ test('filterAccess public, protected, undefined, no private', function() {
4646
]);
4747
});
4848

49-
test('filterAccess explicit public', function() {
49+
test('filterAccess explicit public', function () {
5050
expect(
5151
filterAccess(
5252
['public'],
@@ -64,7 +64,7 @@ test('filterAccess explicit public', function() {
6464
]);
6565
});
6666

67-
test('filterAccess override', function() {
67+
test('filterAccess override', function () {
6868
expect(
6969
filterAccess(
7070
['private'],
@@ -81,7 +81,7 @@ test('filterAccess override', function() {
8181
]);
8282
});
8383

84-
test('filterAccess nesting', function() {
84+
test('filterAccess nesting', function () {
8585
expect(
8686
filterAccess(
8787
['public', 'protected', 'undefined'],

__tests__/lib/flow_doctrine.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const flowDoctrine = require('../../src/flow_doctrine.js');
2-
const parse = require('../../src/parsers/javascript');
3-
const FLOW_TYPES = require('@babel/types').FLOW_TYPES;
1+
import flowDoctrine from '../../src/flow_doctrine.js';
2+
import parse from '../../src/parsers/javascript';
3+
import { FLOW_TYPES } from '@babel/types';
44

55
function toComment(fn, filename) {
66
return parse(
@@ -12,8 +12,8 @@ function toComment(fn, filename) {
1212
)[0];
1313
}
1414

15-
test('flowDoctrine', function() {
16-
const types = FLOW_TYPES.filter(function(type) {
15+
test('flowDoctrine', function () {
16+
const types = FLOW_TYPES.filter(function (type) {
1717
return type.match(/\wTypeAnnotation$/);
1818
});
1919

__tests__/lib/git/find_git.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
const mock = require('mock-fs');
2-
const mockRepo = require('../../utils').mockRepo;
3-
const path = require('path');
4-
const findGit = require('../../../src/git/find_git');
1+
import mock from 'mock-fs';
2+
import { mockRepo } from '../../utils.js';
3+
import path from 'path';
4+
import findGit from '../../../src/git/find_git.js';
5+
import { fileURLToPath } from 'url';
56

6-
test('findGit', function() {
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
10+
test('findGit', function () {
711
mock(mockRepo.master);
812
const root =
913
path.parse(__dirname).root + path.join('my', 'repository', 'path');

__tests__/lib/git/url_prefix.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
const mock = require('mock-fs');
2-
const mockRepo = require('../../utils').mockRepo;
3-
const getGithubURLPrefix = require('../../../src/git/url_prefix');
4-
const parsePackedRefs = getGithubURLPrefix.parsePackedRefs;
1+
import mock from 'mock-fs';
2+
import { mockRepo } from '../../utils.js';
3+
import {
4+
getGithubURLPrefix,
5+
parsePackedRefs
6+
} from '../../../src/git/url_prefix.js';
57

6-
test('getGithubURLPrefix', function() {
8+
test('getGithubURLPrefix', function () {
79
mock(mockRepo.master);
810
const masterUrl = getGithubURLPrefix({
911
git: '/my/repository/path/.git',
@@ -34,7 +36,7 @@ test('getGithubURLPrefix', function() {
3436
expect(submoduleUrl).toBe('https://github.com/foo/bar/blob/this_is_the_sha/');
3537
});
3638

37-
test('parsePackedRefs', function() {
39+
test('parsePackedRefs', function () {
3840
const input =
3941
'# pack-refs with: peeled fully-peeled\n' +
4042
'4acd658617928bd17ae7364ef2512630d97c007a refs/heads/babel-6\n' +

__tests__/lib/github.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/* eslint no-unused-vars: 0 */
2+
import mock from 'mock-fs';
3+
import path from 'path';
4+
import { mockRepo } from '../utils.js';
5+
import parse from '../../src/parsers/javascript.js';
6+
import github from '../../src/github.js';
7+
import { fileURLToPath } from 'url';
28

3-
const mock = require('mock-fs');
4-
const path = require('path');
5-
const mockRepo = require('../utils').mockRepo;
6-
const parse = require('../../src/parsers/javascript');
7-
const github = require('../../src/github');
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = path.dirname(__filename);
811

912
// mock-fs is causing some unusual side effects with jest-resolve
1013
// not being able to resolve modules so we've disabled these tests
@@ -29,15 +32,15 @@ function evaluate(fn) {
2932
);
3033
}
3134

32-
afterEach(function() {
35+
afterEach(function () {
3336
mock.restore();
3437
});
3538

36-
test.skip('github', function() {
39+
test.skip('github', function () {
3740
mock(mockRepo.master);
3841

3942
expect(
40-
evaluate(function() {
43+
evaluate(function () {
4144
/**
4245
* get one
4346
* @returns {number} one
@@ -52,11 +55,11 @@ test.skip('github', function() {
5255
});
5356
});
5457

55-
test.skip('malformed repository', function() {
58+
test.skip('malformed repository', function () {
5659
mock(mockRepo.malformed);
5760

5861
expect(
59-
evaluate(function() {
62+
evaluate(function () {
6063
/**
6164
* get one
6265
* @returns {number} one
@@ -68,11 +71,11 @@ test.skip('malformed repository', function() {
6871
).toBe(undefined);
6972
});
7073

71-
test.skip('enterprise repository', function() {
74+
test.skip('enterprise repository', function () {
7275
mock(mockRepo.enterprise);
7376

7477
expect(
75-
evaluate(function() {
78+
evaluate(function () {
7679
/**
7780
* get one
7881
* @returns {number} one
@@ -83,16 +86,15 @@ test.skip('enterprise repository', function() {
8386
})[0].context.github
8487
).toEqual({
8588
path: 'index.js',
86-
url:
87-
'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
89+
url: 'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
8890
});
8991
});
9092

91-
test.skip('typedef', function() {
93+
test.skip('typedef', function () {
9294
mock(mockRepo.master);
9395

9496
expect(
95-
evaluate(function() {
97+
evaluate(function () {
9698
/**
9799
* A number, or a string containing a number.
98100
* @typedef {(number|string)} NumberLike

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy