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

Parsing error: ESLint was configured to run on <tsconfigRootDir>/vite.config.ts using parserOptions.project: #13739

Closed
7 tasks done
vaynevayne opened this issue Jul 7, 2023 · 16 comments · Fixed by #13749
Closed
7 tasks done

Comments

@vaynevayne
Copy link

Describe the bug

pnpm create vite
react typescript-swc

Reproduction

https://stackblitz.com/edit/vitejs-vite-psmxmw?file=tsconfig.node.json

Steps to reproduce

No response

System Info

OS: macOS 12.5.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 101.81 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
    pnpm: 8.5.1 - /opt/homebrew/bin/pnpm
    Watchman: 2023.02.27.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 15.6.1
  npmPackages:
    @vitejs/plugin-react-swc: ^3.3.2 => 3.3.2 
    vite: ^4.4.0 => 4.4.0

Used Package Manager

pnpm

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented Jul 7, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red
Copy link
Member

No error happens when running npm run lint. Please describe what you think is the bug.

@github-actions
Copy link

github-actions bot commented Jul 7, 2023

Hello @vaynevayne. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@AlexMNet
Copy link

@vaynevayne I am having the same issue trying to start a new vite react typescript project.

@Hongbusi
Copy link

I also encountered the same problem and created a new react + ts project through vite.

@berkerdemirer
Copy link

Having the same issue

@Javier1177
Copy link

Having the same issue with npm

@prajwalsharma
Copy link

Having the same issue with npm
image

@AlexMNet
Copy link

This helped me for the time being

#13747 (comment)

@jaffyyyy
Copy link

jaffyyyy commented Jul 12, 2023

having the same issue inside src folder, another fix is to add src in ignorePatterns: ignorePatterns: [".eslintrc.cjs", "vite.config.ts", "src"], in .eslintrc.cjs.

@Warchino
Copy link

Same issue but using yarn.

@ikangjie
Copy link

Having the same issue

@basitcodeenv
Copy link

basitcodeenv commented Jul 16, 2023

2023-07-16_13-09

Same Issue

@puxiao
Copy link

puxiao commented Jul 19, 2023

Problem solved
./.eslintrc.cjs :change parserOptions.project to ['./tsconfig.json', './tsconfig.node.json']

#13747 (comment)


I have discovered a new solution !

./.eslintrc.cjs :change parserOptions.project to ['./tsconfig.json', './tsconfig.node.json']


tsconfig.node.json

- "include": ["vite.config.ts"]
+ "include": ["vite.config.ts", ".eslintrc.cjs"]

By the way, another thing: If you use node.js in vite

xxx.js, not xxx.cjs

__dirname is not defined in es module scope

You need to modify it to the following code :

import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

@Brendler17
Copy link

Captura de tela de 2023-07-21 18-13-51

same :(

@liudayang
Copy link

having the same issue inside src folder, another fix is to add src in ignorePatterns: ignorePatterns: [".eslintrc.cjs", "vite.config.ts", "src"], in .eslintrc.cjs.

you'd better delete src

@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.