From 775e5b8cd076183c770b2dd6ea316e35656bf5c1 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Thu, 21 Apr 2022 15:27:16 -0700 Subject: [PATCH] fix eslint config for files in `scripts` --- .eslintrc.js | 8 ++++++++ packages/gatsby/.eslintrc.js | 2 +- tsconfig.json | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 956f3681ba72..01d0da16cf14 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -33,6 +33,14 @@ module.exports = { project: ['tsconfig.test.json'], }, }, + { + 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'], + }, + }, { files: ['*.tsx'], rules: { diff --git a/packages/gatsby/.eslintrc.js b/packages/gatsby/.eslintrc.js index 6aff306daa40..56cb2e62ad47 100644 --- a/packages/gatsby/.eslintrc.js +++ b/packages/gatsby/.eslintrc.js @@ -7,6 +7,6 @@ module.exports = { jsx: true, }, // ignore these because they're not covered by a `tsconfig`, which makes eslint throw an error - ignorePatterns: ['scripts/prepack.ts', 'gatsby-browser.d.ts', 'gatsby-node.d.ts'], + ignorePatterns: ['gatsby-browser.d.ts', 'gatsby-node.d.ts'], extends: ['../../.eslintrc.js'], }; diff --git a/tsconfig.json b/tsconfig.json index f2ffa0c4e07c..98848bfdcbe8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,10 @@ { "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,