Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

feat: Bundle JSDoc-built TypeScript declaration file #34

Merged
merged 16 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"sourceType": "module",
"ecmaVersion": 2020
},
"settings": {
"jsdoc": {
"mode": "typescript",
"preferredTypes": {
brettz9 marked this conversation as resolved.
Show resolved Hide resolved
"Object": "object",
"object<>": "Object"
}
}
},
"overrides": [
{
"files": ["*.cjs"],
Expand Down
10 changes: 5 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function filterKey(key) {

/**
* Get visitor keys of a given node.
* @param {Object} node The AST node to get keys.
* @returns {string[]} Visitor keys of the node.
* @param {object} node The AST node to get keys.
* @returns {readonly string[]} Visitor keys of the node.
*/
export function getKeys(node) {
return Object.keys(node).filter(filterKey);
Expand All @@ -33,11 +33,11 @@ export function getKeys(node) {
// eslint-disable-next-line valid-jsdoc
/**
* Make the union set with `KEYS` and given keys.
* @param {Object} additionalKeys The additional keys.
* @returns {{ [type: string]: string[] | undefined }} The union set.
* @param {{ readonly [type: string]: ReadonlyArray<string> }} additionalKeys The additional keys.
* @returns {{ readonly [type: string]: ReadonlyArray<string> }} The union set.
*/
export function unionWith(additionalKeys) {
const retv = Object.assign({}, KEYS);
const retv = /** @type {{ [type: string]: ReadonlyArray<string> }} */ (Object.assign({}, KEYS));
brettz9 marked this conversation as resolved.
Show resolved Hide resolved

for (const type of Object.keys(additionalKeys)) {
if (Object.prototype.hasOwnProperty.call(retv, type)) {
Expand Down
3 changes: 3 additions & 0 deletions lib/visitor-keys.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {{ readonly [type: string]: ReadonlyArray<string> | undefined }}
*/
const KEYS = {
AssignmentExpression: [
"left",
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"description": "Constants and utilities about visitor keys to traverse AST.",
"type": "module",
"main": "dist/eslint-visitor-keys.cjs",
"types": "./dist/index.d.ts",
"exports": {
".": [
{
"types": "./dist/index.d.ts",
brettz9 marked this conversation as resolved.
Show resolved Hide resolved
"import": "./lib/index.js",
"require": "./dist/eslint-visitor-keys.cjs"
},
Expand All @@ -15,6 +17,8 @@
"./package.json": "./package.json"
},
"files": [
"dist/index.d.ts",
"dist/visitor-keys.d.ts",
"dist/eslint-visitor-keys.cjs",
"lib"
],
Expand All @@ -30,12 +34,14 @@
"eslint-release": "^3.2.0",
"mocha": "^9.0.1",
"opener": "^1.5.2",
"rollup": "^2.52.1"
"rollup": "^2.52.1",
"typescript": "^4.6.0-dev.20220206"
brettz9 marked this conversation as resolved.
Show resolved Hide resolved
},
"scripts": {
"prepare": "npm run build",
"prepare": "npm run build && npm run tsc",
brettz9 marked this conversation as resolved.
Show resolved Hide resolved
"build": "rollup -c",
"lint": "eslint .",
"tsc": "tsc",
"test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js",
"coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html",
"generate-release": "eslint-generate-release",
Expand Down
19 changes: 19 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"lib": ["es2020"],
"moduleResolution": "nodenext",
"module": "esnext",
"resolveJsonModule": true,
"allowJs": true,
"checkJs": true,
"noEmit": false,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"strict": true,
"target": "es5",
brettz9 marked this conversation as resolved.
Show resolved Hide resolved
"outDir": "dist"
},
"include": ["lib/**/*.js"],
"exclude": ["node_modules"]
}