{"id":18374534,"url":"https://github.com/jupiterone/typescript-tools","last_synced_at":"2025-04-06T19:32:42.196Z","repository":{"id":39856605,"uuid":"315812345","full_name":"JupiterOne/typescript-tools","owner":"JupiterOne","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-12T20:13:46.000Z","size":2177,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-03-22T06:12:52.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JupiterOne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-25T02:56:14.000Z","updated_at":"2022-03-15T03:11:37.000Z","dependencies_parsed_at":"2023-01-31T07:01:08.835Z","dependency_job_id":"1786030f-c09d-47e4-ad41-a91df82f1826","html_url":"https://github.com/JupiterOne/typescript-tools","commit_stats":{"total_commits":158,"total_committers":20,"mean_commits":7.9,"dds":0.6455696202531646,"last_synced_commit":"182e0786542667e261c4f4a940dbda5a2d0ea296"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Ftypescript-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Ftypescript-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Ftypescript-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JupiterOne%2Ftypescript-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JupiterOne","download_url":"https://codeload.github.com/JupiterOne/typescript-tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247539519,"owners_count":20955319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T00:15:01.094Z","updated_at":"2025-04-06T19:32:41.512Z","avatar_url":"https://github.com/JupiterOne.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript Tools\n\nThis Node.js package provides a baseline set of dependencies, configuration, and\nscripts that can be used by other TypeScript projects.\n\nThis Node.js package is opinionated and comes bundled with the following\ndependencies:\n\n- `typescript`\n\n- `prettier`\n\n- `jest`\n\n- `babel` (used by `jest` and for building/transpiling)\n\n- `eslint`\n\n- `husky` (allows you specify git hook scripts inside `.husky/` directory -\n  [read more](#usage-husky-7))\n\n- `lint-staged` (used as a `precommit` hook to automatically reformat changed\n  source files)\n\n- `ttypescript` (allows transform plugins to be loaded from `tsconfig.json`)\n\n## Migrating from Husky 4 to Husky 7:\n\nIf you've been using previous versions of Husky in your project, the newest\nversion of Husky requires some package maintenance to keep git hooks working\n(and working better than previously):\n[read more](#installation-or-upgrade-for-previous-projects)\n\n## Helper Scripts\n\nThis package provides the following `bin` entries:\n\n- `check-tsconfig`: Fix and, optionally, repair\n  [project references](https://www.typescriptlang.org/docs/handbook/project-references.html)\n  in `tsconfig.dist.json` files. Run `yarn check-tsconfig --help` for more\n  information.\n\n- `yalc-publish`: Use `yalc` to publish packages locally (better alternative to\n  `yarn link`) Run `yarn yalc-publish --help` for more information.\n\n- `yalc-check`: Checks `package.json` files to make sure there are no `.yalc`\n  entries Run `yarn yalc-check --help` for more information.\n\nIt is recommended that you add helper scripts to projects using\n`@jupiterone/typescript-tools`.\n\n**For monorepo projects:**\n\n```json\n{\n  \"scripts\": {\n    \"tsconfig:repair\": \"check-tsconfig --monorepo --repair\",\n    \"tsconfig:check\": \"check-tsconfig --monorepo --no-repair\",\n    \"yalc:publish\": \"yalc-publish --monorepo\",\n    \"yalc:check\": \"yalc-check --monorepo\"\n  }\n}\n```\n\n**For non-monorepo projects:**\n\n```json\n{\n  \"scripts\": {\n    \"tsconfig:repair\": \"check-tsconfig --repair\",\n    \"tsconfig:check\": \"check-tsconfig --no-repair\",\n    \"yalc:publish\": \"yalc-publish\",\n    \"yalc:check\": \"yalc-check\"\n  }\n}\n```\n\n```sh\n# Repair project references inside packages/*/tsconfig.dist.json files:\nyarn check-tsconfig --monorepo --repair\n\n# Check project references inside packages/*/tsconfig.dist.json files:\nyarn check-tsconfig --monorepo\n\n# Publish packages in your monorepo locally using yalc:\nyalc-publish --monorepo\n\n# Make sure package.json files do not contain local .yalc dependencies:\nyalc-check --monorepo\n```\n\nFor more information about `yalc`, visit:\n\n\u003chttps://github.com/whitecolor/yalc\u003e\n\n### Compiling project\n\n**For monorepo:**\n\n```sh\n# Update all project references so that they match interproject dependencies:\nyarn check-tsconfig --monorepo --repair\n\n# Now compile all packages using project references which allows the\n# typescript compiler to compile your packages in the correct order\nyarn tspc -b `find ./packages -maxdepth 2 -name tsconfig.dist.json`\n```\n\n**For non-monorepo:**\n\n```sh\n# It is recommended to have a tsconfig.dist.json that excludes all test files\n# and use that to compile your typescript files\nyarn tspc --declaration -p tsconfig.dist.json\n```\n\n## Usage: Prettier\n\nCreate `prettier.config.js` at root of your project that contains:\n\n```javascript\nmodule.exports = require('@jupiterone/typescript-tools/config/prettier');\n```\n\nCreate `lint-staged.config.js` at root of your project that contains:\n\n```javascript\nmodule.exports = require('@jupiterone/typescript-tools/config/lint-staged');\n```\n\nAlso, the following `.prettierignore` file is recommended:\n\n```plain\ndist/\nwork/\nnode_modules/\ncoverage/\npackage.json\n```\n\nIf you would like to rewrite `../` style paths in imports to use `~/` then you\nshould modify your project's `lint-staged.config.js` file.\n\n**NOTE:** This project also installs\n[prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports)\nwhich will automatically be loaded by `prettier` and it will be used to organize\nimports.\n\n**For monorepo:**\n\n```js\n// For monorepo\nmodule.exports = {\n  '*.{ts,tsx,js,jsx,json,css,md}': [\n    'prettier --write',\n    'yarn rewrite-imports --monorepo --dir .',\n  ],\n};\n```\n\n**For non-monorepo project:**\n\n```js\n// For monorepo\nmodule.exports = {\n  '*.{ts,tsx,js,jsx,json,css,md}': [\n    'prettier --write',\n    'yarn rewrite-imports --dir .',\n  ],\n};\n```\n\n## Usage: Jest\n\nCreate `jest.config.js` at root of your project and use the contents below.\n\n**For monorepo:**\n\n```javascript\nmodule.exports = {\n  ...require('@jupiterone/typescript-tools/config/jest-monorepo'),\n\n  // Optionally, run some setup script before each test script\n  setupFilesAfterEnv: ['./jest.setup.ts'],\n\n  collectCoverageFrom: [\n    'packages/*/src/**/*.ts',\n    '!**/*.test.ts',\n    '!**/__tests__/**',\n  ],\n  coverageThreshold: {\n    global: {\n      statements: 100,\n      branches: 100,\n      functions: 100,\n      lines: 100,\n    },\n  },\n};\n```\n\n**For non-monorepo:**\n\n```javascript\nmodule.exports = {\n  ...require('@jupiterone/typescript-tools/config/jest'),\n\n  // Optionally, run some setup script before each test script\n  setupFilesAfterEnv: ['./jest.setup.ts'],\n\n  collectCoverage: true,\n  collectCoverageFrom: ['src/**/*.ts'],\n  coverageThreshold: {\n    global: {\n      statements: 100,\n      branches: 100,\n      functions: 100,\n      lines: 100,\n    },\n  },\n};\n```\n\n## Usage: Babel\n\nBabel is used to convert `*.ts` files to `*.js` by stripping away type\ninformation. It is used when running `jest` tests and it can also be used to\nbuild files for the web, docker image, serverless function, etc. (when type\ndeclaration files are not needed)\n\nCreate `babel.config.js` at root of your project that contains:\n\n```javascript\nmodule.exports = require('@jupiterone/typescript-tools/config/babel');\n```\n\n**For monorepo projects use the following in your root `babel.config.js` file:**\n\n```javascript\nconst {\n  buildBabelConfig,\n} = require('@jupiterone/typescript-tools/config/babel-util');\nmodule.exports = buildBabelConfig({ monorepo: true });\n```\n\n**In each of the monorepo packages, use the following in each of your\n`packages/*/.babelrc.js` files:**\n\n```javascript\nconst {\n  buildBabelConfig,\n} = require('@jupiterone/typescript-tools/config/babel-util');\nmodule.exports = buildBabelConfig({ packageDir: __dirname });\n```\n\n## Usage: TypeScript\n\nCreate `tsconfig.json` at root of your project that contains the contents below.\n\n**For monorepo:**\n\n```json\n{\n  \"extends\": \"./node_modules/@jupiterone/typescript-tools/config/typescript-node18-monorepo\",\n  \"compilerOptions\": {\n    \"rootDir\": \".\",\n    \"outDir\": \"dist\"\n  },\n  \"include\": [\n    \"*.js\",\n    \"*.ts\",\n    \"packages/*/*.js\",\n    \"packages/*/*.ts\",\n    \"packages/*/package.json\",\n    \"packages/*/*/**/*.ts\",\n    \"packages/*/*/**/*.json\"\n  ],\n  \"exclude\": [\n    \"packages/*/dist/**/*\",\n    \"packages/*/coverage/**/*\",\n    \"**/bak/**/*\",\n    \"**/*.bak/**/*\"\n  ]\n}\n```\n\nAlso, for every monorepo package use this in its `./packages/*/tsconfig.json`\nfile:\n\n```json\n{\n  \"extends\": \"../../tsconfig.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"dist\",\n    \"rootDir\": \".\",\n    \"baseUrl\": \".\"\n  },\n  \"include\": [\"package.json\", \"**/*.ts\", \"**/*.json\"],\n  \"exclude\": [\"dist/**/*\", \"coverage/**/*\", \"**/bak/**/*\", \"**/*.bak/**/*\"]\n}\n```\n\nAlso, for every monorepo package use this in its\n`./packages/*/tsconfig.dist.json` file:\n\n```json\n{\n  \"extends\": \"./tsconfig.json\",\n  \"exclude\": [\n    \"dist/**/*\",\n    \"coverage/**/*\",\n    \"**/bak/**/*\",\n    \"**/*.bak/**/*\",\n    \"test/**\",\n    \"**/*.test.ts\",\n    \"**/__tests__/**/*.ts\",\n    \"**/__mocks__/**/*.ts\"\n  ],\n  \"references\": [\n    ...\n  ]\n}\n```\n\n**For non-monorepo:**\n\nAdd this to `tsconfig.json` file at root of project:\n\n```json\n{\n  \"extends\": \"./node_modules/@jupiterone/typescript-tools/config/typescript-node18\",\n  \"compilerOptions\": {\n    \"rootDir\": \".\",\n    \"baseUrl\": \".\",\n    \"outDir\": \"dist\"\n  },\n  \"include\": [\n    \"src/**/*.ts\",\n    \"tools/**/*.ts\",\n    \"tools/*.js\",\n    \"test/**/*.ts\",\n    \"jest.*.ts\",\n    \"jest.*.js\",\n    \"*.config.js\"\n  ],\n  \"exclude\": [\"**/*.bak/**/*\", \"**/dist/**/*\"]\n}\n```\n\nAlso, for _production_ builds use a `tsconfig.dist.json` file that excludes\ntests:\n\n```json\n{\n  \"extends\": \"./tsconfig.json\",\n  \"include\": [\"src/**/*.ts\"],\n  \"exclude\": [\"src/**/*.test.ts\"]\n}\n```\n\n**NOTE:** Your config should contain `rootDir` and `baseUrl` because these paths\nneed to be relative to your `tsconfig.json` file and not the TypeScript\nconfiguration file that we are extending.\n\n**NOTE:** You may want to add `\"skipLibCheck\": true` to the `compilerOptions` if\nyou have installed third-party packages that have broken types.\n\n**NOTE:** TypeScript doesn't use Node module resolution to find tsconfig.json\nfiles for extending so we have to use a relative or absolute path. See\n\u003chttps://github.com/Microsoft/TypeScript/issues/18865\u003e\n\n**To perform type-checking:**\n\n```bash\nyarn type-check\n```\n\n**NOTE:** `type-check` utility script runs `tsc --noEmit`.\n\n## Usage: ESLint\n\nThis package contains `eslint` configuration for both backend (Node.js) and\nfrontend (React) so pick the configuration that is appropriate for your project.\n\nRegardless of target environment, you can always add `.eslintignore` to ignore\ncertain files in your project.\n\nThe current eslint configuration extends the following:\n\n- [eslint:recommended](https://eslint.org/docs/rules/): Built-in ecommended\n  rules for `eslint`.\n- [@typescript-eslint/recommended](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs#recommended):\n  Opionated rules that don't require type information.\n- [@typescript-eslint/recommended-requiring-type-checking](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs#recommended-requiring-type-checking):\n  Opionated rules that use typescript type information (requires\n  `parserOptions.project` in `eslint` config).\n- [prettier/@typescript-eslint](https://github.com/prettier/eslint-config-prettier):\n  Disables rules that `prettier` will automatically fix.\n\nAfter extending the configurations above, the following rule overrides are\nprovided by `@jupiterone/typescript-tools`:\n\n- `@typescript-eslint/explicit-function-return-type\": \"off\"`\n- `@typescript-eslint/no-explicit-any\": \"off\"`\n- `@typescript-eslint/no-inferrable-types\": \"off\"`\n- `@typescript-eslint/no-non-null-assertion\": \"off\"`\n- `@typescript-eslint/no-require-imports\": \"off\"`\n- `@typescript-eslint/no-unused-vars\": \"off\"`\n- `@typescript-eslint/no-use-before-define\": \"off\"`\n- `@typescript-eslint/no-var-requires\": \"off\"`\n- `@typescript-eslint/no-unsafe-return\": \"off\"`\n- `@typescript-eslint/no-unsafe-call\": \"off\"`\n- `@typescript-eslint/restrict-plus-operands\": \"off\"`\n- `@typescript-eslint/restrict-template-expressions\": \"off\"`\n- `@typescript-eslint/no-unsafe-assignment\": \"off\"`\n- `@typescript-eslint/prefer-string-starts-ends-with\": \"off\"`\n- `@typescript-eslint/require-await\": \"off\"`\n- `@typescript-eslint/no-unsafe-member-access\": \"off\"`\n- `@typescript-eslint/unbound-method\": \"off\"`\n- `@typescript-eslint/explicit-module-boundary-types\": \"off\"`\n\nSee\n\u003chttps://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin\u003e\nfor documentation on eslint rules for typescript.\n\nRun `eslint` using the following command:\n\n```sh\nyarn eslint --ext .ts,.tsx.js,.jsx .\n```\n\nIn your `package.json` add the following to the `scripts` section:\n\n```json\n\"lint\": \"eslint --ext .ts,.tsx,.js,.jsx .\"\n```\n\n**IMPORTANT:** You currently must explicitly add the `--ext` argument because\n`eslint` will only check `.js` files by default and you can't control this from\nthe eslint configuration.\n\n### ESLint configuration for Node.js\n\nCreate `.eslintrc` at root of your project that contains:\n\n```json\n{\n  \"root\": true,\n  \"extends\": [\"@jupiterone/eslint-config\"],\n  \"parserOptions\": {\n    \"project\": \"./tsconfig.json\",\n    \"tsconfigRootDir\": \".\"\n  }\n}\n```\n\n**IMPORTANT:** If you are linting `*.js` files (which are enabled by via `--ext`\nargument) then make sure `allowJs: true` is set in your `tsconfig.json`, and\nalso make sure the `*.js` files are included via the `include`/`exclude`\npatterns in your `tsconfig.json` files. If the typescript compiler does not\nprocess the `*.js` files then you'll see eslint errors similar to the following:\n\n```\n/Development/my-project/my-file.js\n  0:0  error  Parsing error: \"parserOptions.project\" has been set for @typescript-eslint/parser.\nThe file does not match your project config: my-file.js.\nThe file must be included in at least one of the projects provided\n```\n\n### ESLint configuration for React\n\nCreate `.eslintrc` at root of your project that contains:\n\n```json\n{\n  \"root\": true,\n  \"extends\": [\"@jupiterone/eslint-config/react\"]\n}\n```\n\n## Usage: Husky 7\n\nIn the updates to Husky for major version 7 they have included some large\nchanges that fix existing Husky problems. (Most of these problems revolved\naround failing to properly bootstrap a new cloned project with `.git/hooks`\nentries and the inability to run hooks without first loading the `node.js`\nruntime [due to looking in many different places for a JS config that must be\nadded to the `.git/hooks` directory])\n\nA writeup by the Husky authors\n[can be read here](https://blog.typicode.com/husky-git-hooks-javascript-config/).\nSummarized major changes for our use-case are as follows:\n\n- No more `.huskyrc` and no more `[package.json].husky` entries. (Husky is\n  configuring Git with shell scripts now, we don't want JS configs)\n\n- Hooks now live in a directory specified by `git config` at the\n  `core.hooksPath` directory\n\n  - Husky will try to set the above path automatically on `prepare`\n\n- Maintenance needed to upgrade existing hooks to the new format:\n\n### Installation or Upgrade for Previous Projects\n\n- \u003cb\u003e[Instructions to migrate](https://github.com/typicode/husky-4-to-7) from v4\n  to v7 automatically\u003c/b\u003e\n\n  From the above link:\n\n  ```bash\n  yarn add husky@latest --dev \\\n  \u0026\u0026 npx husky-init \\\n  \u0026\u0026 npm exec -- github:typicode/husky-4-to-7 --remove-v4-config\n  ```\n\nThe above instructions basically just remove the `.git/hooks` entries, creates a\n`.husky` directory, and executes\n`npx husky add .husky/\u003cmy-hook\u003e '\u003cMy Hook Contents\u003e` for each hook in the\nprevious format -- you are free to set up the hooks each on their own, but the\naforementioned script will attempt to convert the old format to the Husky 7.x\nformat.\n\n### Recommended Hooks\n\nStandard set of Jupiter One hooks are configured as follows, after installing\nHusky:\n\n```bash\nnpx husky add .husky/pre-commit 'yarn lint-staged \u0026\u0026 yarn format'\nnpx husky add .husky/pre-push 'yarn test:ci'\n```\n\nThe above pattern can be used to add hooks for any of the supported git-hooks.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiterone%2Ftypescript-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupiterone%2Ftypescript-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiterone%2Ftypescript-tools/lists"}