Skip to content

web-mode support doesn't work well for heterogeneous indent types #66

@thomasjm

Description

@thomasjm

I have a codebase that uses different values for different web-mode indentation variables within .tsx files. For example:

(setq web-mode-code-indent-offset 2)
(setq web-mode-markup-indent-offset 4)

Here's some code written this way:

import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";
import { useCallback } from "react";

export default function FooBarMenu() {
  const fooCallback = useCallback(() => {
    console.log("foo");
  }, []);

  return (
    <Menu label="Foo"
          disabled={false}>
        <MenuItem className=""
                  onClick={fooCallback}>
            Foo
        </MenuItem>
    </Menu>
  );
}

When I run dtrt-indent-diagnosis, it says "Guessed offset 2 with 100% confidence" and sets all my variables to 2. No doubt because it expects them all to be the same; see here.

Unfortunately this is probably hard to fix because it requires a more detailed understanding of JSX/TSX files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions