Skip to content

fix(dev): Correctly lint scripts typescript files #4963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
};
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down