Skip to content

Commit 7d541c5

Browse files
authored
Added tseslint style checks (#31)
1 parent 237394d commit 7d541c5

File tree

11 files changed

+18
-22
lines changed

11 files changed

+18
-22
lines changed

packages/config/eslint/base.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const getBaseESLintConfig = ({
3939
]
4040
: undefined),
4141
...tseslint.configs.recommendedTypeChecked,
42+
...tseslint.configs.stylisticTypeChecked,
4243
{
4344
files: ["**/*.{ts,tsx,mts}"],
4445
languageOptions: {
@@ -78,6 +79,7 @@ export const getBaseESLintConfig = ({
7879
"no-return-assign": "error",
7980
"@typescript-eslint/consistent-type-imports": "error",
8081
"@typescript-eslint/no-non-null-assertion": "error",
82+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
8183

8284
// TODO: Currently this crashes and so we have to turn it off. It was fixed previously at
8385
// https://github.com/typescript-eslint/typescript-eslint/issues/10338, but seems to have regressed

packages/docs-md/src/cli/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ async function getSettings(): Promise<ParsedSettings> {
115115
);
116116
}
117117

118-
if (!configFileImport.output) {
119-
configFileImport.output = {};
120-
}
118+
configFileImport.output ??= {};
121119

122120
// Parse the settings using Zod to ensure accuracy
123121
const configFileContents = settingsSchema.safeParse(configFileImport);

packages/docs-md/src/components/TryItNow/hooks/useCodeDependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function useTranspileDependencyMatches(transpiledCode: string) {
2020
const dependencies = transpiledCode.matchAll(re);
2121
const dependenciesArray = Array.from(dependencies).reduce(
2222
(prev, match) => {
23-
const dependency = match.groups?.dependency || "";
23+
const dependency = match.groups?.dependency ?? "";
2424
// filter out local dependencies
2525
if (localImportRegex.test(dependency)) {
2626
return prev;

packages/docs-md/src/components/TryItNow/state/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const lastEditorValueAtom = atom<string | null>(null);
88
export const setDependenciesAtom = atom(
99
null,
1010
(get, set, dependencies: Record<string, string>, code: string) => {
11-
const previousDependencies = get(dependenciesAtom) || {};
11+
const previousDependencies = get(dependenciesAtom) ?? {};
1212
if (
1313
Object.keys(dependencies).join("-") !==
1414
Object.keys(previousDependencies).join("-")

packages/docs-md/src/pages/codeSnippets/generateCodeSnippets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
import { getSettings } from "../../util/settings.ts";
1010

1111
const CODE_SNIPPETS_API_URL =
12-
process.env.SPEAKEASY_CODE_SNIPPETS_API_URL || "https://api.speakeasy.com";
12+
process.env.SPEAKEASY_CODE_SNIPPETS_API_URL ?? "https://api.speakeasy.com";
1313

1414
export type DocsCodeSnippets = Record<OperationChunk["id"], CodeSnippet>;
1515

packages/docs-md/src/pages/content/chunks/schema.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type TypeLabel = {
3333

3434
type DisplayType = {
3535
typeLabel: TypeLabel;
36-
breakoutSubTypes: Array<{ label: string; schema: SchemaValue }>;
36+
breakoutSubTypes: { label: string; schema: SchemaValue }[];
3737
};
3838

3939
function getDisplayType(
@@ -208,9 +208,7 @@ function computeMultilineTypeLabel(
208208
}
209209

210210
let contents = `${typeLabel.label}<\n`;
211-
for (let i = 0; i < children.length; i++) {
212-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
213-
const child = children[i]!;
211+
for (const child of children) {
214212
contents += `${" ".repeat(indentation + 1)}${child.contents}\n`;
215213
}
216214
contents += `${" ".repeat(indentation)}>\n`;
@@ -241,9 +239,7 @@ function computeMultilineTypeLabel(
241239
}
242240

243241
let contents = "\n";
244-
for (let i = 0; i < children.length; i++) {
245-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
246-
const child = children[i]!;
242+
for (const child of children) {
247243
contents += `${" ".repeat(indentation)}| ${child.contents}\n`;
248244
}
249245
return {

packages/docs-md/src/pages/data/getDocsData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { unzipSync } from "node:zlib";
99
import type { Chunk } from "../../types/chunk.ts";
1010
declare class Go {
1111
argv: string[];
12-
env: { [envKey: string]: string };
12+
env: Record<string, string>;
1313
exit: (code: number) => void;
1414
importObject: WebAssembly.Imports;
1515
exited: boolean;

packages/docs-md/src/types/renderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type AppendOptions = {
44
escape?: Escape;
55
};
66

7-
export interface Renderer {
7+
export type Renderer = {
88
escapeText(text: string, options: { escape: Escape }): string;
99

1010
insertFrontMatter(options: {
@@ -67,4 +67,4 @@ export interface Renderer {
6767
}): void;
6868

6969
render(): string;
70-
}
70+
};

packages/docs-md/src/types/site.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Renderer } from "./renderer.ts";
22

3-
export interface Site {
3+
export type Site = {
44
createPage(path: string): Renderer;
55
render(): Record<string, string>;
66
buildPagePath(slug: string, options?: { appendIndex?: boolean }): string;
77
hasPage(path: string): boolean;
8-
}
8+
};

scaffold-templates/docusaurus/src/components/PropertiesModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as Dialog from "@radix-ui/react-dialog";
22
import "./styles.css";
33

4-
interface PropertiesModalProps {
4+
type PropertiesModalProps = {
55
children: React.ReactNode;
6-
}
6+
};
77

88
export const PropertiesModal = ({ children }: PropertiesModalProps) => (
99
<Dialog.Root>

0 commit comments

Comments
 (0)