Skip to content
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

bug(gatsby-plugin-typescript): linting causes errors #21913

Closed
cpboyd opened this issue Mar 2, 2020 · 9 comments · Fixed by #22308
Closed

bug(gatsby-plugin-typescript): linting causes errors #21913

cpboyd opened this issue Mar 2, 2020 · 9 comments · Fixed by #22308
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@cpboyd
Copy link
Contributor

cpboyd commented Mar 2, 2020

Description

PR #18721 seems to have broken my builds.

I get errors thrown at Typescript-specific keywords like enum and as, even though my eslint config doesn't throw any errors for those.

Reverting to [email protected] resolves these issues.

Steps to reproduce

Use [email protected] for any Typescript project containing Typescript files with enum or as.

Expected result

These previously compiled without issue.

Actual result

Crash on develop/build.

Environment

Run gatsby info --clipboard in your project directory and paste the output here.

  System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.8.0 - /usr/local/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.14.1 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 80.0.3987.122
    Safari: 13.0.5
  npmGlobalPackages:
    gatsby-cli: 2.9.0
@cpboyd cpboyd added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 2, 2020
@pvdz
Copy link
Contributor

pvdz commented Mar 3, 2020

@ThewBear could you please look into this?

@ThewBear
Copy link
Contributor

ThewBear commented Mar 3, 2020

I couldn't reproduce. Could you give me an example code?

@cpboyd
Copy link
Contributor Author

cpboyd commented Mar 3, 2020

@ThewBear After trying to make a simplified reproduction, it seems like it only happens with theme workspaces. I'll try to get you a repro

@cpboyd
Copy link
Contributor Author

cpboyd commented Mar 3, 2020

@LekoArts LekoArts added the status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. label Mar 4, 2020
@LekoArts
Copy link
Contributor

LekoArts commented Mar 4, 2020

Also seeing the issue. You can clone https://github.com/LekoArts/gatsby-themes and run yarn and then yarn workspace minimal-blog develop and see a bunch of errors like:

 ERROR #98123  WEBPACK

Generating development JavaScript bundle failed


/mnt/c/Users/Lennart/Development/GitHub/gatsby-themes/themes/gatsby-theme-minimal-blog/src/hooks/use-site-metadata.tsx
  7:7  error  Parsing error: Unexpected token

   5 |     siteMetadata: {
   6 |       siteTitle: string
>  7 |       siteTitleAlt: string
     |       ^
   8 |       siteHeadline: string
   9 |       siteUrl: string
  10 |       siteDescription: string

✖ 1 problem (1 error, 0 warnings)

This completely brakes the development and I'll rollback for now.

@brycefranzen
Copy link

I'm having the same issue -- working in a mono repo with yarn workspaces. Worked on version 2.1.23. Any higher version, it fails during build/develop.

@wardpeet
Copy link
Contributor

We reverted it in version [email protected] thanks for pointing this out! And sorry for the troubles ❤️

@pieh
Copy link
Contributor

pieh commented Mar 16, 2020

I was diving into this issue and here's gist of it:
eslint-config-react-app already adds .ts specific rules - that's why it worked nicely in non-workspaces examples. Problem is that the "criteria" for ts is **/*.ts?(x) ( https://github.com/facebook/create-react-app/blob/master/packages/eslint-config-react-app/index.js#L57 ) - the ** prefix seems to prevent it from matching files outside of project directories so it fails in workspaces scenario as themes directories are outside of site directory.

Potential fixes here (that would need to be done if we restore eslint loader for ts, as we reverted that part recently):

  • make a PR to eslint-config-react-app to use just *.ts?(x) pattern ( will need to go through history there to see if the **/ prefix is very intentional

@pieh
Copy link
Contributor

pieh commented Mar 17, 2020

I created PR for eslint-config-react-app ( facebook/create-react-app#8666 ), will see if we can revert the revert / restore TS linting with workspaces support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
7 participants