-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infra: onboard to template-typescript-node-package
- Loading branch information
1 parent
398a1b3
commit c901483
Showing
88 changed files
with
8,195 additions
and
3,966 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"badgeTemplate": "<img alt=\"All Contributors: <%= contributors.length %>\" src=\"https://img.shields.io/badge/all_contributors-<%= contributors.length %>-21bb42.svg\" />", | ||
"commit": false, | ||
"commitConvention": "angular", | ||
"contributors": [ | ||
{ | ||
"avatar_url": "https://avatars.githubusercontent.com/u/3335181?v=4", | ||
"contributions": ["tool"], | ||
"login": "JoshuaKGoldberg", | ||
"name": "Josh Goldberg", | ||
"profile": "http://www.joshuakgoldberg.com" | ||
} | ||
], | ||
"contributorsPerLine": 7, | ||
"contributorsSortAlphabetically": true, | ||
"files": ["README.md"], | ||
"imageSize": 100, | ||
"projectName": "template-typescript-node-package", | ||
"projectOwner": "JoshuaKGoldberg", | ||
"repoHost": "https://github.com", | ||
"repoType": "github" | ||
} |
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 @@ | ||
!.* | ||
coverage | ||
lib | ||
node_modules | ||
pnpm-lock.yaml |
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,148 @@ | ||
/* | ||
👋 Hi! This ESLint configuration contains a lot more stuff than many repos'! | ||
You can read from it to see all sorts of linting goodness, but don't worry - | ||
it's not something you need to exhaustively understand immediately. 💙 | ||
If you're interested in learning more, see the 'getting started' docs on: | ||
- ESLint: https://eslint.org | ||
- typescript-eslint: https://typescript-eslint.io | ||
*/ | ||
|
||
/** @type {import("@types/eslint").Linter.Config} */ | ||
module.exports = { | ||
env: { | ||
es2022: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:eslint-comments/recommended", | ||
"plugin:regexp/recommended", | ||
"prettier", | ||
], | ||
overrides: [ | ||
{ | ||
extends: ["plugin:markdown/recommended"], | ||
files: ["**/*.md"], | ||
processor: "markdown/markdown", | ||
}, | ||
{ | ||
extends: [ | ||
"plugin:jsdoc/recommended-typescript-error", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:typescript-sort-keys/recommended", | ||
], | ||
files: ["**/*.ts"], | ||
parser: "@typescript-eslint/parser", | ||
rules: { | ||
// These off-by-default rules work well for this repo and we like them on. | ||
"jsdoc/informative-docs": "error", | ||
|
||
// These on-by-default rules don't work well for this repo and we like them off. | ||
"jsdoc/require-jsdoc": "off", | ||
"jsdoc/require-param": "off", | ||
"jsdoc/require-property": "off", | ||
"jsdoc/require-returns": "off", | ||
}, | ||
}, | ||
{ | ||
extends: [ | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:@typescript-eslint/strict", | ||
], | ||
excludedFiles: ["**/*.md/*.ts"], | ||
files: ["**/*.ts"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "./tsconfig.eslint.json", | ||
}, | ||
rules: { | ||
// TODO: Investigate turning these on | ||
"@typescript-eslint/ban-types": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/restrict-template-expressions": "off", | ||
"@typescript-eslint/unbound-method": "off", | ||
|
||
// These off-by-default rules work well for this repo and we like them on. | ||
"deprecation/deprecation": "error", | ||
}, | ||
}, | ||
{ | ||
files: ["*.json", "*.jsonc"], | ||
excludedFiles: ["package.json"], | ||
parser: "jsonc-eslint-parser", | ||
rules: { | ||
"jsonc/sort-keys": "error", | ||
}, | ||
extends: ["plugin:jsonc/recommended-with-json"], | ||
}, | ||
{ | ||
files: "**/*.test.ts", | ||
rules: { | ||
// These on-by-default rules aren't useful in test files. | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
}, | ||
}, | ||
{ | ||
extends: ["plugin:yml/standard", "plugin:yml/prettier"], | ||
files: ["**/*.{yml,yaml}"], | ||
parser: "yaml-eslint-parser", | ||
rules: { | ||
"yml/file-extension": ["error", { extension: "yml" }], | ||
"yml/sort-keys": [ | ||
"error", | ||
{ | ||
order: { type: "asc" }, | ||
pathPattern: "^.*$", | ||
}, | ||
], | ||
"yml/sort-sequence-values": [ | ||
"error", | ||
{ | ||
order: { type: "asc" }, | ||
pathPattern: "^.*$", | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
parser: "@typescript-eslint/parser", | ||
plugins: [ | ||
"@typescript-eslint", | ||
"deprecation", | ||
"import", | ||
"jsdoc", | ||
"no-only-tests", | ||
"regexp", | ||
"simple-import-sort", | ||
"typescript-sort-keys", | ||
"vitest", | ||
], | ||
root: true, | ||
rules: { | ||
// These off/less-strict-by-default rules work well for this repo and we like them on. | ||
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }], | ||
"import/extensions": ["error", "ignorePackages"], | ||
"no-only-tests/no-only-tests": "error", | ||
"simple-import-sort/exports": "error", | ||
"simple-import-sort/imports": "error", | ||
|
||
// These on-by-default rules don't work well for this repo and we like them off. | ||
"no-constant-condition": "off", | ||
"no-inner-declarations": "off", | ||
|
||
// Stylistic concerns that don't interfere with Prettier | ||
curly: ["error", "all"], | ||
"padding-line-between-statements": "off", | ||
"@typescript-eslint/padding-line-between-statements": [ | ||
"error", | ||
{ blankLine: "always", next: "*", prev: "block-like" }, | ||
], | ||
}, | ||
}; |
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
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,84 @@ | ||
# Development | ||
|
||
After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo) and [installing pnpm](https://pnpm.io/installation): | ||
|
||
```shell | ||
git clone https://github.com/<your-name-here>/console-fail-test | ||
cd console-fail-test | ||
pnpm install | ||
``` | ||
|
||
> This repository includes a list of suggested VS Code extensions. | ||
> It's a good idea to use [VS Code](https://code.visualstudio.com) and accept its suggestion to install them, as they'll help with development. | ||
## Building | ||
|
||
Run [TypeScript](https://typescriptlang.org) locally to type check and build source files from `src/` into output files in `lib/`: | ||
|
||
```shell | ||
pnpm build --watch | ||
``` | ||
|
||
You should also see suggestions from TypeScript in your editor. | ||
|
||
## Formatting | ||
|
||
[Prettier](https://prettier.io) is used to format code. | ||
It should be applied automatically when you save files in VS Code or make a Git commit. | ||
|
||
To manually reformat all files, you can run: | ||
|
||
```shell | ||
pnpm format:write | ||
``` | ||
|
||
## Linting | ||
|
||
This package includes several forms of linting to enforce consistent code quality and styling. | ||
Each should be shown in VS Code, and can be run manually on the command-line: | ||
|
||
- `pnpm lint:knip` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports | ||
- `pnpm lint:md` ([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks Markdown source files | ||
- `pnpm lint:package` ([npm-package-json-lint](https://npmpackagejsonlint.org/)): Lints the `package.json` file | ||
- `pnpm lint:packages` ([pnpm dedupe --check](https://pnpm.io/cli/dedupe)): Checks for unnecessarily duplicated packages in the `pnpm-lock.yml` file | ||
- `pnpm lint:spelling` ([cspell](https://cspell.org)): Spell checks across all source files | ||
- `pnpm lint` ([ESLint](https://eslint.org) with [typescript-eslint](https://typescript-eslint.io)): Lints JavaScript and TypeScript source files | ||
|
||
## Testing | ||
|
||
[Vitest](https://vitest.dev) is used for tests. | ||
You can run it locally on the command-line: | ||
|
||
```shell | ||
pnpm run test | ||
``` | ||
|
||
Add the `--coverage` flag to compute test coverage and place reports in the `coverage/` directory: | ||
|
||
```shell | ||
pnpm run test --coverage | ||
``` | ||
|
||
Note that [console-fail-test](https://github.com/JoshuaKGoldberg/console-fail-test) is enabled for all test runs. | ||
Calls to `console.log`, `console.warn`, and other console methods will cause a test to fail. | ||
|
||
### Debugging Tests | ||
|
||
This repository includes a [VS Code launch configuration](https://code.visualstudio.com/docs/editor/debugging) for debugging unit tests. | ||
To launch it, open a test file, then run _Debug Current Test File_ from the VS Code Debug panel (or press F5). | ||
|
||
### Testing the Setup Script | ||
|
||
In addition to unit tests, this template also includes an "end-to-end" test for `script/setup.js`. | ||
You can run it locally on the command-line: | ||
|
||
```shell | ||
pnpm run setup:test | ||
``` | ||
|
||
That end-to-end test executes `script/setup-test-e2e.js`, which: | ||
|
||
1. Runs the setup script using `--skip-api` | ||
2. Checks that the local repository's files were changed correctly (e.g. removed setup-only files) | ||
|
||
As with the setup script itself, end-to-end tests are removed on package setup. |
Oops, something went wrong.