-
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: validate type comments and generate .d.ts
#204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
c6a385f
d24cd96
b430a97
94d9faf
5b7ea93
722f27e
5a7e9a2
fe80e3c
82a1134
dbbf50d
a3abcf9
77cff12
33adae4
fece1fa
b156b09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
!.vitepress | ||
/docs/.vitepress/dist | ||
/docs/.vitepress/cache | ||
/dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,12 @@ | |
module.exports = { | ||
root: true, | ||
extends: ["plugin:@eslint-community/mysticatea/es2020"], | ||
parserOptions: { | ||
project: "./tsconfig.json", | ||
}, | ||
rules: { | ||
semi: ["error", "never"], | ||
"semi-spacing": ["error", { before: false, after: true }], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's something deeply funny to me about an |
||
"@eslint-community/mysticatea/prettier": "off", | ||
"no-restricted-properties": [ | ||
"error", | ||
|
@@ -18,7 +23,7 @@ module.exports = { | |
}, | ||
overrides: [ | ||
{ | ||
files: ["src/**/*.mjs", "test/**/*.mjs"], | ||
files: ["src/**/*.mjs", "test/**/*.mjs", "rollup.config.mjs"], | ||
extends: ["plugin:@eslint-community/mysticatea/+modules"], | ||
rules: { | ||
"init-declarations": "off", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/node_modules | ||
/index.* | ||
/test.* | ||
/dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig", | ||
"files": [], | ||
"exclude": ["tests/**/*.js"], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"noEmit": false, | ||
"outDir": "dist" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,27 +18,30 @@ | |
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"import": "./index.mjs", | ||
"require": "./index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
} | ||
}, | ||
"main": "index", | ||
"module": "index.mjs", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.*" | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"scripts": { | ||
"prebuild": "npm run -s clean", | ||
"build": "rollup -c", | ||
"clean": "rimraf .nyc_output coverage index.*", | ||
"prebuild": "npm run -s clean ", | ||
"build": "tsc -p declaration.tsconfig.json && rollup -c", | ||
"clean": "rimraf .nyc_output coverage dist index.*", | ||
"coverage": "opener ./coverage/lcov-report/index.html", | ||
"docs:build": "vitepress build docs", | ||
"docs:watch": "vitepress dev docs", | ||
"format": "npm run -s format:prettier -- --write", | ||
"format:prettier": "prettier .", | ||
"format:check": "npm run -s format:prettier -- --check", | ||
"lint": "eslint .", | ||
"lint:eslint": "eslint .", | ||
"lint:tsc": "tsc", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming: I wouldn't call TypeScript a "lint" task. Even if it acts essentially as a linter in this setup, I've found it confusing for newer contributors to see it named as one. |
||
"lint:type-coverage": "type-coverage --detail --strict --at-least 99 --ignore-files 'test/*' --ignore-files 'src/get-static-value.mjs'", | ||
"lint": "run-p lint:*", | ||
"test": "c8 mocha --reporter dot \"test/*.mjs\"", | ||
"preversion": "npm test && npm run -s build", | ||
"postversion": "git push && git push --tags", | ||
|
@@ -50,17 +53,23 @@ | |
}, | ||
"devDependencies": { | ||
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1", | ||
"@types/eslint": "^8.21.0", | ||
"@types/estree": "^1.0.0", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.19.21", | ||
"c8": "^8.0.1", | ||
"dot-prop": "^7.2.0", | ||
"eslint": "^8.50.0", | ||
"mocha": "^9.2.2", | ||
"npm-run-all": "^4.1.5", | ||
"npm-run-all2": "^6.1.2", | ||
"opener": "^1.5.2", | ||
"prettier": "2.8.8", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.79.1", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup": "^4.12.0", | ||
"rollup-plugin-dts": "^6.1.0", | ||
"semver": "^7.5.4", | ||
"type-coverage": "^2.27.1", | ||
"typescript": "^5.3.3", | ||
"vitepress": "^1.0.0-rc.20", | ||
"warun": "^1.0.0" | ||
}, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @author Toru Nagashima | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
|
||
import { readFileSync } from "node:fs" | ||
import { URL } from "node:url" | ||
|
||
import { dts } from "rollup-plugin-dts" | ||
|
||
/** @type {{ dependencies: Record<string, string> }} */ | ||
const packageInfo = JSON.parse( | ||
readFileSync(new URL("./package.json", import.meta.url), "utf8"), | ||
) | ||
|
||
export default [ | ||
{ | ||
input: "src/index.mjs", | ||
output: { | ||
exports: "named", | ||
file: `index.js`, | ||
format: "cjs", | ||
sourcemap: true, | ||
}, | ||
external: Object.keys(packageInfo.dependencies), | ||
}, | ||
{ | ||
input: "dist/index.d.mts", | ||
output: [ | ||
{ | ||
exports: "named", | ||
file: `index.d.ts`, | ||
format: "cjs", | ||
}, | ||
], | ||
// type-coverage:ignore-next-line | ||
plugins: [dts()], | ||
}, | ||
] |
Uh oh!
There was an error while loading. Please reload this page.