From 11050e320d8166c37d79066a77eed8d5ba4a9f67 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 25 Apr 2022 22:29:21 -0700 Subject: [PATCH 1/3] add tsconfig for dev tools --- tsconfig.dev.json | 6 ++++++ tsconfig.json | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 tsconfig.dev.json diff --git a/tsconfig.dev.json b/tsconfig.dev.json new file mode 100644 index 000000000000..49053ea1124c --- /dev/null +++ b/tsconfig.dev.json @@ -0,0 +1,6 @@ +// TODO This should eventually end up as the tsconfig for a dev-utils package +{ + "extends": "./tsconfig.json", + + "include": ["**/scripts/**/*.ts"], +} diff --git a/tsconfig.json b/tsconfig.json index 98848bfdcbe8..f2ffa0c4e07c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,6 @@ { "extends": "./packages/typescript/tsconfig.json", - // include scripts here because their TS config isn't package-specific, and they need to be included in a tsconfig - // file to be linted - "include": ["**/scripts/**/*.ts"], - "compilerOptions": { // TODO: turn these on once we switch to only generating types once, using `tsconfig.types.json` // "declaration": false, From 8f817757d6d2ac83824f2e65fb52344790af4bcf Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 25 Apr 2022 22:31:08 -0700 Subject: [PATCH 2/3] fix linting of scripts --- .eslintrc.js | 6 ++---- packages/gatsby/.eslintrc.js | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 01d0da16cf14..9da9cd411f5b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -34,11 +34,9 @@ module.exports = { }, }, { - files: ['**/scripts/**/*.ts'], + files: ['scripts/**/*.ts'], parserOptions: { - // since filepaths are relative to the working directory, we need to go back up to reach the repo root level - // tsconfig - project: ['../../tsconfig.json'], + project: ['tsconfig.dev.json'], }, }, { diff --git a/packages/gatsby/.eslintrc.js b/packages/gatsby/.eslintrc.js index 56cb2e62ad47..88a6a96293ee 100644 --- a/packages/gatsby/.eslintrc.js +++ b/packages/gatsby/.eslintrc.js @@ -8,5 +8,13 @@ module.exports = { }, // ignore these because they're not covered by a `tsconfig`, which makes eslint throw an error ignorePatterns: ['gatsby-browser.d.ts', 'gatsby-node.d.ts'], + overrides: [ + { + files: ['scripts/**/*.ts'], + parserOptions: { + project: ['../../tsconfig.dev.json'], + }, + }, + ], extends: ['../../.eslintrc.js'], }; From 6572ff9652048801874679a16d0cf7c862727ac8 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Fri, 22 Apr 2022 14:18:06 -0700 Subject: [PATCH 3/3] fix linting errors in build:types:watch script --- scripts/build-types-watch.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build-types-watch.ts b/scripts/build-types-watch.ts index d8a4cedb32aa..8b29635479d0 100644 --- a/scripts/build-types-watch.ts +++ b/scripts/build-types-watch.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /** * If `yarn build:types:watch` is run without types files previously having been created, the build will get stuck in an * errored state. This happens because lerna runs all of the packages' `yarn build:types:watch` statements in parallel, @@ -28,7 +29,9 @@ for (const pkg of packages) { continue; } - const packageJSON = JSON.parse(fs.readFileSync(path.resolve(packagePath, 'package.json'), 'utf-8')); + const packageJSON = JSON.parse(fs.readFileSync(path.resolve(packagePath, 'package.json'), 'utf-8')) as { + scripts: Record; + }; if ('build:types' in packageJSON.scripts && !fs.existsSync(path.resolve(packagePath, 'build/types'))) { console.warn(