From a555fd1dcbcec4c9d7e6c7c857285c1bcca88783 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Wed, 18 May 2022 12:48:28 +0800 Subject: [PATCH] refactor: make each tsconfig explicitly declare module and include/exclude (#7443) --- __tests__/validate-package-json.test.ts | 4 +- __tests__/validate-tsconfig.test.ts | 66 +++++++++++++++++++ .../create-docusaurus/tsconfig.build.json | 5 +- packages/create-docusaurus/tsconfig.json | 3 +- .../docusaurus-cssnano-preset/tsconfig.json | 6 +- packages/docusaurus-logger/tsconfig.json | 6 +- packages/docusaurus-mdx-loader/tsconfig.json | 5 +- .../docusaurus-migrate/tsconfig.build.json | 5 +- packages/docusaurus-migrate/tsconfig.json | 3 +- .../tsconfig.json | 9 ++- .../tsconfig.json | 6 +- .../tsconfig.client.json | 4 +- .../tsconfig.json | 1 + .../tsconfig.json | 6 +- .../tsconfig.client.json | 4 +- .../docusaurus-plugin-debug/tsconfig.json | 3 +- .../tsconfig.client.json | 4 +- .../tsconfig.json | 3 +- .../tsconfig.client.json | 4 +- .../tsconfig.json | 3 +- .../tsconfig.client.json | 4 +- .../tsconfig.json | 3 +- .../tsconfig.client.json | 4 +- packages/docusaurus-plugin-pwa/tsconfig.json | 9 ++- .../docusaurus-plugin-sitemap/tsconfig.json | 6 +- .../docusaurus-preset-classic/tsconfig.json | 6 +- .../tsconfig.json | 6 +- .../docusaurus-theme-classic/tsconfig.json | 3 +- .../docusaurus-theme-common/tsconfig.json | 4 +- .../tsconfig.client.json | 4 +- .../tsconfig.json | 2 + .../tsconfig.client.json | 4 +- .../tsconfig.json | 2 + .../tsconfig.build.json | 6 +- packages/docusaurus-types/package.json | 3 - .../docusaurus-utils-common/tsconfig.json | 6 +- .../docusaurus-utils-validation/tsconfig.json | 6 +- packages/docusaurus-utils/tsconfig.json | 6 +- packages/docusaurus/tsconfig.client.json | 4 +- packages/docusaurus/tsconfig.json | 3 +- packages/docusaurus/tsconfig.server.json | 1 + packages/eslint-plugin/tsconfig.json | 6 +- packages/lqip-loader/tsconfig.json | 6 +- packages/stylelint-copyright/tsconfig.json | 6 +- tsconfig.json | 10 ++- 45 files changed, 223 insertions(+), 47 deletions(-) create mode 100644 __tests__/validate-tsconfig.test.ts diff --git a/__tests__/validate-package-json.test.ts b/__tests__/validate-package-json.test.ts index f6003be9bacf..31bd4e8b5e8d 100644 --- a/__tests__/validate-package-json.test.ts +++ b/__tests__/validate-package-json.test.ts @@ -62,7 +62,9 @@ describe('packages', () => { const packageJsonFiles = await getPackagesJsonFiles(); packageJsonFiles - .filter((packageJsonFile) => packageJsonFile.content.name.startsWith('@')) + .filter((packageJsonFile) => + packageJsonFile.content.name?.startsWith('@'), + ) .forEach((packageJsonFile) => { if (packageJsonFile) { // Unfortunately jest custom message do not exist in loops, diff --git a/__tests__/validate-tsconfig.test.ts b/__tests__/validate-tsconfig.test.ts new file mode 100644 index 000000000000..7a80816b7a98 --- /dev/null +++ b/__tests__/validate-tsconfig.test.ts @@ -0,0 +1,66 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import fs from 'fs-extra'; +import {Globby} from '@docusaurus/utils'; +import {Joi} from '@docusaurus/utils-validation'; + +type TsconfigFile = { + file: string; + content: { + extends?: string; + compilerOptions: { + [key: string]: unknown; + }; + }; +}; + +async function getTsconfigFiles(): Promise { + const files = await Globby('packages/*/tsconfig.*'); + return Promise.all( + files.map((file) => fs.readJSON(file).then((content) => ({file, content}))), + ); +} + +const tsconfigSchema = Joi.object({ + extends: '../../tsconfig.json', + compilerOptions: Joi.alternatives().conditional( + Joi.object({noEmit: true}).unknown(), + { + then: Joi.object({ + noEmit: Joi.valid(true).required(), + incremental: Joi.forbidden(), + tsBuildInfoFile: Joi.forbidden(), + outDir: Joi.forbidden(), + module: Joi.valid('commonjs', 'es2020', 'esnext').required(), + }).unknown(), + otherwise: Joi.object({ + noEmit: Joi.valid(false).required(), + incremental: Joi.valid(true).required(), + rootDir: Joi.valid('src').required(), + outDir: Joi.valid('lib').required(), + module: Joi.valid('commonjs', 'es2020', 'esnext').required(), + }).unknown(), + }, + ), +}).unknown(); + +describe('tsconfig files', () => { + it('contain all required fields', async () => { + const tsconfigFiles = await getTsconfigFiles(); + tsconfigFiles.forEach((file) => { + try { + Joi.attempt(file.content, tsconfigSchema); + } catch (e) { + ( + e as Error + ).message += `\n${file.file} does not match the required schema.`; + throw e; + } + }); + }); +}); diff --git a/packages/create-docusaurus/tsconfig.build.json b/packages/create-docusaurus/tsconfig.build.json index 3262001f72c0..6f46335ae9d0 100644 --- a/packages/create-docusaurus/tsconfig.build.json +++ b/packages/create-docusaurus/tsconfig.build.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "module": "es2020", "incremental": true, @@ -8,6 +9,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src/"], - "exclude": ["templates/"] + "include": ["src"], + "exclude": ["templates/", "**/__tests__/**"] } diff --git a/packages/create-docusaurus/tsconfig.json b/packages/create-docusaurus/tsconfig.json index 1b8a3ef4baf3..ef9bff21668e 100644 --- a/packages/create-docusaurus/tsconfig.json +++ b/packages/create-docusaurus/tsconfig.json @@ -7,5 +7,6 @@ "module": "esnext", "rootDir": "." }, - "include": ["bin"] + "include": ["bin"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-cssnano-preset/tsconfig.json b/packages/docusaurus-cssnano-preset/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/docusaurus-cssnano-preset/tsconfig.json +++ b/packages/docusaurus-cssnano-preset/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-logger/tsconfig.json b/packages/docusaurus-logger/tsconfig.json index aee99fc0f38e..7807612b51a5 100644 --- a/packages/docusaurus-logger/tsconfig.json +++ b/packages/docusaurus-logger/tsconfig.json @@ -1,11 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "sourceMap": true, "declarationMap": true, + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-mdx-loader/tsconfig.json b/packages/docusaurus-mdx-loader/tsconfig.json index 4cc153c7f158..7807612b51a5 100644 --- a/packages/docusaurus-mdx-loader/tsconfig.json +++ b/packages/docusaurus-mdx-loader/tsconfig.json @@ -1,12 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "sourceMap": true, "declarationMap": true, + "module": "commonjs", "rootDir": "src", "outDir": "lib" }, - "include": ["src"] + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-migrate/tsconfig.build.json b/packages/docusaurus-migrate/tsconfig.build.json index 89b76f28591d..e43e58accad2 100644 --- a/packages/docusaurus-migrate/tsconfig.build.json +++ b/packages/docusaurus-migrate/tsconfig.build.json @@ -1,11 +1,14 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" }, - "include": ["src"] + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-migrate/tsconfig.json b/packages/docusaurus-migrate/tsconfig.json index c930032b738b..4c04aae29fd9 100644 --- a/packages/docusaurus-migrate/tsconfig.json +++ b/packages/docusaurus-migrate/tsconfig.json @@ -7,5 +7,6 @@ "allowJs": true, "rootDir": "." }, - "include": ["bin"] + "include": ["bin"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-client-redirects/tsconfig.json b/packages/docusaurus-plugin-client-redirects/tsconfig.json index 7b696ed3843d..80e43e9813ef 100644 --- a/packages/docusaurus-plugin-client-redirects/tsconfig.json +++ b/packages/docusaurus-plugin-client-redirects/tsconfig.json @@ -1,10 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", - "outDir": "lib", - "typeRoots": ["./types", "./node_modules/@types"] - } + "outDir": "lib" + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-content-blog/tsconfig.json b/packages/docusaurus-plugin-content-blog/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/docusaurus-plugin-content-blog/tsconfig.json +++ b/packages/docusaurus-plugin-content-blog/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-content-docs/tsconfig.client.json b/packages/docusaurus-plugin-content-docs/tsconfig.client.json index 018e125eb75c..2741f3ca3890 100644 --- a/packages/docusaurus-plugin-content-docs/tsconfig.client.json +++ b/packages/docusaurus-plugin-content-docs/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src/client", "src/*.d.ts"] + "include": ["src/client", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-content-docs/tsconfig.json b/packages/docusaurus-plugin-content-docs/tsconfig.json index 57f0111934e4..48e200409e4e 100644 --- a/packages/docusaurus-plugin-content-docs/tsconfig.json +++ b/packages/docusaurus-plugin-content-docs/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "module": "commonjs", diff --git a/packages/docusaurus-plugin-content-pages/tsconfig.json b/packages/docusaurus-plugin-content-pages/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/docusaurus-plugin-content-pages/tsconfig.json +++ b/packages/docusaurus-plugin-content-pages/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-debug/tsconfig.client.json b/packages/docusaurus-plugin-debug/tsconfig.client.json index 836fc6391ac5..2fd5ae7c4d29 100644 --- a/packages/docusaurus-plugin-debug/tsconfig.client.json +++ b/packages/docusaurus-plugin-debug/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src/theme", "src/*.d.ts"] + "include": ["src/theme", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-debug/tsconfig.json b/packages/docusaurus-plugin-debug/tsconfig.json index f3146ecc7574..7c1bb85ac462 100644 --- a/packages/docusaurus-plugin-debug/tsconfig.json +++ b/packages/docusaurus-plugin-debug/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "module": "commonjs", @@ -9,5 +10,5 @@ "outDir": "lib" }, "include": ["src"], - "exclude": ["src/theme"] + "exclude": ["src/theme", "**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-google-analytics/tsconfig.client.json b/packages/docusaurus-plugin-google-analytics/tsconfig.client.json index 3e8fdb9a0b8e..766ffcc81d67 100644 --- a/packages/docusaurus-plugin-google-analytics/tsconfig.client.json +++ b/packages/docusaurus-plugin-google-analytics/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src/analytics.ts", "src/*.d.ts"] + "include": ["src/analytics.ts", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-google-analytics/tsconfig.json b/packages/docusaurus-plugin-google-analytics/tsconfig.json index 9ca36591661f..77a4365aedfe 100644 --- a/packages/docusaurus-plugin-google-analytics/tsconfig.json +++ b/packages/docusaurus-plugin-google-analytics/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "module": "commonjs", @@ -9,5 +10,5 @@ "outDir": "lib" }, "include": ["src"], - "exclude": ["src/analytics.ts"] + "exclude": ["src/analytics.ts", "**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-google-gtag/tsconfig.client.json b/packages/docusaurus-plugin-google-gtag/tsconfig.client.json index b00cb512062b..985b9a458099 100644 --- a/packages/docusaurus-plugin-google-gtag/tsconfig.client.json +++ b/packages/docusaurus-plugin-google-gtag/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src/gtag.ts", "src/options.ts", "src/*.d.ts"] + "include": ["src/gtag.ts", "src/options.ts", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-google-gtag/tsconfig.json b/packages/docusaurus-plugin-google-gtag/tsconfig.json index cad9a09f4e49..1b3271a718e6 100644 --- a/packages/docusaurus-plugin-google-gtag/tsconfig.json +++ b/packages/docusaurus-plugin-google-gtag/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "module": "commonjs", @@ -9,5 +10,5 @@ "outDir": "lib" }, "include": ["src"], - "exclude": ["src/gtag.ts"] + "exclude": ["src/gtag.ts", "**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-ideal-image/tsconfig.client.json b/packages/docusaurus-plugin-ideal-image/tsconfig.client.json index 836fc6391ac5..2fd5ae7c4d29 100644 --- a/packages/docusaurus-plugin-ideal-image/tsconfig.client.json +++ b/packages/docusaurus-plugin-ideal-image/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src/theme", "src/*.d.ts"] + "include": ["src/theme", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-ideal-image/tsconfig.json b/packages/docusaurus-plugin-ideal-image/tsconfig.json index f3146ecc7574..7c1bb85ac462 100644 --- a/packages/docusaurus-plugin-ideal-image/tsconfig.json +++ b/packages/docusaurus-plugin-ideal-image/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "module": "commonjs", @@ -9,5 +10,5 @@ "outDir": "lib" }, "include": ["src"], - "exclude": ["src/theme"] + "exclude": ["src/theme", "**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-pwa/tsconfig.client.json b/packages/docusaurus-plugin-pwa/tsconfig.client.json index bb29e4aa07e9..9404df7cd886 100644 --- a/packages/docusaurus-plugin-pwa/tsconfig.client.json +++ b/packages/docusaurus-plugin-pwa/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -14,5 +15,6 @@ "src/*.d.ts", "src/registerSw.ts", "src/renderReloadPopup.tsx" - ] + ], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-plugin-pwa/tsconfig.json b/packages/docusaurus-plugin-pwa/tsconfig.json index 98aa9153f659..5eb9d05af96b 100644 --- a/packages/docusaurus-plugin-pwa/tsconfig.json +++ b/packages/docusaurus-plugin-pwa/tsconfig.json @@ -2,11 +2,18 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" }, "include": ["src"], - "exclude": ["src/theme/", "src/registerSw.ts", "src/renderReloadPopup.tsx"] + "exclude": [ + "src/theme/", + "src/registerSw.ts", + "src/renderReloadPopup.tsx", + "**/__tests__/**" + ] } diff --git a/packages/docusaurus-plugin-sitemap/tsconfig.json b/packages/docusaurus-plugin-sitemap/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/docusaurus-plugin-sitemap/tsconfig.json +++ b/packages/docusaurus-plugin-sitemap/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-preset-classic/tsconfig.json b/packages/docusaurus-preset-classic/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/docusaurus-preset-classic/tsconfig.json +++ b/packages/docusaurus-preset-classic/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-remark-plugin-npm2yarn/tsconfig.json b/packages/docusaurus-remark-plugin-npm2yarn/tsconfig.json index aee99fc0f38e..7807612b51a5 100644 --- a/packages/docusaurus-remark-plugin-npm2yarn/tsconfig.json +++ b/packages/docusaurus-remark-plugin-npm2yarn/tsconfig.json @@ -1,11 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "sourceMap": true, "declarationMap": true, + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-theme-classic/tsconfig.json b/packages/docusaurus-theme-classic/tsconfig.json index 659cb2cc6b98..4ee40b287f62 100644 --- a/packages/docusaurus-theme-classic/tsconfig.json +++ b/packages/docusaurus-theme-classic/tsconfig.json @@ -5,5 +5,6 @@ "module": "esnext", "noEmit": true }, - "include": ["src/"] + "include": ["src/"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-theme-common/tsconfig.json b/packages/docusaurus-theme-common/tsconfig.json index a6f83d37f330..ceffc5496b4b 100644 --- a/packages/docusaurus-theme-common/tsconfig.json +++ b/packages/docusaurus-theme-common/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "module": "esnext", @@ -10,5 +11,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src"] + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-theme-live-codeblock/tsconfig.client.json b/packages/docusaurus-theme-live-codeblock/tsconfig.client.json index 1988ff0b3884..222005186ea5 100644 --- a/packages/docusaurus-theme-live-codeblock/tsconfig.client.json +++ b/packages/docusaurus-theme-live-codeblock/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "module": "esnext", "target": "esnext" }, - "include": ["src/theme", "src/*.d.ts", "src/custom-buble.ts"] + "include": ["src/theme", "src/*.d.ts", "src/custom-buble.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-theme-live-codeblock/tsconfig.json b/packages/docusaurus-theme-live-codeblock/tsconfig.json index e9a5d5fd3387..c0b15f81fcc8 100644 --- a/packages/docusaurus-theme-live-codeblock/tsconfig.json +++ b/packages/docusaurus-theme-live-codeblock/tsconfig.json @@ -2,8 +2,10 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" }, diff --git a/packages/docusaurus-theme-search-algolia/tsconfig.client.json b/packages/docusaurus-theme-search-algolia/tsconfig.client.json index 9e8321ca3deb..a8c1d3f7de50 100644 --- a/packages/docusaurus-theme-search-algolia/tsconfig.client.json +++ b/packages/docusaurus-theme-search-algolia/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "module": "esnext", "target": "esnext" }, - "include": ["src/theme", "src/client", "src/*.d.ts"] + "include": ["src/theme", "src/client", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-theme-search-algolia/tsconfig.json b/packages/docusaurus-theme-search-algolia/tsconfig.json index 413bf0796347..3c8737f51c0d 100644 --- a/packages/docusaurus-theme-search-algolia/tsconfig.json +++ b/packages/docusaurus-theme-search-algolia/tsconfig.json @@ -2,8 +2,10 @@ "extends": "../../tsconfig.json", "references": [{"path": "./tsconfig.client.json"}], "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" }, diff --git a/packages/docusaurus-theme-translations/tsconfig.build.json b/packages/docusaurus-theme-translations/tsconfig.build.json index a0eb19189c73..5370e86c56a5 100644 --- a/packages/docusaurus-theme-translations/tsconfig.build.json +++ b/packages/docusaurus-theme-translations/tsconfig.build.json @@ -1,12 +1,16 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "sourceMap": true, "declarationMap": true, + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-types/package.json b/packages/docusaurus-types/package.json index b50c2100a5af..051f1625c8ff 100644 --- a/packages/docusaurus-types/package.json +++ b/packages/docusaurus-types/package.json @@ -12,9 +12,6 @@ "directory": "packages/docusaurus-types" }, "license": "MIT", - "scripts": { - "test": "tsc -p ." - }, "dependencies": { "commander": "^5.1.0", "history": "^4.9.0", diff --git a/packages/docusaurus-utils-common/tsconfig.json b/packages/docusaurus-utils-common/tsconfig.json index c28192960036..f787010fcd78 100644 --- a/packages/docusaurus-utils-common/tsconfig.json +++ b/packages/docusaurus-utils-common/tsconfig.json @@ -1,12 +1,16 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "sourceMap": true, "declarationMap": true, + "module": "commonjs", "rootDir": "src", "outDir": "lib", "noEmitHelpers": false - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-utils-validation/tsconfig.json b/packages/docusaurus-utils-validation/tsconfig.json index aee99fc0f38e..7807612b51a5 100644 --- a/packages/docusaurus-utils-validation/tsconfig.json +++ b/packages/docusaurus-utils-validation/tsconfig.json @@ -1,11 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "sourceMap": true, "declarationMap": true, + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus-utils/tsconfig.json b/packages/docusaurus-utils/tsconfig.json index aee99fc0f38e..7807612b51a5 100644 --- a/packages/docusaurus-utils/tsconfig.json +++ b/packages/docusaurus-utils/tsconfig.json @@ -1,11 +1,15 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", "sourceMap": true, "declarationMap": true, + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus/tsconfig.client.json b/packages/docusaurus/tsconfig.client.json index 018e125eb75c..2741f3ca3890 100644 --- a/packages/docusaurus/tsconfig.client.json +++ b/packages/docusaurus/tsconfig.client.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo-client", @@ -9,5 +10,6 @@ "rootDir": "src", "outDir": "lib" }, - "include": ["src/client", "src/*.d.ts"] + "include": ["src/client", "src/*.d.ts"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus/tsconfig.json b/packages/docusaurus/tsconfig.json index ebbe87890df4..cf74f4e2b7a6 100644 --- a/packages/docusaurus/tsconfig.json +++ b/packages/docusaurus/tsconfig.json @@ -11,5 +11,6 @@ "rootDir": ".", "module": "esnext" }, - "include": ["bin"] + "include": ["bin"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/docusaurus/tsconfig.server.json b/packages/docusaurus/tsconfig.server.json index eb1b6945ac88..f800ce6a5fe5 100644 --- a/packages/docusaurus/tsconfig.server.json +++ b/packages/docusaurus/tsconfig.server.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "composite": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/packages/eslint-plugin/tsconfig.json b/packages/eslint-plugin/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/eslint-plugin/tsconfig.json +++ b/packages/eslint-plugin/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/lqip-loader/tsconfig.json b/packages/lqip-loader/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/lqip-loader/tsconfig.json +++ b/packages/lqip-loader/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/packages/stylelint-copyright/tsconfig.json b/packages/stylelint-copyright/tsconfig.json index f5902ba1089b..80e43e9813ef 100644 --- a/packages/stylelint-copyright/tsconfig.json +++ b/packages/stylelint-copyright/tsconfig.json @@ -1,9 +1,13 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "noEmit": false, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", + "module": "commonjs", "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] } diff --git a/tsconfig.json b/tsconfig.json index e7d9ca05d0eb..9b4ff3711eb3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,13 +2,17 @@ "compilerOptions": { /* Emit */ "target": "ES2020", - "module": "commonjs", - "lib": ["ESNext", "DOM"], + "lib": ["ESNext"], "declaration": true, + // These two options will be selectively overridden in each project. + // Utility libraries will have source maps on, but plugins will not. "declarationMap": false, + "sourceMap": false, "jsx": "react-native", "importHelpers": true, "noEmitHelpers": true, + // Avoid accidentally using this config to build + "noEmit": true, /* Strict Type-Checking Options */ "allowUnreachableCode": false, @@ -44,5 +48,5 @@ "isolatedModules": true, "skipLibCheck": true // @types/webpack and webpack/types.d.ts are not the same thing }, - "exclude": ["node_modules", "**/__tests__/**", "**/lib/**/*"] + "exclude": ["node_modules", "**/lib/**/*"] }