Skip to content

Commit

Permalink
feat: generate .d.ts files on publishing
Browse files Browse the repository at this point in the history
Fixes #24
  • Loading branch information
haoqunjiang committed Oct 23, 2024
1 parent 8784cfb commit c75ff34
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
index.d.ts
skip-formatting.d.ts
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const recommendedConfig = require("eslint-plugin-prettier/recommended");

/** @type {import('eslint').Linter.Config} */
module.exports = {
...recommendedConfig,
rules: {
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"main": "index.js",
"files": [
"index.js",
"skip-formatting.js"
"index.d.ts",
"skip-formatting.js",
"skip-formatting.d.ts"
],
"exports": {
".": "./index.js",
Expand Down Expand Up @@ -38,14 +40,16 @@
},
"devDependencies": {
"eslint": "^9.11.0",
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"typescript": "^5.6.3"
},
"peerDependencies": {
"eslint": ">= 8.21.0",
"prettier": ">= 3.0.0"
},
"scripts": {
"lint": "eslint . --fix",
"format": "prettier *.{js,md} --write"
"format": "prettier *.{js,md} --write",
"prepublishOnly": "tsc"
}
}
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions skip-formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const eslintConfigPrettier = require("eslint-config-prettier");
// Because that would be an overkill:
// - since we are not formatting, the plugin isn't needed;
// - and without the `prettier/prettier` rule, we don't have to disable the conflicting `arrow-body-style` and `prefer-arrow-callback` rules.

/** @type {import('eslint').Linter.Config} */
module.exports = {
...eslintConfigPrettier,
rules: {
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"include": ["index.js", "skip-formatting.js"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"skipLibCheck": true
}
}

0 comments on commit c75ff34

Please sign in to comment.