Skip to content

Commit 0fe109d

Browse files
authored
chore: sort imports in our typescript code (#12417)
1 parent 17c486c commit 0fe109d

File tree

626 files changed

+2362
-2331
lines changed

Some content is hidden

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

626 files changed

+2362
-2331
lines changed

Makefile

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,32 +382,44 @@ install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT)
382382
cp "$<" "$$output_file"
383383
.PHONY: install
384384

385-
fmt: fmt/prettier fmt/terraform fmt/shfmt fmt/go
385+
BOLD := $(shell tput bold)
386+
GREEN := $(shell tput setaf 2)
387+
RESET := $(shell tput sgr0)
388+
389+
fmt: fmt/eslint fmt/prettier fmt/terraform fmt/shfmt fmt/go
386390
.PHONY: fmt
387391

388392
fmt/go:
393+
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/go$(RESET)"
389394
# VS Code users should check out
390395
# https://github.com/mvdan/gofumpt#visual-studio-code
391396
go run mvdan.cc/gofumpt@v0.4.0 -w -l .
392397
.PHONY: fmt/go
393398

399+
fmt/eslint:
400+
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/eslint$(RESET)"
401+
cd site
402+
pnpm run lint:fix
403+
.PHONY: fmt/eslint
404+
394405
fmt/prettier:
395-
echo "--- prettier"
406+
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/prettier$(RESET)"
396407
cd site
397408
# Avoid writing files in CI to reduce file write activity
398409
ifdef CI
399410
pnpm run format:check
400411
else
401-
pnpm run format:write
412+
pnpm run format
402413
endif
403414
.PHONY: fmt/prettier
404415

405416
fmt/terraform: $(wildcard *.tf)
417+
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/terraform$(RESET)"
406418
terraform fmt -recursive
407419
.PHONY: fmt/terraform
408420

409421
fmt/shfmt: $(SHELL_SRC_FILES)
410-
echo "--- shfmt"
422+
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET)"
411423
# Only do diff check in CI, errors on diff.
412424
ifdef CI
413425
shfmt -d $(SHELL_SRC_FILES)
@@ -574,7 +586,7 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
574586

575587
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
576588
go run ./scripts/apitypings/ > $@
577-
pnpm run format:write:only "$@"
589+
pnpm exec prettier --write "$@"
578590

579591
site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
580592
cd site
@@ -583,7 +595,7 @@ site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisio
583595

584596
site/src/theme/icons.json: $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*)
585597
go run ./scripts/gensite/ -icons "$@"
586-
pnpm run format:write:only "$@"
598+
pnpm exec prettier --write "$@"
587599

588600
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
589601
go run ./scripts/examplegen/main.go > examples/examples.gen.json
@@ -593,19 +605,19 @@ coderd/rbac/object_gen.go: scripts/rbacgen/main.go coderd/rbac/object.go
593605

594606
docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
595607
go run scripts/metricsdocgen/main.go
596-
pnpm run format:write:only ./docs/admin/prometheus.md
608+
pnpm exec prettier --write ./docs/admin/prometheus.md
597609

598610
docs/cli.md: scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES)
599611
CI=true BASE_PATH="." go run ./scripts/clidocgen
600-
pnpm run format:write:only ./docs/cli.md ./docs/cli/*.md ./docs/manifest.json
612+
pnpm exec prettier --write ./docs/cli.md ./docs/cli/*.md ./docs/manifest.json
601613

602614
docs/admin/audit-logs.md: coderd/database/querier.go scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go
603615
go run scripts/auditdocgen/main.go
604-
pnpm run format:write:only ./docs/admin/audit-logs.md
616+
pnpm exec prettier --write ./docs/admin/audit-logs.md
605617

606618
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go
607619
./scripts/apidocgen/generate.sh
608-
pnpm run format:write:only ./docs/api ./docs/manifest.json ./coderd/apidoc/swagger.json
620+
pnpm exec prettier --write ./docs/api ./docs/manifest.json ./coderd/apidoc/swagger.json
609621

610622
update-golden-files: \
611623
cli/testdata/.gen-golden \

offlinedocs/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
"private": true,
55
"scripts": {
66
"dev": "pnpm copy-images && next dev",
7-
"build": "pnpm exec next build",
8-
"start": "pnpm exec next start",
7+
"build": "next build",
8+
"start": "next start",
99
"export": "pnpm copy-images && next build",
1010
"copy-images": "sh ./scripts/copyImages.sh",
1111
"lint": "pnpm run lint:types",
12-
"lint:fix": "FIX=true pnpm lint",
13-
"lint:types": "pnpm exec tsc --noEmit",
14-
"format:check": "pnpm exec prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
15-
"format:write": "pnpm exec prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
12+
"lint:types": "tsc --noEmit",
13+
"format": "prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
14+
"format:check": "prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
1615
},
1716
"dependencies": {
1817
"@chakra-ui/react": "2.8.0",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"name": "coder",
44
"version": "0.0.0",
55
"scripts": {
6-
"format:write:only": "prettier --cache --write"
6+
"format": "prettier --cache --write",
7+
"storybook": "pnpm run -C site/ storybook"
78
},
89
"devDependencies": {
910
"prettier": "3.0.0"

site/.eslintrc.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ overrides:
5252
testing-library/prefer-screen-queries: "off"
5353
root: true
5454
rules:
55-
"@typescript-eslint/brace-style":
56-
["error", "1tbs", { "allowSingleLine": false }]
57-
"@typescript-eslint/method-signature-style": ["error", "property"]
5855
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
5956
"@typescript-eslint/no-misused-promises": "off"
6057
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
@@ -75,6 +72,14 @@ rules:
7572
"@typescript-eslint/restrict-template-expressions": "off"
7673
# TODO: Investigate whether to enable this rule & fix and/or disable all its complaints
7774
"@typescript-eslint/unbound-method": "off"
75+
76+
"@typescript-eslint/brace-style":
77+
["error", "1tbs", { "allowSingleLine": false }]
78+
"@typescript-eslint/consistent-type-imports":
79+
- error
80+
- fixStyle: inline-type-imports
81+
"@typescript-eslint/method-signature-style": ["error", "property"]
82+
"@typescript-eslint/no-import-type-side-effects": "error"
7883
# We're disabling the `no-namespace` rule to use a pattern of defining an interface,
7984
# and then defining functions that operate on that data via namespace. This is helpful for
8085
# dealing with immutable objects. This is a common pattern that shows up in some other
@@ -104,6 +109,13 @@ rules:
104109
import/no-named-as-default: "off"
105110
import/no-named-as-default-member: "off"
106111
import/prefer-default-export: "off"
112+
import/order:
113+
- error
114+
- groups: [["builtin", "external"], "internal", "parent"]
115+
newlines-between: never
116+
alphabetize:
117+
order: asc
118+
caseInsensitive: true
107119
jest/no-focused-tests: "error"
108120
jsx-a11y/label-has-for: "off"
109121
jsx-a11y/no-autofocus: "off"

site/e2e/global.setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from "@playwright/test";
2+
import { Language } from "pages/CreateUserPage/CreateUserForm";
23
import * as constants from "./constants";
34
import { STORAGE_STATE } from "./playwright.config";
4-
import { Language } from "pages/CreateUserPage/CreateUserForm";
55

66
test("setup first user", async ({ page }) => {
77
await page.goto("/", { waitUntil: "domcontentloaded" });

site/e2e/helpers.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { expect, Page } from "@playwright/test";
2-
import { ChildProcess, exec, spawn } from "child_process";
1+
import { expect, type Page } from "@playwright/test";
2+
import axios from "axios";
3+
import { type ChildProcess, exec, spawn } from "child_process";
34
import { randomUUID } from "crypto";
4-
import path from "path";
55
import express from "express";
6+
import capitalize from "lodash/capitalize";
7+
import path from "path";
8+
import * as ssh from "ssh2";
9+
import { Duplex } from "stream";
10+
import type {
11+
WorkspaceBuildParameter,
12+
UpdateTemplateMeta,
13+
} from "api/typesGenerated";
614
import { TarWriter } from "utils/tar";
15+
import { prometheusPort, agentPProfPort } from "./constants";
16+
import { port } from "./playwright.config";
717
import {
818
Agent,
9-
App,
19+
type App,
1020
AppSharingLevel,
21+
type ParseComplete,
22+
type PlanComplete,
23+
type ApplyComplete,
24+
type Resource,
1125
Response,
12-
ParseComplete,
13-
PlanComplete,
14-
ApplyComplete,
15-
Resource,
16-
RichParameter,
26+
type RichParameter,
1727
} from "./provisionerGenerated";
18-
import { prometheusPort, agentPProfPort } from "./constants";
19-
import { port } from "./playwright.config";
20-
import * as ssh from "ssh2";
21-
import { Duplex } from "stream";
22-
import {
23-
WorkspaceBuildParameter,
24-
UpdateTemplateMeta,
25-
} from "api/typesGenerated";
26-
import axios from "axios";
27-
import capitalize from "lodash/capitalize";
2828

2929
// createWorkspace creates a workspace for a template.
3030
// It does not wait for it to be running, but it does navigate to the page.

site/e2e/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Page } from "@playwright/test";
1+
import type { Page } from "@playwright/test";
22

33
export const beforeCoderTest = async (page: Page) => {
44
// eslint-disable-next-line no-console -- Show everything that was printed with console.log()

site/e2e/parameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RichParameter } from "./provisionerGenerated";
1+
import type { RichParameter } from "./provisionerGenerated";
22

33
// Rich parameters
44

site/e2e/pom/BasePom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Page } from "@playwright/test";
1+
import type { Page } from "@playwright/test";
22

33
export abstract class BasePom {
44
protected readonly baseURL: string | undefined;

site/e2e/pom/SignInPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Page } from "@playwright/test";
1+
import type { Page } from "@playwright/test";
22
import { BasePom } from "./BasePom";
33

44
export class SignInPage extends BasePom {

0 commit comments

Comments
 (0)