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

Errors while linting TypeScript #108

Open
mehmetnyarar opened this issue Aug 3, 2020 · 12 comments
Open

Errors while linting TypeScript #108

mehmetnyarar opened this issue Aug 3, 2020 · 12 comments

Comments

@mehmetnyarar
Copy link

I've installed prettier-standard to my monorepo project. When I run prettier-standard --lint on the root, I get the following errors:


   7 | export interface EnvVars {
   8 |   HOST_SSL?: string
>  9 |   HOST_DOMAIN?: string
     |   ^
  10 |   SERVER_PORT?: string
  11 |   WEB_CLIENTS?: string
  12 |   CORS_WHITELIST?: string
error  Parsing error: Unexpected token, expected "]"

  10 | export const getRequired = (config: RequiredConfig = {}) => {
  11 |   return Object.keys(config).reduce((required, key) => {
> 12 |     return config[key as keyof EnvVars] ? required.concat(key) : required
     |                       ^
  13 |   }, [] as string[])
  14 | }
error  'Record' is not defined  no-undef
error  Parsing error: Unexpected token, expected ";"

  15 |  * Console methods.
  16 |  */
> 17 | export type ConsoleMethod = keyof Omit<Console, 'Console'>
error  Parsing error: Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.

  3 | 
  4 | @Resolver()
> 5 | export class CommonResolver {

Am I missing something?

@sheerun
Copy link
Owner

sheerun commented Aug 3, 2020

I guess you forgot ;?

@jdtzmn
Copy link

jdtzmn commented Aug 6, 2020

I'm having this issue as well, with static modifiers and whatnot:

Screen Shot 2020-08-06 at 8 30 20 AM

@jdtzmn
Copy link

jdtzmn commented Aug 6, 2020

Is this package expected to work with TypeScript or not?

I assumed it was because it includes @typescript-eslint/parser, but then in the ignoring files section it has the example of ignoring **/*.ts, so now I'm not sure.

@sheerun
Copy link
Owner

sheerun commented Aug 6, 2020

it works in my case, what's your typescript and prettier-standard version in package.json? how do you run it?

@jdtzmn
Copy link

jdtzmn commented Aug 9, 2020

You are correct. I figured out that my issue was with eslint. static's can't be private.

@ahuggins-nhs
Copy link

I'm having the same issues as the OP. There's actually a couple of different scenarios:

Combinations of:

pretter-standard@16.4.1
typescript@4.0.2
@typescript-eslint/parser@4.0.1

or

pretter-standard@16.4.1
typescript@3.9.7
@typescript-eslint/parser@3.0.0

Results in eslint parsing errors.

Rolling back to 16.3.0 resolves my issue.

@RogWilco
Copy link

RogWilco commented Sep 4, 2020

Encountered the same problem today, and can also confirm rolling back to 16.3.0 seems to resolve it. In my case it seems to be choking on this:

export type ThrowableType = new () => Error

Which results in:

  5:33  error  Parsing error: Unexpected token, expected ";"

  3 |  * used when specifying which type of error will be caught.
  4 |  */
> 5 | export type ThrowableType = new () => Error
    |                                 ^
  6 | 
  7 | /**
  8 |  * A function containing the code to be executed as part of a try block

✖ 1 problem (1 error, 0 warnings)

This behavior can be observed in the public repo I'm working in here (running yarn lint will reproduce the issue).

tuomokar added a commit to tuomokar/stock-visualization that referenced this issue Sep 12, 2020
Note that the version is specifically 16.3.0 because in the latest version (16.4.1 when doing this commit)
TypeScript support seems broken. See sheerun/prettier-standard#108.
@ofbeaton
Copy link

ofbeaton commented Oct 12, 2020

Came here because of the same types of problems.

  15:3  error  Parsing error: Unexpected token
  13 | export interface testConnInfo {
  14 |   db?: Connection
> 15 |   redis?: Redis.Redis
     |   ^
  16 | }

or

  191:25  error  Parsing error: Unexpected token, expected ","

  189 |     })
  190 |
> 191 |     expect(response.data!.users!).toHaveLength(4)
      |                         ^
  192 |
  193 |     // TODO: verify the 4 users we want to see
  194 |   })

or

  47:27  error  Parsing error: Unexpected token, expected ";"

  45 |   beforeAll(async () => {
  46 |     connInfo = await testConnOpen()
> 47 |     redis = connInfo.redis!
     |                           ^
  48 |     userRepository = getRepository(User)
  49 |   })
  50 |

problems occur with 16.4.1, 16.4.0 (how come neither of these are tagged in github master repo?)

All of them go away when you revert to 16.3.0 the last repo tagged version.

@einSelbst
Copy link

einSelbst commented Jan 17, 2021

When setting parserOptions.project for typescript in the eslint config I also have the problem that prettier-standard seem to have issues picking up the config.

Error: Error while loading rule '@typescript-eslint/await-thenable': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /Users/einselbst/Workspace/einselbst/feehikel/src/pages/_app.tsx

Rolling back to 16.3.0 does also fix this issue.

@spaceoi
Copy link

spaceoi commented Feb 23, 2021

Came here because of the same types of problems.

  15:3  error  Parsing error: Unexpected token
  13 | export interface testConnInfo {
  14 |   db?: Connection
> 15 |   redis?: Redis.Redis
     |   ^
  16 | }

or

  191:25  error  Parsing error: Unexpected token, expected ","

  189 |     })
  190 |
> 191 |     expect(response.data!.users!).toHaveLength(4)
      |                         ^
  192 |
  193 |     // TODO: verify the 4 users we want to see
  194 |   })

or

  47:27  error  Parsing error: Unexpected token, expected ";"

  45 |   beforeAll(async () => {
  46 |     connInfo = await testConnOpen()
> 47 |     redis = connInfo.redis!
     |                           ^
  48 |     userRepository = getRepository(User)
  49 |   })
  50 |

problems occur with 16.4.1, 16.4.0 (how come neither of these are tagged in github master repo?)

All of them go away when you revert to 16.3.0 the last repo tagged version.

solved the optional chaining problem by replacing dependency "prettierx"(0.11 in package) to newest version(currently 0.17). You can try if it could solve other problems.

@HoraceShmorace
Copy link

This is pretty old and I'm running into the same problem. Rolling back to 16.3.0 definitely fixed the issue for me.

@einSelbst
Copy link

@HoraceShmorace this library doesn't seem to be maintained anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants