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

jsx + eslint --fix not properly spacing text #2484

Closed
RyanPWalker opened this issue Nov 1, 2019 · 1 comment · Fixed by #2542
Closed

jsx + eslint --fix not properly spacing text #2484

RyanPWalker opened this issue Nov 1, 2019 · 1 comment · Fixed by #2542

Comments

@RyanPWalker
Copy link

My application is a node app that server side renders React components to strings. Whenever I run eslint --fix, it fixes spacing correctly except for plain text in jsx. For example, after running eslint --fix here is what some of my jsx looks like:

    myAccount: {
        option1: <>
Shop Smarter,
            <br />
Earn Rewards
        </>,
        option2: 'No Interest Financing',
        option3: 'No Credit Needed',
        option4: 'Shop Smart',
        option5: <>
You’re still
            <br />
pre-approved!
        </>
    },

html entities are spaced just fine while text always has no indentation. This happens almost everywhere in my repo and even my other repos. Please help.

Node version: 10.16.3 or 12.13.0
yarn version: 1.17.3 or 1.19.1
package.json:

    "@babel/cli": "^7.6.4",
    "@babel/core": "^7.6.4",
    "@babel/plugin-transform-react-jsx": "^7.3.0",
    "@babel/preset-env": "^7.6.3",
    "babel-eslint": "^10.0.2",
    "babel-preset-minify": "^0.5.1",

    "eslint": "^6.6.0",
    "eslint-plugin-react": "^7.15.1",

    "react": "^16.11.0",
    "react-dom": "^16.11.0",

Additional eslint config:


    "env": {
        "es6": true,
        "jest": true,
        "node": true
    },
    "extends": "airbnb",
    "parser": "babel-eslint",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 6,
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "react-hooks",
        "jsx-a11y",
        "import"
    ],
    "rules": {
        "max-len": ["error", 120, 4, {
            ignoreUrls: true,
            ignoreComments: false,
            ignoreRegExpLiterals: true,
            ignoreStrings: true,
            ignoreTemplateLiterals: true,
        }],
        "comma-dangle": 0,
        "no-underscore-dangle": 0,
        "import/prefer-default-export": 0,
        "indent": ["error", 4, {
            "SwitchCase": 1
        }],
        "react-hooks/rules-of-hooks": "error",
        "react-hooks/exhaustive-deps": "warn",
        "react/jsx-filename-extension": 0,
        "react/jsx-indent": ["error", 4],
        "react/jsx-indent-props": ["error", 4],
        "jsx-a11y/no-static-element-interactions": 0,

        "array-callback-return": 0,
        "consistent-return": 0,
        "import/no-extraneous-dependencies": 0,
        "max-len": 0,
        "no-console": 0,
        "no-plusplus": 0,
        "react/jsx-closing-tag-location": 0,
        "react/jsx-curly-brace-presence": 0,
        "react/jsx-uses-react": 2,
        "react/jsx-uses-vars": 2,
        "react/prop-types": 0,
        "react/no-danger": 0
    }
@ljharb
Copy link
Member

ljharb commented Nov 2, 2019

This is definitely something that jsx-indent needs to cover. I believe there's a number of open issues that cover it: #2467 #1136

ljharb pushed a commit to toshi-toma/eslint-plugin-react that referenced this issue Jan 16, 2020
ljharb pushed a commit to toshi-toma/eslint-plugin-react that referenced this issue Jan 28, 2020
ljharb pushed a commit to toshi-toma/eslint-plugin-react that referenced this issue Feb 1, 2020
@ljharb ljharb closed this as completed in ffdf69a Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants