Skip to content

Commit

Permalink
Support Typescript 5.5 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlansley authored Jun 24, 2024
1 parent 6112e99 commit 9eba579
Show file tree
Hide file tree
Showing 18 changed files with 1,414 additions and 932 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/check-published-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on:

jobs:
checkPublished:
runs-on: ubuntu-latest
name: Check Published
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check Published
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ on:
branches:
- 'main'

env:
CI: true

jobs:
pullRequestBuild:
name: Pull Request Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 21.x]
node-version: ['20.x', '22.x']
steps:
- uses: actions/checkout@v4
- name: Checkout Code
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
- name: Install Dependencies
run: npm ci --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Prepare
run: npm run prepare
- name: Compile
run: npm run ci:compile
- name: Check Code Style
Expand All @@ -31,22 +39,27 @@ jobs:
run: npm run ci:test

branchBuild:
runs-on: ubuntu-latest
name: Branch Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 21.x]
node-version: ['20.x', '22.x']
steps:
- uses: actions/checkout@v4
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
- name: Install Dependencies
run: npm ci --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Prepare
run: npm run prepare
- name: Compile
run: npm run ci:compile
- name: Check Code Style
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
matrix:
language: ['javascript']
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
6 changes: 4 additions & 2 deletions .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:

jobs:
publishBeta:
runs-on: ubuntu-latest
name: Publish Beta
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -23,6 +23,8 @@ jobs:
uses: checkdigit/github-actions/check-label@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check Imports
uses: checkdigit/github-actions/check-imports@main
- name: Install latest npm
run: npm install -g npm@latest
- name: Install Dependencies
Expand All @@ -38,7 +40,7 @@ jobs:
run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH }}
- name: Comment npm publish result
- name: Comment
uses: checkdigit/github-actions/comment-npm-publish@main
with:
betaPackage: ${{ steps.prepare-beta.outputs.betaPackage }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ jobs:
id-token: write
name: Publish to NPM
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install latest npm
run: npm install -g npm@latest
- name: Install dependencies
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: Audit Signatures
run: npm audit signatures
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This module contains the standard Check Digit Typescript configuration, along wi

### Typescript Configuration

- currently requires Node 20.11 or above.
- currently requires Node 20.13 or above.
- emits `esnext`, with the default libraries, to avoid down-leveling. It is intended that application spec tests pick
up any issues with using newer features unavailable in a particular environment. Browsers and NodeJS are fast-moving
up any issues with using newer features unavailable in a particular environment. Browsers and Node.js are fast-moving
targets, and can add language features at any time.
- uses the `module` type of `esnext`.
- all compiler options set for maximum strictness.
Expand All @@ -24,7 +24,7 @@ It is intended to be used when publishing a package to NPM, or to bundle a packa
It uses `tsc` for generating types, and `esbuild` for generating code.

**Note:** the `require` function will be defined as a global variable, to allow
dynamic `require`s by CommonJS submodules. This is not a problem for NodeJS, but will cause issues in a browser environment.
dynamic `require`s by CommonJS submodules. This is not a problem for Node.js, but will cause issues in a browser environment.

#### Options

Expand Down
86 changes: 86 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// eslint.config.js

import { promises as fs } from 'node:fs';

import eslint from '@eslint/js';
import typescriptEslint from 'typescript-eslint';
import prettier from 'eslint-config-prettier';

const ignores = [
...(await fs.readFile('.gitignore', 'utf-8')).split('\n').filter((path) => path.trim() !== ''),
'eslint.config.js',
];

export default [
{ ignores },
eslint.configs.all,
...typescriptEslint.configs.recommended,
...typescriptEslint.configs.recommendedTypeChecked,
...typescriptEslint.configs.strict,
prettier,
{
languageOptions: {
parserOptions: {
project: './tsconfig.json',
},
},
rules: {
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'capitalized-comments': 'off',
'one-var': 'off',
'func-names': 'off',
'sort-keys': 'off',
'sort-imports': 'off',
'max-lines': [
'error',
{
max: 500,
skipBlankLines: true,
skipComments: true,
},
],
'func-style': [
'error',
'declaration',
{
allowArrowFunctions: true,
},
],
'no-magic-numbers': [
'error',
{
ignore: [0, 1, 2],
},
],
'no-undefined': 'off',
'no-ternary': 'off',
},
},
{
files: ['**/*.spec.ts', '**/*.test.ts'],
rules: {
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'line-comment-position': 'off',
'no-fallthrough': 'off',
'no-inline-comments': 'off',
'no-param-reassign': 'off',
'id-length': 'off',
'no-magic-numbers': 'off',
'no-duplicate-imports': 'off',
'symbol-description': 'off',
'no-invalid-this': 'off',
'max-lines-per-function': 'off',
'max-lines': 'off',
'max-statements': 'off',
'no-await-in-loop': 'off',
},
},
];
Loading

0 comments on commit 9eba579

Please sign in to comment.