chore(linter): ignore file changes in packages directory - #9302
chore(linter): ignore file changes in packages directory#9302shivanee-p wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the linter configuration and script to ignore files inside top-level directories like packages/ and optimizes path segment checks by using Set lookups. Feedback on the changes highlights a bug where running the linter from a subdirectory causes incorrect path resolution; resolving file paths relative to the repository root instead of the current working directory is recommended to ensure correct behavior.
83cc487 to
29be9f8
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the linter script (bin/linter.mjs) and .eslintrc.json to support running from subdirectories by dynamically resolving the repository root path via Git. It also introduces a mechanism to ignore top-level directories like packages/ and optimizes ignored path checks using a Set. Feedback was provided to avoid hardcoding the path to the TypeScript compiler inside node_modules and instead resolve it dynamically using require.resolve for better robustness.
| await execFileAsync('node', [ | ||
| 'node_modules/typescript/bin/tsc', | ||
| path.join(getRepoRoot(), 'node_modules/typescript/bin/tsc'), |
There was a problem hiding this comment.
According to the general rules, we should avoid hardcoding relative paths to dependencies in node_modules (e.g., 'node_modules/typescript/bin/tsc'). Instead, resolve the path dynamically using require.resolve to ensure robustness across different environments and directory structures. Since this is an ES module, we can dynamically import createRequire from the module package to obtain a require function.
| await execFileAsync('node', [ | |
| 'node_modules/typescript/bin/tsc', | |
| path.join(getRepoRoot(), 'node_modules/typescript/bin/tsc'), | |
| const require = (await import('module')).createRequire(import.meta.url); | |
| await execFileAsync('node', [ | |
| require.resolve('typescript/bin/tsc'), |
References
- Avoid hardcoding relative paths to dependencies in node_modules. Instead, resolve the path dynamically using require.resolve and path.join to ensure robustness across different environments and directory structures.
Updates the monorepo linter to ignore changes in the top-level
packages/directory containing generated client librariesFixes b/560350445 🦕