Skip to content

Commit 7b02ed3

Browse files
authored
chore: Import sort plugin (#37)
* chore: Import sort plugin * chore: Replace import sorting pattern for external packages to include everything started optionally with @, but @Cloudscape * chore: Raise eslint sorting rule to error * chore: Small eslint rule adjustment
1 parent 65c7642 commit 7b02ed3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+209
-23
lines changed

.eslintrc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"jsx": true
1616
}
1717
},
18-
"plugins": ["unicorn", "react-hooks", "no-unsanitized", "header", "import"],
18+
"plugins": ["unicorn", "react-hooks", "no-unsanitized", "header", "import", "simple-import-sort"],
1919
"rules": {
2020
"@typescript-eslint/no-unused-vars": "error",
2121
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
@@ -69,14 +69,13 @@
6969
]
7070
}
7171
],
72-
"sort-imports": ["error", { "ignoreDeclarationSort": true }],
73-
"import/order": ["error", { "alphabetize": { "order": "asc" } }],
7472
"import/no-useless-path-segments": [
7573
"warn",
7674
{
7775
"noUselessIndex": true
7876
}
79-
]
77+
],
78+
"simple-import-sort/imports": "error"
8079
},
8180
"settings": {
8281
"react": {
@@ -98,6 +97,30 @@
9897
"env": {
9998
"jest": true
10099
}
100+
},
101+
{
102+
"files": ["src/**", "pages/**", "test/**", "scripts/**"],
103+
"rules": {
104+
"simple-import-sort/imports": [
105+
"error",
106+
{
107+
"groups": [
108+
// External packages come first.
109+
["^react", "^(?!@cloudscape)@?\\w"],
110+
// Cloudscape packages.
111+
["^@cloudscape"],
112+
// Things that start with a letter (or digit or underscore), or `~` followed by a letter.
113+
["^~\\w"],
114+
// Anything not matched in another group.
115+
["^"],
116+
// Styles come last.
117+
[
118+
"^.+\\.?(css)$","^.+\\.?(css.js)$", "^.+\\.?(scss)$", "^.+\\.?(selectors.js)$"
119+
]
120+
]
121+
}
122+
]
123+
}
101124
}
102125
]
103126
}

package-lock.json

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"eslint-plugin-react": "^7.31.11",
101101
"eslint-plugin-react-hooks": "^4.6.0",
102102
"eslint-plugin-unicorn": "^45.0.2",
103+
"eslint-plugin-simple-import-sort": "^12.1.1",
103104
"execa": "^6.1.0",
104105
"globby": "^13.1.3",
105106
"husky": "^8.0.3",

pages/app/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import { HashRouter, Link, Route, Routes, useLocation } from "react-router-dom";
4+
45
import { pages } from "../pages";
56
import Page from "./page";
67

pages/app/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import { SpaceBetween, Toggle } from "@cloudscape-design/components";
4-
import { Density, Mode, applyDensity, applyMode } from "@cloudscape-design/global-styles";
53
import { Suspense } from "react";
64
import { useEffect, useState } from "react";
5+
6+
import { SpaceBetween, Toggle } from "@cloudscape-design/components";
7+
import { applyDensity, applyMode, Density, Mode } from "@cloudscape-design/global-styles";
8+
79
import { pagesMap } from "../pages";
810
import PageLayout from "./page-layout";
911

pages/code-view/with-actions-button.page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { Button, SpaceBetween } from "@cloudscape-design/components";
5+
56
import { CodeView } from "../../lib/components";
67
import { ScreenshotArea } from "../screenshot-area";
78
export default function CodeViewPage() {

pages/code-view/with-all-features.page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { Button } from "@cloudscape-design/components";
5+
56
import { CodeView } from "../../lib/components";
67
import javascriptHighlight from "../../lib/components/code-view/highlight/javascript";
78
import { ScreenshotArea } from "../screenshot-area";

pages/code-view/with-line-numbers.page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { SpaceBetween } from "@cloudscape-design/components";
5-
import { CodeView } from "../../lib/components";
65

6+
import { CodeView } from "../../lib/components";
77
import { ScreenshotArea } from "../screenshot-area";
88
export default function CodeViewPage() {
99
return (

pages/code-view/with-syntax-highlighting.page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { SpaceBetween } from "@cloudscape-design/components";
5+
56
import { CodeView } from "../../lib/components";
6-
import cssHighlight from "../../lib/components/code-view/highlight/css";
77
import htmlHighlight from "../../lib/components/code-view/highlight/html";
88
import javaHighlight from "../../lib/components/code-view/highlight/java";
99
import javascriptHighlight from "../../lib/components/code-view/highlight/javascript";
@@ -15,8 +15,9 @@ import shHighlight from "../../lib/components/code-view/highlight/sh";
1515
import typescriptHighlight from "../../lib/components/code-view/highlight/typescript";
1616
import xmlHighlight from "../../lib/components/code-view/highlight/xml";
1717
import yamlHighlight from "../../lib/components/code-view/highlight/yaml";
18-
1918
import { ScreenshotArea } from "../screenshot-area";
19+
20+
import cssHighlight from "../../lib/components/code-view/highlight/css";
2021
export default function CodeViewPage() {
2122
return (
2223
<ScreenshotArea>

pages/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { StrictMode } from "react";
44
import ReactDOM from "react-dom/client";
5-
import "@cloudscape-design/global-styles/index.css";
65

76
import App from "./app";
87

8+
import "@cloudscape-design/global-styles/index.css";
9+
910
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
1011
<StrictMode>
1112
<App />

0 commit comments

Comments
 (0)