forked from kitschpatrol/shared-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89a67dd
commit b66f095
Showing
12 changed files
with
1,834 additions
and
75 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Liam Rella | ||
|
||
Based on the MIT-licensed "@kitschpatrol/shared-config" project by Eric Mika | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,64 @@ | ||
{ | ||
"name": "@envsa/typescript-config", | ||
"version": "8.2.0", | ||
"type": "module", | ||
"description": "TypeScript configuration for @envsa/shared-config.", | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:envsa/shared-config.git", | ||
"directory": "packages/typescript-config" | ||
}, | ||
"homepage": "https://github.com/envsa/shared-config/packages/typescript-config", | ||
"bugs": { | ||
"url": "https://github.com/envsa/shared-config/issues", | ||
"email": "[email protected]" | ||
}, | ||
"author": { | ||
"name": "Liam Rella", | ||
"email": "[email protected]", | ||
"url": "https://github.com/rellafella" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=22.0.0", | ||
"pnpm": ">=10.0.0" | ||
}, | ||
"bin": { | ||
"envsa-typescript": "bin/cli.js" | ||
}, | ||
"exports": { | ||
".": "./tsconfigs/base.json" | ||
}, | ||
"files": [ | ||
"bin/*", | ||
"init/*", | ||
"tsconfigs/*" | ||
], | ||
"keywords": [ | ||
"shared-config", | ||
"typescript", | ||
"tsconfig", | ||
"envsa", | ||
"envsa-typescript", | ||
"cli" | ||
], | ||
"scripts": { | ||
"build": "../../scripts/build.ts", | ||
"cli": "node ./bin/cli.js", | ||
"prepublishOnly": "pnpm run build" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "~5.7.3" | ||
}, | ||
"dependencies": { | ||
"@pinojs/json-colorizer": "^4.0.0", | ||
"cosmiconfig": "^9.0.0", | ||
"execa": "^9.5.2", | ||
"find-workspaces": "^0.3.1", | ||
"fs-extra": "^11.2.0", | ||
"prettier": "^3.5.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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,98 @@ | ||
<!-- title --> | ||
|
||
<!-- badges --> | ||
|
||
<!-- description --> | ||
|
||
## Overview | ||
|
||
It's a shared [TypeScript](https://www.typescriptlang.org/) `tsconfig.json` config, plus a command-line tool envsa-typescript to perform TypesScript-related validation and linting. | ||
|
||
<!-- recommendation --> | ||
|
||
## Setup | ||
|
||
> [!NOTE] | ||
> | ||
> The package treats `typescript` as a peer dependency - it expects you to have `typescript` installed in your project. | ||
To use just this TypeScript config in isolation: | ||
|
||
1. Install the `.npmrc` in your project root. This is required for correct PNPM behavior: | ||
|
||
```sh | ||
pnpm dlx @envsa/repo-config init | ||
``` | ||
|
||
2. Add the package: | ||
|
||
```sh | ||
pnpm add -D @envsa/typescript-config | ||
``` | ||
|
||
3. Add the starter `tsconfig.json` and `tsconfig.build.json` files to your project root, and add any customizations you'd like: | ||
|
||
```sh | ||
pnpm exec envsa-typescript init | ||
``` | ||
|
||
## Usage | ||
|
||
You can call `envsa-typescript` directly, or use the script bundled with the config. | ||
Integrate wih your `package.json` script as you see fit, for example: | ||
|
||
```json | ||
{ | ||
"scripts": { | ||
"lint": "envsa-typescript lint" | ||
} | ||
} | ||
``` | ||
|
||
### Ignoring files | ||
|
||
See the `tsconfig.json` [`exclude`](https://www.typescriptlang.org/tsconfig/#exclude) key. | ||
`.gitignore` files are not ignored. | ||
|
||
### Ignoring code | ||
|
||
See [the TypeScript directive comments documentation](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#improved-checking-for-js-files) for more details. | ||
|
||
Entire files (at top): | ||
|
||
`/* @ts-nocheck */` | ||
|
||
Next line: | ||
|
||
`/* @ts-ignore */` | ||
|
||
or | ||
|
||
`/* @ts-expect-error - reason */` | ||
|
||
### CLI | ||
|
||
<!-- cli-help --> | ||
|
||
## Notes | ||
|
||
### General | ||
|
||
- [tsconfig Cheat Sheet](https://www.totaltypescript.com/tsconfig-cheat-sheet) | ||
|
||
### Other shared tsconfig projects | ||
|
||
- [tsconfig/bases](https://github.com/tsconfig/bases) | ||
- [sindresorhus/tsconfig](https://github.com/sindresorhus/tsconfig) | ||
- [total-typescript/tsconfig](https://github.com/total-typescript/tsconfig) | ||
|
||
### Future integrations | ||
|
||
- [Are The Types Wrong](https://github.com/arethetypeswrong/arethetypeswrong.github.io),\ | ||
e.g. `attw --format ascii --no-summary --profile esm-only --pack .` | ||
|
||
## Credits | ||
|
||
[Eric Mika](https://github.com/kitschpatrol) is the author of the original [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config) project on which this is based. | ||
|
||
<!-- license --> |
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,5 @@ | ||
#!/usr/bin/env node | ||
import { buildCommands } from '../../../src/command-builder.js'; | ||
import { commandDefinition } from './command.js'; | ||
|
||
await buildCommands(commandDefinition); |
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,38 @@ | ||
import { type CommandDefinition, DESCRIPTION } from '../../../src/command-builder.js'; | ||
|
||
export const commandDefinition: CommandDefinition = { | ||
commands: { | ||
init: { | ||
locationOptionFlag: false, | ||
}, | ||
lint: { | ||
commands: [ | ||
{ | ||
cwdOverride: 'package-dir', | ||
name: 'tsc', | ||
optionFlags: ['--noEmit'], | ||
}, | ||
], | ||
// TODO confirm monorepo behavior | ||
description: `Run type checking on your project. ${DESCRIPTION.packageRun} ${DESCRIPTION.monorepoRun}`, | ||
positionalArgumentMode: 'none', | ||
}, | ||
printConfig: { | ||
commands: [ | ||
{ | ||
name: 'tsc', | ||
optionFlags: ['--showConfig'], | ||
prettyJsonOutput: true, | ||
}, | ||
], | ||
// TODO confirm monorepo behaviour | ||
description: `Print the TypeScript configuration for the project. ${DESCRIPTION.packageSearch} ${DESCRIPTION.monorepoSearch}`, | ||
positionalArgumentMode: 'none', | ||
}, | ||
}, | ||
description: "Envsa's TypeScript shared configuration tools.", | ||
logColor: 'blueBright', | ||
logPrefix: '[TypeScript Config]', | ||
name: 'Envsa-typescript', | ||
order: 3, | ||
}; |
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,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2023", | ||
"lib": ["ES2023", "DOM", "DOM.Iterable"], | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"allowImportingTsExtensions": true, | ||
"allowJs": true, | ||
"checkJs": true, | ||
"strict": true, | ||
"allowUnreachableCode": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noEmit": true, | ||
"isolatedModules": true, | ||
"skipLibCheck": true, | ||
"noErrorTruncation": true | ||
} | ||
} |
Oops, something went wrong.