From be0c4d71ef2cdc77b68b0467100b0dfc29c93f2a Mon Sep 17 00:00:00 2001 From: Robert Vitonsky Date: Fri, 25 Oct 2024 18:56:44 +0200 Subject: [PATCH 1/2] build: generate declaration files --- package-lock.json | 43 +++++++++++++++++++--- package.json | 1 + rollup.config.mjs | 92 ++++++++++++++++++++++++++--------------------- 3 files changed, 92 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index 41a9629..9568235 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "prettier": "^3.2.5", "rollup": "^4.14.0", "rollup-plugin-copy": "^3.5.0", + "rollup-plugin-dts": "^6.1.1", "ts-jest": "^29.1.2", "tslib": "^2.6.2", "typescript": "^5.4.3" @@ -1614,10 +1615,11 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", - "dev": true + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.25", @@ -7859,6 +7861,16 @@ "yallist": "^3.0.2" } }, + "node_modules/magic-string": { + "version": "0.30.12", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz", + "integrity": "sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -10064,6 +10076,29 @@ "node": ">=8" } }, + "node_modules/rollup-plugin-dts": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-6.1.1.tgz", + "integrity": "sha512-aSHRcJ6KG2IHIioYlvAOcEq6U99sVtqDDKVhnwt70rW6tsz3tv5OSjEiWcgzfsHdLyGXZ/3b/7b/+Za3Y6r1XA==", + "dev": true, + "license": "LGPL-3.0-only", + "dependencies": { + "magic-string": "^0.30.10" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/Swatinem" + }, + "optionalDependencies": { + "@babel/code-frame": "^7.24.2" + }, + "peerDependencies": { + "rollup": "^3.29.4 || ^4", + "typescript": "^4.5 || ^5.0" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", diff --git a/package.json b/package.json index 1cbddc6..f1a6715 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "prettier": "^3.2.5", "rollup": "^4.14.0", "rollup-plugin-copy": "^3.5.0", + "rollup-plugin-dts": "^6.1.1", "ts-jest": "^29.1.2", "tslib": "^2.6.2", "typescript": "^5.4.3" diff --git a/rollup.config.mjs b/rollup.config.mjs index 393a56b..2a1c5a1 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,46 +1,58 @@ import copy from 'rollup-plugin-copy'; +import dts from 'rollup-plugin-dts'; import typescript from '@rollup/plugin-typescript'; -export default { - input: 'src/index.ts', - output: { - dir: 'dist', - format: 'cjs', - }, - plugins: [ - typescript(), - copy({ - targets: [ - { - src: 'LICENSE', - dest: 'dist', - }, - { - src: 'README.md', - dest: 'dist', - }, - { - src: 'package.json', - dest: 'dist', - transform(content) { - const ignoredProps = ['devDependencies', 'scripts']; +export default [ + { + input: 'src/index.ts', + output: { + dir: 'dist', + format: 'cjs', + }, + plugins: [ + typescript(), + copy({ + targets: [ + { + src: 'LICENSE', + dest: 'dist', + }, + { + src: 'README.md', + dest: 'dist', + }, + { + src: 'package.json', + dest: 'dist', + transform(content) { + const ignoredProps = ['devDependencies', 'scripts']; - const json = JSON.parse(content.toString()); - return JSON.stringify( - { - ...Object.fromEntries( - Object.entries(json).filter( - ([key]) => !ignoredProps.includes(key), + const json = JSON.parse(content.toString()); + return JSON.stringify( + { + ...Object.fromEntries( + Object.entries(json).filter( + ([key]) => !ignoredProps.includes(key), + ), ), - ), - main: 'index.js', - }, - null, - 4, - ); + main: 'index.js', + }, + null, + 4, + ); + }, }, - }, - ], - }), - ], -}; + ], + }), + ], + }, + { + // Generate declaration file + input: 'src/index.ts', + output: { + file: 'dist/index.d.ts', + format: 'cjs', + }, + plugins: [dts()], + }, +]; From 36335068beea8ae797a881182f613c1a170c0382 Mon Sep 17 00:00:00 2001 From: Robert Vitonsky Date: Fri, 25 Oct 2024 18:57:22 +0200 Subject: [PATCH 2/2] chore: satisfy type instead of set --- src/rules/alias.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rules/alias.ts b/src/rules/alias.ts index 2f29a04..f7b9350 100644 --- a/src/rules/alias.ts +++ b/src/rules/alias.ts @@ -68,7 +68,7 @@ function findAlias( // TODO: implement option to force relative path instead of alias (for remove alias case) // TODO: add tests -const rule: Rule.RuleModule = { +const rule = { meta: { fixable: 'code', schema: { @@ -157,6 +157,6 @@ const rule: Rule.RuleModule = { }, }; }, -}; +} satisfies Rule.RuleModule; export default rule;