diff --git a/.eslintrc.yml b/.eslintrc.yml index 31c484a9..b04839b8 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -33,6 +33,9 @@ rules: '@typescript-eslint/prefer-readonly-parameter-types': - error - ignoreInferredTypes: true + # See https://zenn.dev/teppeis/articles/2023-04-typescript-5_0-verbatim-module-syntax for enabling reason + '@typescript-eslint/consistent-type-imports': 'error' + '@typescript-eslint/no-import-type-side-effects': 'error' parser: '@typescript-eslint/parser' parserOptions: ecmaVersion: 12 diff --git a/__tests__/postbuild/main.test.ts b/__tests__/postbuild/main.test.ts index f24b472a..0adeb652 100644 --- a/__tests__/postbuild/main.test.ts +++ b/__tests__/postbuild/main.test.ts @@ -1,5 +1,6 @@ import { env, execPath } from 'process'; -import { execFileSync, ExecFileSyncOptions } from 'child_process'; +import type { ExecFileSyncOptions } from 'child_process'; +import { execFileSync } from 'child_process'; import { join } from 'path'; import { expect, test } from '@jest/globals'; diff --git a/jest.post.config.ts b/jest.post.config.ts index 76490361..bc6f9166 100644 --- a/jest.post.config.ts +++ b/jest.post.config.ts @@ -17,4 +17,4 @@ const config: Config.InitialOptions = { extensionsToTreatAsEsm: ['.ts'], testMatch: ['**/__tests__/postbuild/**/*.test.ts'], }; -export default config; +module.exports = config; diff --git a/jest.pre.config.ts b/jest.pre.config.ts index 28d753ee..7c547f3b 100644 --- a/jest.pre.config.ts +++ b/jest.pre.config.ts @@ -17,4 +17,4 @@ const config: Config.InitialOptions = { extensionsToTreatAsEsm: ['.ts'], testMatch: ['**/__tests__/prebuild/**/*.test.ts'], }; -export default config; +module.exports = config; diff --git a/package-lock.json b/package-lock.json index 3cd0d5cd..d90c527f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ }, "devDependencies": { "@octokit/types": "^9.0.0", - "@tsconfig/node16-strictest-esm": "^1.0.3", "@types/jest": "^29.5.0", "@types/node": "^16.18.23", "@typescript-eslint/eslint-plugin": "^5.58.0", @@ -28,7 +27,7 @@ "jest": "^29.5.0", "ts-node": "^10.9.1", "tsx": "^3.12.6", - "typescript": "^4.9.5" + "typescript": "^5.0.4" }, "engines": { "node": "16.x" @@ -1933,12 +1932,6 @@ "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", "dev": true }, - "node_modules/@tsconfig/node16-strictest-esm": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node16-strictest-esm/-/node16-strictest-esm-1.0.3.tgz", - "integrity": "sha512-0/QTPDkKmE2dy0dMRstPCv4VJ+gUGgvMKzaWd5P3hgdlmPqYqe1pJxDGUlNYbSgUBlncIvvX+mIeZarokysNgg==", - "dev": true - }, "node_modules/@types/babel__core": { "version": "7.20.0", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.0.tgz", @@ -5739,16 +5732,16 @@ } }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=12.20" } }, "node_modules/universal-user-agent": { @@ -7413,12 +7406,6 @@ "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", "dev": true }, - "@tsconfig/node16-strictest-esm": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node16-strictest-esm/-/node16-strictest-esm-1.0.3.tgz", - "integrity": "sha512-0/QTPDkKmE2dy0dMRstPCv4VJ+gUGgvMKzaWd5P3hgdlmPqYqe1pJxDGUlNYbSgUBlncIvvX+mIeZarokysNgg==", - "dev": true - }, "@types/babel__core": { "version": "7.20.0", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.0.tgz", @@ -10100,9 +10087,9 @@ "dev": true }, "typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true }, "universal-user-agent": { diff --git a/package.json b/package.json index d40c28d1..e760c2c9 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ }, "devDependencies": { "@octokit/types": "^9.0.0", - "@tsconfig/node16-strictest-esm": "^1.0.3", "@types/jest": "^29.5.0", "@types/node": "^16.18.23", "@typescript-eslint/eslint-plugin": "^5.58.0", @@ -46,6 +45,6 @@ "jest": "^29.5.0", "ts-node": "^10.9.1", "tsx": "^3.12.6", - "typescript": "^4.9.5" + "typescript": "^5.0.4" } } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..7ab0cb8f --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,30 @@ +{ + // Import from https://github.com/tsconfig/bases/commit/0ae4791797d8ba3dd2bca9aca880eb2d3e30e6fb + // To avoid issues around tsconfig.extends array + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Node 16 + Strictest", + "compilerOptions": { + "lib": [ + "es2021" + ], + "module": "commonjs", + "target": "es2021", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node", + "allowUnusedLabels": false, + "allowUnreachableCode": false, + "exactOptionalPropertyTypes": true, + "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "verbatimModuleSyntax": true, + "checkJs": true + } +} diff --git a/tsconfig.json b/tsconfig.json index 315732d1..20f9039b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { - // https://github.com/tsconfig/bases/blob/d1543a94d47c3ef9af9987790742b09caf71b71d/bases/node16-strictest-esm.combined.json - "extends": "@tsconfig/node16-strictest-esm/tsconfig.json", + // TODO: Use tsconfig/base after all tools support tsconfig.extends array + "extends": "./tsconfig.base.json", "compilerOptions": { // https://www.typescriptlang.org/docs/handbook/esm-node.html "module": "node16",