getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.
https://docs.grit.io/
MIT License
3.17k stars 82 forks source link

Some `.tsx` files are throwing `code:300` #561

Open alexgorbatchev opened 4 weeks ago

alexgorbatchev commented 4 weeks ago

I was testing grit on a large corporate project and some .tsx files are throwing an error. Unfortunately I can't paste code here verbatim due to IP, but here's is one complete file and one snippet that fail to parse:

> grit --version
grit 0.1.1
import * as React from 'react';

import { ExternalLink } from 'internal';

import { SLACK_CHANNEL, SLACK_URL } from '../../constants';

export function OnboardingDocLink() {
  return (
    <ExternalLink
      to="https://edited/pages/viewpage.action?spaceKey=edited&title=edited"
                                                               ^----- grit pointed here
      testId="onboarding-doc-link"
    >
      Onboarding document
    </ExternalLink>
  );
}

export function SlackLink() {
  return (
    <ExternalLink to={SLACK_URL} testId="slack-link">
      {SLACK_CHANNEL}
    </ExternalLink>
  );
}

in another file

const renderButton = (props: { onClick: () => void }) => (
  <Button {...props}>Add Infrastructure & Onboard to Acme</Button>
   ^----- grit pointed here
);
morgante commented 4 weeks ago

Thanks for the report, I think this is an upstream error in the typescript grammars: https://github.com/tree-sitter/tree-sitter-typescript

Note Grit will still do a best effort attempt even on files that fail to fully parse.

alexgorbatchev commented 4 weeks ago

Thanks, I re-posted over at the grammar repo.