diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec3627c..f864352 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,9 +56,34 @@ jobs: with: node-version: 20.x - run: yarn - - uses: pre-commit/action@v3.0.0 + - name: pre-commit + env: + SKIP: eslint + run: | + python -m pip install pre-commit && \ + python -m pip freeze --local && \ + pre-commit run \ + --show-diff-on-failure \ + --color=always \ + --source ${{ github.event.pull_request.base.sha || 'HEAD~1' }} \ + --origin ${{ github.event.pull_request.head.sha || 'HEAD' }} ; + + run-eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 with: - extra_args: --source ${{ github.event.pull_request.base.sha || 'HEAD~1' }} --origin ${{ github.event.pull_request.head.sha || 'HEAD' }} + fetch-depth: 100 # need the history to do a changed files check below (source, origin) + - name: Use Node.js 20.x + uses: actions/setup-node@v1 + with: + node-version: 20.x + - run: yarn install --immutable + + # The exclusion from the `git diff` is necessary because `yarn install` + # on CI modifies the `.pnp.cjs` file to change their actual locations + # but we don't care about that on CI. + - run: yarn lint --quiet --fix && git diff --exit-code -- . ':(exclude)*.pnp.cjs' build-to-npm: if: github.ref == 'refs/heads/main' @@ -68,6 +93,7 @@ jobs: - run-depcheck - build-and-upload-artifacts - run-pre-commits + - run-eslint steps: - name: Checkout uses: actions/checkout@v2 @@ -90,6 +116,7 @@ jobs: - run-depcheck - build-and-upload-artifacts - run-pre-commits + - run-eslint steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3256848..866aec3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/pre-commit/mirrors-prettier # Use the sha / tag you want to point at, this needs # to stay in sync with the package.json version - rev: 'v2.7.1' + rev: 'v3.0.3' hooks: - id: prettier args: [--write, --list-different] diff --git a/package.json b/package.json index afe9681..c119308 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Transcend Inc.", "name": "@transcend-io/type-utils", "description": "Small package containing useful typescript utilities.", - "version": "1.4.0", + "version": "1.4.1", "homepage": "https://github.com/transcend-io/type-utils", "repository": { "type": "git", @@ -19,7 +19,7 @@ "update:deps": "yarn upgrade-interactive && yarn update:sdks", "build": "yarn tsc --build", "clean": "yarn tsc --build --clean", - "lint": "yarn eslint src --ext .ts", + "lint": "yarn eslint ./src --ext .js --ext .ts --ext .tsx --ext .jsx", "prepublish": "yarn build", "test": "yarn mocha './src/**/*.test.ts'" }, diff --git a/src/codecTools/dictionary.ts b/src/codecTools/dictionary.ts index 71a4ac3..84807ff 100644 --- a/src/codecTools/dictionary.ts +++ b/src/codecTools/dictionary.ts @@ -3,10 +3,8 @@ import { unsafeCoerce } from 'fp-ts/lib/function'; import * as t from 'io-ts'; /** A record with optional keys */ -export interface DictionaryC< - D extends t.Mixed, - C extends t.Mixed, -> extends t.DictionaryType< +export interface DictionaryC + extends t.DictionaryType< D, C, { diff --git a/src/codecTools/partialRecord.ts b/src/codecTools/partialRecord.ts index 5c0d14b..ea6806f 100644 --- a/src/codecTools/partialRecord.ts +++ b/src/codecTools/partialRecord.ts @@ -2,10 +2,8 @@ import * as t from 'io-ts'; // TODO: https://github.com/gcanti/io-ts/issues/429 - remove if/when io-ts supports this natively -export interface PartialRecordC< - D extends t.Mixed, - C extends t.Mixed, -> extends t.DictionaryType< +export interface PartialRecordC + extends t.DictionaryType< D, C, { diff --git a/src/enums.ts b/src/enums.ts index 251ddf2..5ba19b5 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -20,4 +20,4 @@ export const HttpMethod = makeEnum({ /** * Override to cast as string */ -export type HttpMethod = typeof HttpMethod[keyof typeof HttpMethod]; +export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];