Skip to content

Commit 637b712

Browse files
committed
Remove index.mjs and fix type declarations
1 parent d1f6a41 commit 637b712

File tree

7 files changed

+58
-85
lines changed

7 files changed

+58
-85
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# build target
2-
/index.mjs
3-
41
# test
52
/.tap
63

index.d.ts

+54-55
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,65 @@ interface PatternParams {
1717
mark?: string
1818
}
1919

20-
export interface Ignore {
21-
/**
22-
* Adds one or several rules to the current manager.
23-
* @param {string[]} patterns
24-
* @returns IgnoreBase
25-
*/
26-
add(
27-
patterns: string | Ignore | readonly (string | Ignore)[] | PatternParams
28-
): this
29-
30-
/**
31-
* Filters the given array of pathnames, and returns the filtered array.
32-
* NOTICE that each path here should be a relative path to the root of your repository.
33-
* @param paths the array of paths to be filtered.
34-
* @returns The filtered array of paths
35-
*/
36-
filter(pathnames: readonly Pathname[]): Pathname[]
20+
/**
21+
* Creates new ignore manager.
22+
*/
23+
declare function ignore(options?: ignore.Options): ignore.Ignore
24+
declare namespace ignore {
25+
interface Ignore {
26+
/**
27+
* Adds one or several rules to the current manager.
28+
* @param {string[]} patterns
29+
* @returns IgnoreBase
30+
*/
31+
add(
32+
patterns: string | Ignore | readonly (string | Ignore)[] | PatternParams
33+
): this
3734

38-
/**
39-
* Creates a filter function which could filter
40-
* an array of paths with Array.prototype.filter.
41-
*/
42-
createFilter(): (pathname: Pathname) => boolean
35+
/**
36+
* Filters the given array of pathnames, and returns the filtered array.
37+
* NOTICE that each path here should be a relative path to the root of your repository.
38+
* @param paths the array of paths to be filtered.
39+
* @returns The filtered array of paths
40+
*/
41+
filter(pathnames: readonly Pathname[]): Pathname[]
4342

44-
/**
45-
* Returns Boolean whether pathname should be ignored.
46-
* @param {string} pathname a path to check
47-
* @returns boolean
48-
*/
49-
ignores(pathname: Pathname): boolean
43+
/**
44+
* Creates a filter function which could filter
45+
* an array of paths with Array.prototype.filter.
46+
*/
47+
createFilter(): (pathname: Pathname) => boolean
5048

51-
/**
52-
* Returns whether pathname should be ignored or unignored
53-
* @param {string} pathname a path to check
54-
* @returns TestResult
55-
*/
56-
test(pathname: Pathname): TestResult
49+
/**
50+
* Returns Boolean whether pathname should be ignored.
51+
* @param {string} pathname a path to check
52+
* @returns boolean
53+
*/
54+
ignores(pathname: Pathname): boolean
5755

58-
/**
59-
* Debugs ignore rules and returns the checking result, which is
60-
* equivalent to `git check-ignore -v`.
61-
* @returns TestResult
62-
*/
63-
checkIgnore(pathname: Pathname): TestResult
64-
}
56+
/**
57+
* Returns whether pathname should be ignored or unignored
58+
* @param {string} pathname a path to check
59+
* @returns TestResult
60+
*/
61+
test(pathname: Pathname): TestResult
6562

66-
export interface Options {
67-
ignorecase?: boolean
68-
// For compatibility
69-
ignoreCase?: boolean
70-
allowRelativePaths?: boolean
71-
}
63+
/**
64+
* Debugs ignore rules and returns the checking result, which is
65+
* equivalent to `git check-ignore -v`.
66+
* @returns TestResult
67+
*/
68+
checkIgnore(pathname: Pathname): TestResult
69+
}
7270

73-
/**
74-
* Creates new ignore manager.
75-
*/
76-
declare function ignore(options?: Options): Ignore
77-
declare function isPathValid (pathname: string): boolean
71+
interface Options {
72+
ignorecase?: boolean
73+
// For compatibility
74+
ignoreCase?: boolean
75+
allowRelativePaths?: boolean
76+
}
7877

79-
export default ignore
80-
export {
81-
isPathValid
78+
function isPathValid(pathname: string): boolean
8279
}
80+
81+
export = ignore

index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,6 @@ const factory = options => new Ignore(options)
739739
const isPathValid = path =>
740740
checkPath(path && checkPath.convert(path), path, RETURN_FALSE)
741741

742-
factory.isPathValid = isPathValid
743-
744742

745743
// Windows
746744
// --------------------------------------------------------------
@@ -771,7 +769,5 @@ if (
771769

772770
// COMMONJS_EXPORTS ////////////////////////////////////////////////////////////
773771

774-
// Fixes typescript
775-
factory.default = factory
776-
777772
module.exports = factory
773+
module.exports.isPathValid = isPathValid

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
"version": "7.0.0",
44
"description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",
55
"main": "index.js",
6-
"module": "index.mjs",
76
"types": "index.d.ts",
87
"files": [
98
"legacy.js",
109
"index.js",
11-
"index.mjs",
1210
"index.d.ts",
1311
"LICENSE-MIT"
1412
],
1513
"scripts": {
1614
"prepublishOnly": "npm run build",
17-
"build": "babel -o legacy.js index.js && node ./scripts/build.js",
15+
"build": "babel -o legacy.js index.js",
1816
"test:lint": "eslint .",
1917
"test:ts": "ts-node ./test/ts/simple.ts",
2018
"test:ts:16": "ts-node --compilerOptions '{\"moduleResolution\": \"Node16\", \"module\": \"Node16\"}' ./test/ts/simple.ts",

scripts/build.js

-18
This file was deleted.

test/ts/simple.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ignore, {isPathValid} from '../../index.mjs' // eslint-disable-line import/extensions
1+
import ignore, {isPathValid} from '../../index.js' // eslint-disable-line import/extensions
22

33
const equal = (actual, expect, message) => {
44
if (actual !== expect) {

test/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"compilerOptions": {
3+
"esModuleInterop": true
34
}
45
}

0 commit comments

Comments
 (0)