top of page

Random Tech Solutions

Öffentlich·1 Mitglied

### Post: Solving the "Parsing Error" in a Monorepo Turbo Repo with ESLint


If you're working in a **Turborepo** setup and encounter the following ESLint error:


```

Parsing error: Cannot read file '/my-turborepo/tsconfig.json'.eslint

import { Section1 } from "../../components/section1";

```


This error usually happens due to ESLint not properly finding or loading your `tsconfig.json`. Here are two possible solutions to fix the issue, depending on whether you want to resolve it locally within your repo or globally for a Next.js project.


---


### **Solution 1: Local Fix for the Monorepo**


If you're working on a monorepo, the easiest fix is to adjust your `.eslintrc.js` file to extend the appropriate ESLint configurations. Just add the following line to the `.eslintrc.js` in your project root:


```js

module.exports = {

extends: ["@repo/eslint-config/react.js", "next/core-web-vitals"],

};

```


This will ensure that the ESLint configuration applies both your custom monorepo configuration and the `next/core-web-vitals` rules to ensure best practices for Next.js.


---


### **Solution 2: Global Fix for Next.js**


If you want to apply a more **global** ESLint configuration for Next.js across the entire repo or multiple repos, you can use Vercel’s style guide as a base. Add the following configuration to `.eslintrc.js`:


```js

module.exports = {

extends: [

...[

"@vercel/style-guide/eslint/node",

"@vercel/style-guide/eslint/typescript",

"@vercel/style-guide/eslint/browser",

"@vercel/style-guide/eslint/react",

"@vercel/style-guide/eslint/next",

].map(require.resolve),

"turbo",

"next/core-web-vitals"

],

};

```


### Explanation:

- This configuration applies Vercel’s style guide, ensuring consistent coding standards across your Node, TypeScript, React, and Next.js codebases.

- `"next/core-web-vitals"` enforces rules specific to Next.js performance optimizations.


---


By applying one of these solutions, you should be able to resolve the parsing error and continue using ESLint effectively in your **Turborepo**.


#### Additional Tip:

- **Ensure that your `tsconfig.json` paths are correctly configured** to prevent any missing or incorrect file errors.

About

Welcome to the group! You can connect with other members, ge...

bottom of page