1

I have problem with formatting html file by prettier end eslint. Prettier formatting by html code by adding /> to single tag, but I don't want using slash character for end my tag. And second problem is adding indent for "head" and "body" tag in "html" tag, I want Use indent only in "body" and "head" tag.

Second problem is conflict with prettier and eslint in my JS code. ESlint return problem because I seting indent for 4 spaces, but prettier want using only two spaces intent.

Prettier return code like this

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>Document</title>
    </head>
    <body></body>
</html>

But I want have something like this

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

</body>
</html>

My pacpage.json prettier and eslint dependencies

    "eslint": "^6.1.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-config-prettier": "^6.2.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-react": "^7.14.3",
    "eslint-plugin-react-hooks": "^1.7.0",
    "prettier": "^1.18.2",

.eslintrc.json

{
    "extends": ["airbnb", "prettier"],
    "plugins": ["prettier"],
    "rules": {
        "prettier/prettier": ["error"],
        "indent": [
            "error",
            4,
            { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }
        ]
    }
}

.prettierrc

{
    "singleQuote": true,
}

Thanks for your help.

Paul
  • 11
  • 3
  • Why do you care? It's not going to break anything? There's plenty of conversation about this topic here https://stackoverflow.com/questions/3558119/are-non-void-self-closing-tags-valid-in-html5 – Jon B Sep 05 '19 at 23:13
  • I just don't want change style in my code, which I use as far as I remember. I know, that code is valid. – Paul Sep 05 '19 at 23:32

0 Answers0