-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: jsx-newline
sometimes breaks with comments
#3573
Comments
This cannot be reproduced with the default parser, can you show what parser you are using? For example running |
I'm having the same issue. Package versions and my eslint config file is below. Thanks! Packages"dependencies": { "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.18", "@mui/material": "^5.14.18", "axios": "^1.6.2", "fuse.js": "^7.0.0", "immer": "^10.0.3", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.19.0", "zustand": "^4.4.6" }, "devDependencies": { "@types/node": "^20.9.2", "@types/react": "^18.2.37", "@types/react-dom": "^18.2.15", "@typescript-eslint/eslint-plugin": "^6.11.0", "@typescript-eslint/parser": "^6.11.0", "@vitejs/plugin-react-swc": "^3.5.0", "dotenv": "^16.3.1", "eslint": "^8.54.0", "eslint-plugin-import": "^2.29.0", "eslint-plugin-json": "^3.1.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.4", "typescript": "^5.2.2", "vite": "^5.0.0" } ESLint Configmodule.exports = { root: true, env: { browser: true, es2020: true }, settings: { react: { version: "detect" } }, extends: [ "eslint:recommended", "plugin:import/typescript", "plugin:react/recommended", "plugin:react-hooks/recommended", "plugin:@typescript-eslint/recommended", "plugin:json/recommended" ], parserOptions: { project: ["./tsconfig.json"] }, parser: "@typescript-eslint/parser", ignorePatterns: ["node_modules", "dist", "build", "dist", "package.json", "tsconfig.json", "tsconfig.node.json", ".eslintrc.cjs", "vite.config.ts", "**/components_old/**/*.tsx", "**/oldStores/**/*.tsx"], plugins: ["import", "react", "react-hooks", "react-refresh", "@typescript-eslint", "json"], rules: { "json/*": ["error", "allowComments"], |
Same issue here. It seems the problem is that
is called with I see that this simple change
seems to fix the bug. Not sure if the output is correct/as expected, but at least the execution does not crash |
Is there an existing issue for this?
Description Overview
In the following minimal example, the
react/jsx-newline
rule fails to parse the file:The following error is printed on running
eslint
:Moving the comment up a row or removing the sibling fixes the problem.
Expected Behavior
The rule should be able to correctly parse the file.
eslint-plugin-react version
v7.32.2
eslint version
v8.40.0
node version
v19.9.0
The text was updated successfully, but these errors were encountered: