suppress-eslint-errors icon indicating copy to clipboard operation
suppress-eslint-errors copied to clipboard

Transform error with js file using flow type annotations

Open jjblumenfeld opened this issue 3 years ago • 1 comments

When trying to run suppress-eslint-errors over a file with flow type annotations I am getting an error:

 Transformation error (Unexpected token (30:12))
SyntaxError: Unexpected token (30:12)
  at Object.raise (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:6400:17)
  at Object.unexpected (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:7728:16)
  at Object.expectContextual (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:7694:41)
  at Object.parseImport (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:11271:12)
  at Object.parseStatementContent (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:10030:27)
  at Object.parseStatement (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:9932:17)
{
  at Object.parseBlockOrModuleBlockBody (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:10508:25)
  at Object.parseBlockBody (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:10495:10)
  at Object.parseBlockBody (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:428:11)
  at Object.parseTopLevel (/work/git/TCJ/frontend/express-react/node_modules/@babel/parser/lib/index.js:9861:10)

In this case line 30 on the referenced file looks like: import type { Route } from 'website/route.flow';

So it seems like it is throwing the error on the type import. How can I get the parser to understand the flow type syntax?

jjblumenfeld avatar Oct 08 '21 14:10 jjblumenfeld

@jjblumenfeld I suspect that, as in #29, you need to explicitly specify a parser.

I'd happily accept a PR to improve the documentation if this is the case.

amanda-mitchell avatar Feb 19 '22 22:02 amanda-mitchell