[all-commits] [llvm/llvm-project] f6740f: [clang-format] Indent import statements in JavaScr...

eywdck2l via All-commits all-commits at lists.llvm.org
Wed Mar 30 16:20:08 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f6740fe483e9fa0c76aa9f176ff68f51f47a1302
      https://github.com/llvm/llvm-project/commit/f6740fe483e9fa0c76aa9f176ff68f51f47a1302
  Author: sstwcw <f0gukp2nk at protonmail.com>
  Date:   2022-03-30 (Wed, 30 Mar 2022)

  Changed paths:
    M clang/lib/Format/UnwrappedLineFormatter.cpp
    M clang/unittests/Format/FormatTestJS.cpp

  Log Message:
  -----------
  [clang-format] Indent import statements in JavaScript.

[clang-format] Indent import statements in JavaScript.

Take for example this piece of code found at
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import>.

```
for (const link of document.querySelectorAll("nav > a")) {
  link.addEventListener("click", e => {
    e.preventDefault();

    import('/modules/my-module.js')
        .then(module => {
          module.loadPageInto(main);
        })
        .catch(err => {
          main.textContent = err.message;
        });
  });
}
```

Previously the import line would be unindented, looking like this.

```
for (const link of document.querySelectorAll("nav > a")) {
  link.addEventListener("click", e => {
    e.preventDefault();

import('/modules/my-module.js')
        .then(module => {
          module.loadPageInto(main);
        })
        .catch(err => {
          main.textContent = err.message;
        });
  });
}
```

Actually we were going to fix this along with fixing Verilog import
statements.  But the patch got too big.

Reviewed By: MyDeveloperDay, curdeius

Differential Revision: https://reviews.llvm.org/D121906




More information about the All-commits mailing list