Skip to content

Commit

Permalink
Use prettier-plugin-sort-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Dec 18, 2023
1 parent 471f0dc commit 39edede
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 29 deletions.
33 changes: 33 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const config = {
/**
* Enable plugin for automatically sorting of imports
*/
plugins: ["@trivago/prettier-plugin-sort-imports"],
importOrderParserPlugins: ["typescript", "decorators-legacy"],

/**
* Custom sorting of imports, first lit stuff, then other third
* party libs, then own modules
*/
importOrder: [
"^lit$",
"^lit/.*$",
"^@lit/.*$",
"<THIRD_PARTY_MODULES>",
"^[./]",
],

/**
* Whether to separate sorting groups (as defined above) with
* newline
*/
// importOrderSeparation: true,

/**
* Whether to sort the specifiers on the left hand side of the
* import statement
*/
importOrderSortSpecifiers: true,
};

export default config;
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@storybook/blocks": "^7.6.5",
"@storybook/web-components": "^7.6.5",
"@storybook/web-components-vite": "^7.6.5",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -79,7 +80,6 @@
"plugin:prettier/recommended"
]
},
"prettier": {},
"lint-staged": {
"**/*.{ts,js}": [
"eslint --fix"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Backdrop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { theme } from "../utils/theme";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Banner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { classMap } from "lit/directives/class-map.js";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Container.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { theme } from "../utils/theme";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { theme } from "../utils/theme";

Expand Down
2 changes: 1 addition & 1 deletion src/components/FooterLink.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { theme } from "../utils/theme";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Hero.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { theme } from "../utils/theme";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css, TemplateResult } from "lit";
import { LitElement, TemplateResult, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { theme } from "../utils/theme";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { classMap } from "lit/directives/class-map.js";
Expand Down
2 changes: 1 addition & 1 deletion src/components/MenuAction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { theme } from "../utils/theme";
Expand Down
4 changes: 2 additions & 2 deletions src/components/MenuDropdown.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { classMap } from "lit/directives/class-map.js";
import { theme } from "../utils/theme";
import { isNodeOrChild } from "../utils/dom";
import { navigateMenuWithKeyboard } from "../utils/menu";
import { theme } from "../utils/theme";
import "./Icon";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/MenuDropdownItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { theme } from "../utils/theme";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Nav.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { theme } from "../utils/theme";

Expand Down
2 changes: 1 addition & 1 deletion src/components/NavItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { classMap } from "lit/directives/class-map.js";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Subnav.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { theme } from "../utils/theme";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Topbar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, html, css } from "lit";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators/custom-element.js";
import { property } from "lit/decorators/property.js";
import { theme } from "../utils/theme";
Expand Down
3 changes: 2 additions & 1 deletion src/puzzle-shell.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "./utils/theme";

export { Backdrop } from "./components/Backdrop";
export { Banner } from "./components/Banner";
export { Container } from "./components/Container";
Expand All @@ -14,4 +16,3 @@ export { Nav } from "./components/Nav";
export { NavItem } from "./components/NavItem";
export { Subnav } from "./components/Subnav";
export { Topbar } from "./components/Topbar";
import "./utils/theme";
4 changes: 2 additions & 2 deletions src/stories/components/Banner.stories.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { html } from "lit";
import "../../components/Banner";
import "../../components/Icon";
import "../../components/Topbar";
import "../../components/Menu";
import "../../components/Nav";
import "../../components/Subnav";
import "../../components/NavItem";
import "../../components/Subnav";
import "../../components/Topbar";
import { searchStyles } from "./search";

export default {
Expand Down
4 changes: 2 additions & 2 deletions src/stories/components/Topbar.stories.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { html } from "lit";
import "../../components/Topbar";
import "../../components/Icon";
import "../../components/Menu";
import "../../components/MenuAction";
import "../../components/MenuDropdown";
import "../../components/Icon";
import "../../components/Topbar";

export default {
title: "Puzzle Shell/Components/Topbar",
Expand Down
2 changes: 1 addition & 1 deletion src/stories/examples/ContentAppWithSearch.stories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html } from "lit";
import "../../puzzle-shell";
import { searchStyles } from "../components/search";
import { theme } from "../../utils/theme";
import { searchStyles } from "../components/search";

export default {
title: "Puzzle Shell/Examples/Content app with search",
Expand Down
2 changes: 1 addition & 1 deletion src/stories/examples/WelcomePage.stories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html } from "lit";
import "../../puzzle-shell";
import { searchStyles } from "../components/search";
import { theme } from "../../utils/theme";
import { searchStyles } from "../components/search";

export default {
title: "Puzzle Shell/Examples/Welcome page",
Expand Down
10 changes: 5 additions & 5 deletions src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { css, CSSResult } from "lit";
import { CSSResult, css } from "lit";

/**
* Roboto: Regular 400, Regular 400 italic, Medium 500, Medium 500 italic
* Roboto Mono: Regular 400, Medium 500
*/
import "@fontsource/roboto/400.css";
import "@fontsource/roboto/400-italic.css";
import "@fontsource/roboto/500.css";
import "@fontsource/roboto/500-italic.css";
import "@fontsource/roboto-mono/400.css";
import "@fontsource/roboto-mono/500.css";
import "@fontsource/roboto/400-italic.css";
import "@fontsource/roboto/400.css";
import "@fontsource/roboto/500-italic.css";
import "@fontsource/roboto/500.css";

const DEFAULT_BREAKPOINT = 800;
export function getBreakpoint(): number {
Expand Down

0 comments on commit 39edede

Please sign in to comment.