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

Improve the way to find tsconfig.json #2977

Closed
shiyangzhaoa opened this issue Mar 7, 2024 · 2 comments
Closed

Improve the way to find tsconfig.json #2977

shiyangzhaoa opened this issue Mar 7, 2024 · 2 comments

Comments

@shiyangzhaoa
Copy link

I have a monorepo project, and its structure looks like this:

monorepo
├── packages
│  ├── packageA
│  └── packageB
└── index.mjs

I want to run the eslint command in the root directory, like:

const eslint = new ESLint({
    cwd: '/workspace/monorepo/packages/packageA',
    extensions: ['.ts', '.tsx', '.mts', '.cts'],
});

const result = await eslint.lintFiles('/workspace/monorepo/packages/packageA/index.ts');

console.log('result---', result);

The eslint-plugin-import plugin seems to be unable to find the tsconfig.json file of packageA:
image

I think eslint’s cwd configuration should be used first, it looks like this:

const tsconfigInfo = tsConfigLoader({
    cwd: context.parserOptions && context.parserOptions.tsconfigRootDir || eslint.options.cwd || process.cwd(),
    getEnv: (key) => process.env[key],
});

PS

At first I thought the context was the context configured by eslint, but later I found out that it was the plugin itself.
image

So I tried writing it like this and found that nothing worked 😅:

new ESLint({
    cwd: '/workspace/monorepo/packages/packageA',
    extensions: ['.ts', '.tsx', '.mts', '.cts'],
    overrideConfig: {
        parserOptions: {
            tsconfigRootDir: '/workspace/monorepo/packages/packageA'
         },
    },
})
@JounQin
Copy link
Collaborator

JounQin commented Mar 7, 2024

Please stop doing this.

@JounQin
Copy link
Collaborator

JounQin commented Mar 7, 2024

@JounQin JounQin marked this as a duplicate of #274 Mar 7, 2024
@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
@JounQin JounQin marked this as not a duplicate of #274 Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants