Skip to content

Commit 9ded65e

Browse files
lobsterkatieLms24
authored andcommitted
fix(dev): Correctly lint scripts typescript files (#4963)
Previously, we've had to tell eslint to ignore TS files in package-level `scripts` directories, because they weren't included by any existing TS eslint config. This fixes that, by adding them to both our main `.eslintrc.js` and (since that new entry needs a tsconfig to which to point) our main `tsconfig.json`.
1 parent ed17a93 commit 9ded65e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.eslintrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ module.exports = {
3333
project: ['tsconfig.test.json'],
3434
},
3535
},
36+
{
37+
files: ['**/scripts/**/*.ts'],
38+
parserOptions: {
39+
// since filepaths are relative to the working directory, we need to go back up to reach the repo root level
40+
// tsconfig
41+
project: ['../../tsconfig.json'],
42+
},
43+
},
3644
{
3745
files: ['*.tsx'],
3846
rules: {

packages/gatsby/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ module.exports = {
77
jsx: true,
88
},
99
// ignore these because they're not covered by a `tsconfig`, which makes eslint throw an error
10-
ignorePatterns: ['scripts/prepack.ts', 'gatsby-browser.d.ts', 'gatsby-node.d.ts'],
10+
ignorePatterns: ['gatsby-browser.d.ts', 'gatsby-node.d.ts'],
1111
extends: ['../../.eslintrc.js'],
1212
};

tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"extends": "./packages/typescript/tsconfig.json",
33

4+
// include scripts here because their TS config isn't package-specific, and they need to be included in a tsconfig
5+
// file to be linted
6+
"include": ["**/scripts/**/*.ts"],
7+
48
"compilerOptions": {
59
// TODO: turn these on once we switch to only generating types once, using `tsconfig.types.json`
610
// "declaration": false,

0 commit comments

Comments
 (0)