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

Default ESLint setup ignores JSX files if you run npx eslint . #290

Open
7 tasks done
phoenixeliot opened this issue Feb 23, 2024 · 2 comments
Open
7 tasks done

Default ESLint setup ignores JSX files if you run npx eslint . #290

phoenixeliot opened this issue Feb 23, 2024 · 2 comments

Comments

@phoenixeliot
Copy link

phoenixeliot commented Feb 23, 2024

Describe the bug

If you set up a new Vite project using npm create vite@latest, the skeleton it generates will only lint JSX files if you run npm run lint, but will silently ignore JSX files if you run npx eslint ..

Since npx eslint . is a common way to run eslint, I think Vite's default setup should support that way of running it, instead of simply ignoring JSX files and giving the false impression it checked those.

(The supported way to run eslint is the npm run lint script Vite adds, but it's easy to not notice that should be used, and it's bad that not realizing that exists results in potentially a bunch of false negatives)

Reproduction

https://github.com/phoenixeliot/vite-eslint-jsx-demo

Steps to reproduce

  1. Run npm create vite@latest. Select "React" and "Javascript" in the prompts.
  2. Add this line to App.jsx, which violates an eslint:recommended rule: for (var i = 0; i < 10; i--) { }
  3. Run npx eslint . in the terminal

Result: No errors are shown.

  1. Run npm run lint

Result: This time, a lint error is shown.

However, if we add this to .eslintrc.cjs, npx eslint . works:

  overrides: [
    {
      // This is required for `npx eslint .` to lint jsx files
      files: ["*.js", "*.jsx"],
    },
  ],

System Info

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 89.38 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.volta/tools/image/node/18.16.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
    pnpm: 7.18.2 - ~/Library/pnpm/pnpm
  Browsers:
    Brave Browser: 121.1.62.162
    Chrome: 121.0.6167.184
    Edge: 117.0.2045.31
    Safari: 17.2.1

Used Package Manager

npm

Logs

No response

Validations

@ArnaudBarre
Copy link
Member

@phoenixeliot
Copy link
Author

Ah, nice. Looking forward to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants