Skip to content

Commit 49a544c

Browse files
committed
feat: added type declarations
/spend 10m
1 parent 7049063 commit 49a544c

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

commitlint.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { type UserConfig } from '@commitlint/types';
22
import spendPlugin from './index';
33

4-
export default {
4+
const config: UserConfig = {
55
extends: [`@commitlint/config-conventional`],
66
rules: {
77
spend: [2, `always`],
88
},
99
plugins: [spendPlugin],
10-
} satisfies UserConfig;
10+
};
11+
12+
export default config;

index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { Plugin } from '@commitlint/types';
22
import { validateCommitMsg } from './src/utils/validateCommitMsg/validateCommitMsg';
33

4-
export default {
4+
const spendPlugin: Plugin = {
55
rules: {
66
spend: validateCommitMsg,
77
},
8-
} satisfies Plugin;
8+
};
9+
10+
export default spendPlugin;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"url": "https://github.com/nico-i/commitlint-plugin-spend/issues"
3535
},
3636
"scripts": {
37-
"build": "bun build ./index.ts --outdir ./out --minify",
37+
"build": "bun build ./index.ts --outdir ./out --minify && bunx tsc",
3838
"lint": "eslint . --ext .ts && prettier . --check",
3939
"lint:fix": "eslint . --ext .ts --fix && prettier . --write",
4040
"prepare": "husky || true"

src/types/SpendCommand/SpendCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type SpendCommand = (typeof spendingCommands)[number];
88

99
export const spendCommandPattern = new RegExp(
1010
`^(${spendingCommands.join(`|`)})$`,
11-
);
11+
) as RegExp;
1212

1313
export function isSpendCommand(value: string): value is SpendCommand {
1414
return spendingCommands.includes(value as SpendCommand);

src/types/TimeValue/TimeValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type TimeValue = `${number}${TimeUnit}`;
2121
*/
2222
export const timeValuePattern = new RegExp(
2323
`^(\\d{1,2})(${orderedTimeUnits.join(`|`)})$`,
24-
);
24+
) as RegExp;
2525

2626
export function isTimeValue(value: string): value is TimeValue {
2727
return timeValuePattern.test(value);

tsconfig.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2+
"include": ["src/**/*", "index.ts"],
23
"compilerOptions": {
34
// Environment setup & latest features
45
"lib": ["ESNext"],
56
"target": "ESNext",
67
"module": "Preserve",
78
"moduleDetection": "force",
89
"jsx": "react-jsx",
9-
"allowJs": true,
1010

1111
// Bundler mode
1212
"moduleResolution": "bundler",
13-
"allowImportingTsExtensions": true,
1413
"verbatimModuleSyntax": true,
15-
"noEmit": true,
14+
"emitDeclarationOnly": true,
15+
"isolatedDeclarations": true,
1616

1717
// Best practices
1818
"strict": true,
@@ -24,6 +24,9 @@
2424
// Some stricter flags (disabled by default)
2525
"noUnusedLocals": false,
2626
"noUnusedParameters": false,
27-
"noPropertyAccessFromIndexSignature": false
27+
"noPropertyAccessFromIndexSignature": false,
28+
29+
"declaration": true,
30+
"outDir": "out"
2831
}
2932
}

0 commit comments

Comments
 (0)