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'], }; 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( 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,