Closed simonlary closed 2 months ago
Start a new pull request in StackBlitz Codeflow.
No idea if that's the right way to fix the problem, but moving the ignore
field up seems to work? 🤷
export default tseslint.config(
{
ignores: ['dist'],
},
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
)
Putting ignores
in it's own object is a way to tell ESLint to apply it to all configs by default, and I agree the template could probably set that as a default instead. Feel free to send a PR to fix this for the react and react-ts templates!
Describe the bug
The ESLint configuration in the React Typescript template has a
ignores: ['dist']
line in it, but ESLint still scans and lints files in thedist
directory.The problem is not immediately visible since the only included files are
.ts
and.tsx
files and you usually don't have those types of files in yourdist
output, but if you add.js
/.jsx
files to the files to the ESLint configuration the linting fails when after you have built the app.This is also a pretty big issue for projects with big dependencies since even without adding
.js
/.jsx
files to the configuration, ESLint still scans those files in some way which slows down the linting process a ton and can even make Node.js run out of memory.Reproduction
https://stackblitz.com/edit/vitejs-vite-lcggzf
Steps to reproduce
npm run lint
works at first.npm run build
npm run lint
fails with 1224 errors in thedist/index-f40OySzR.js
file.System Info
Used Package Manager
npm
Logs
No response
Validations