-
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.
init setup with examples for debug, lint, test
- Loading branch information
1 parent
f6820d1
commit bb5e713
Showing
13 changed files
with
3,682 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "dev", | ||
"request": "launch", | ||
"runtimeArgs": ["dev"], | ||
"runtimeExecutable": "pnpm", | ||
"skipFiles": ["<node_internals>/**"], | ||
"type": "node" | ||
} | ||
] | ||
} | ||
|
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 |
---|---|---|
@@ -1,2 +1,29 @@ | ||
# ts-node-project-setup | ||
|
||
Foundation for setting up a Typescript project that has support for linting, testing, and debugging | ||
|
||
I typically use [pnpm](https://pnpm.io/) as a Package Manager but everything will work with `npm` as well. Anywhere you see reference to `pnpm` and some command it just means it is using `pnpm`. Examples of both `pnpm` and `npm` are provided. | ||
|
||
## Setup | ||
|
||
1. Install your IDE of choice, such as [Visual Studio Code](https://code.visualstudio.com/) | ||
2. Clone [this repository](https://github.com/scottluskcis/ts-node-project-setup.git) locally | ||
3. Run `pnpm install` or `npm install` | ||
4. Run `pnpm dev` or `npm run dev` to run the simple example | ||
|
||
## Tests | ||
|
||
A simple test is provided here and is setup using [Jest](https://jestjs.io/). You can run the test either running `pnpm test` or `npm run test`. | ||
|
||
## Linting | ||
|
||
Linting is configured for the project, run `pnpm lint` or `npm run lint` | ||
|
||
## Debugging | ||
|
||
A sample launch configuration has been added to use if you are using Visual Studio Code [here](.vscode/launch.json). Use VS Code Run and Debug and launch the dev configuration. Note that the launch is setup to use `pnpm` currently but you can alter this by modifying the following values to work with npm | ||
|
||
```json | ||
"runtimeArgs": ["run", "dev"], | ||
"runtimeExecutable": "npm", | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,37 @@ | ||
import { fileURLToPath } from 'url'; | ||
import { dirname } from 'path'; | ||
import globals from 'globals'; | ||
import pluginJs from '@eslint/js'; | ||
import tsEslintPlugin from '@typescript-eslint/eslint-plugin'; | ||
import tsEslintParser from '@typescript-eslint/parser'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
/** @type {import('eslint').Linter.Config} */ | ||
export default [ | ||
{ | ||
files: ['**/*.{js,mjs,cjs,ts}'], | ||
ignores: ['dist/'], | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
...globals.node, | ||
...globals.jest, | ||
}, | ||
parser: tsEslintParser, | ||
parserOptions: { | ||
project: './tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
}, | ||
}, | ||
plugins: { | ||
'@typescript-eslint': tsEslintPlugin, | ||
}, | ||
rules: { | ||
...pluginJs.configs.recommended.rules, | ||
...tsEslintPlugin.configs.recommended.rules, | ||
// Add any custom rules here | ||
}, | ||
}, | ||
]; |
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,7 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} **/ | ||
module.exports = { | ||
testEnvironment: "node", | ||
transform: { | ||
"^.+.tsx?$": ["ts-jest",{}], | ||
}, | ||
}; |
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 @@ | ||
{ | ||
"execMap": { | ||
"ts": "ts-node" | ||
} | ||
} |
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,30 @@ | ||
{ | ||
"name": "copilot-usage-metrics", | ||
"version": "1.0.0", | ||
"description": "Utility for capturing usage metrics", | ||
"main": "index.js", | ||
"scripts": { | ||
"tsc": "exec tsc", | ||
"start": "tsc && node dist/app.js", | ||
"dev": "nodemon src/index.ts", | ||
"lint": "eslint ./src/**/*.ts", | ||
"test": "jest", | ||
"test:watch": "jest --watch" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@eslint/js": "^9.15.0", | ||
"@types/jest": "^29.5.14", | ||
"@typescript-eslint/eslint-plugin": "^8.15.0", | ||
"@typescript-eslint/parser": "^8.15.0", | ||
"eslint": "^9.15.0", | ||
"globals": "^15.12.0", | ||
"jest": "^29.7.0", | ||
"nodemon": "^3.1.7", | ||
"ts-jest": "^29.2.5", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
Oops, something went wrong.