-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
create-vite
with react-ts
template: linting is broken after following type-aware linting instructions in template's README.md
#17647
Comments
README.md
README.md
create-vite
with react-ts
template: linting is broken after following type-aware linting instructions in template's README.md
@mfisher87 I don't use type-aware linting as described in the readme, but rely on typescript checking done by VSCode's intellisense. This is my module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
} |
I don't use VSCode. The parser options recommended in the README include two additional values, parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
}, Instead of removing those two items like you have, I worked around this issue by modifying this line in "include": ["vite.config.ts", "src"] I'd like to propose a fix to the template, but I'm honestly not sure if I've fixed this in the "correct" way :) I write TypeScript maybe 1 month out of the year 😬 |
Perhaps #17645 fixes it |
This does in fact fix linting when I apply it to my "sscce" repository (if you want to test yourself, you can use the |
Describe the bug
I'm trying to lint after following the "type-aware linting" instructions in the README of the react-ts template. But I'm getting errors:
Reproduction
https://github.com/mfisher87/sscce-vite-react-ts-template-typeaware-linting-broken
Steps to reproduce
First, I create a new project with
react-ts
template:npm create vite@latest . -- --template react-ts npm install npm run lint
This works fine.
Follow the instructions in the README:
At this point,
.eslintrc.cjs
looks like:Then run
npm run lint
again to reproduce the error. 1 error of 3 similar errors shown (see bottom for full error):System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: