import-js/eslint-plugin-import

[feature] make `context.getCwd()` available in resolver

JounQin opened this issue · 7 comments

context: import-js/eslint-import-resolver-typescript#74 (comment)

process.cwd() could be incorrect, context.getCwd() is the replacement.

When available, that seems like something we could provide, altho I'm not clear on when the value would be different than process.cwd() - since all commands in any repo should always only be run in the project root.

It's about IDE/editor integration actually, it can be opened in parent/child folder, did you read through my linked issue? 🤣

I looked, but it’s long.

an IDE should also always be opened from the root of the repo.

Either way, it’d be fine to provide the proper value when available.

I feel like these issues could easily be solved by adding a tsconfigRootDir setting like @typescript-eslint does. Or just by using the tsconfigs that @typescript-eslint specifies. Currently, we have to specify tsconfig locations twice 🙃

I feel like these issues could easily be solved by adding a tsconfigRootDir setting like @typescript-eslint does. Or just by using the tsconfigs that @typescript-eslint specifies. Currently, we have to specify tsconfig locations twice 🙃

I proposed to adding new arguments into current resolver API without any breaking change at #2447 (comment)

@ljharb How do you think?

declare function resolve(
  source: string,
  file: string,
  config: object,
  options?: {
    parser: string;
    parserOption: object;
    context: object;
  }
): { found: Boolean; path: String? };

As long as that actually has no breaking change, that sounds great.

As long as that actually has no breaking change, that sounds great.

OK, I'll raise a PR for it.