forked from mysticatea/eslint-utils
-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: validate type comments and generate .d.ts
#204
Open
voxpelli
wants to merge
14
commits into
main
Choose a base branch
from
generate-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c6a385f
Initial type setup
voxpelli d24cd96
Type it up
voxpelli b430a97
Have static value pass strict check
voxpelli 94d9faf
Check and increase type-coverage
voxpelli 5b7ea93
Improve has-side-effect types
voxpelli 722f27e
Improve the types some more
voxpelli 5a7e9a2
Fix tests
voxpelli fe80e3c
Improve types
voxpelli 82a1134
Enforce no semi colons
voxpelli dbbf50d
Fix incorrect check in `getStringIfConstant`
voxpelli a3abcf9
Run prettier
voxpelli 77cff12
Mimic #60 and move build to lint step on CI
voxpelli 33adae4
Prettier broke an ignore
voxpelli fece1fa
Update .eslintrc.js
voxpelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
!.vitepress | ||
/docs/.vitepress/dist | ||
/docs/.vitepress/cache | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/node_modules | ||
/index.* | ||
/test.* | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()], | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something deeply funny to me about an
eslint-community
project using ESLint for formatting.