From 203b55791bfcbe9878cfcbf10dce161d11884137 Mon Sep 17 00:00:00 2001 From: Jeremy Moseley Date: Wed, 29 Jan 2025 17:05:20 -0600 Subject: [PATCH] chore: Disable no-empty-object eslint rule. (#206) ## Proposed changes Disable the no-empty-object eslint rule so we can do things like `gsx.Component<{}, string>` --- docs/src/content/docs/basic-concepts.mdx | 2 +- docs/src/content/docs/concepts/context.mdx | 11 ++++------- docs/src/env.d.ts | 3 +-- docs/worker-configuration.d.ts | 3 +-- eslint.config.mjs | 12 ++---------- examples/blogWriter/eslint.config.mjs | 10 ++-------- examples/contexts/eslint.config.mjs | 10 ++-------- examples/contexts/index.tsx | 11 ++++------- examples/deepResearch/eslint.config.mjs | 10 ++-------- examples/eslint.config.mjs | 15 +++++++++++++++ .../groq-deepseek-r1-distilled/eslint.config.mjs | 10 ++-------- examples/hackerNewsAnalyzer/eslint.config.mjs | 10 ++-------- examples/providers/eslint.config.mjs | 10 ++-------- examples/reflection/eslint.config.mjs | 10 ++-------- examples/streaming/eslint.config.mjs | 10 ++-------- examples/structuredOutputs/eslint.config.mjs | 10 ++-------- 16 files changed, 46 insertions(+), 101 deletions(-) create mode 100644 examples/eslint.config.mjs diff --git a/docs/src/content/docs/basic-concepts.mdx b/docs/src/content/docs/basic-concepts.mdx index 84303486..418c2c2b 100644 --- a/docs/src/content/docs/basic-concepts.mdx +++ b/docs/src/content/docs/basic-concepts.mdx @@ -166,7 +166,7 @@ interface User { const UserContext = gsx.createContext({ name: "" }); // Use the context in a component -const Greeting = gsx.Component, string>("Greeting", () => { +const Greeting = gsx.Component<{}, string>("Greeting", () => { const user = gsx.useContext(UserContext); return `Hello, ${user.name}!`; }); diff --git a/docs/src/content/docs/concepts/context.mdx b/docs/src/content/docs/concepts/context.mdx index 516d183b..eee4004e 100644 --- a/docs/src/content/docs/concepts/context.mdx +++ b/docs/src/content/docs/concepts/context.mdx @@ -49,13 +49,10 @@ const UserContext = gsx.createContext({ To use the context, call the `gsx.useContext(context)` hook inside of a component. Here a `Greeting` component is created that uses the `UserContext` to get the user's name: ```tsx -const Greeting = gsx.Component, GreetingOutput>( - "Greeting", - () => { - const user = gsx.useContext(UserContext); - return `Hello, ${user.name}!`; - }, -); +const Greeting = gsx.Component<{}, GreetingOutput>("Greeting", () => { + const user = gsx.useContext(UserContext); + return `Hello, ${user.name}!`; +}); ``` ### Step 3: Provide the context value diff --git a/docs/src/env.d.ts b/docs/src/env.d.ts index 6d86cf5c..1ab8db73 100644 --- a/docs/src/env.d.ts +++ b/docs/src/env.d.ts @@ -1,8 +1,7 @@ /// // This interface is used to augment the ImportMetaEnv type -// eslint-disable-next-line @typescript-eslint/no-empty-object-type -interface ImportMetaEnv extends Record { +interface ImportMetaEnv extends {} { // Add environment variables here } diff --git a/docs/worker-configuration.d.ts b/docs/worker-configuration.d.ts index f5018fad..ee0cb010 100644 --- a/docs/worker-configuration.d.ts +++ b/docs/worker-configuration.d.ts @@ -1,7 +1,6 @@ // Generated by Wrangler // After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen` // This interface is used to define the environment variables for Cloudflare Workers -// eslint-disable-next-line @typescript-eslint/no-empty-object-type -interface Env extends Record { +interface Env extends {} { // Add environment variables here } diff --git a/eslint.config.mjs b/eslint.config.mjs index 6743fa0d..dc3ffdf6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -107,16 +107,7 @@ export default [ ], }, ], - }, - }, - { - files: ["examples/**"], - rules: { - "no-console": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-empty-object-type": "off", }, }, { @@ -130,6 +121,7 @@ export default [ "vitest/no-disabled-tests": "warn", "vitest/expect-expect": "off", "vitest/no-standalone-expect": "off", + "@typescript-eslint/no-empty-object-type": "off", }, }, ]; diff --git a/examples/blogWriter/eslint.config.mjs b/examples/blogWriter/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/blogWriter/eslint.config.mjs +++ b/examples/blogWriter/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/contexts/eslint.config.mjs b/examples/contexts/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/contexts/eslint.config.mjs +++ b/examples/contexts/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/contexts/index.tsx b/examples/contexts/index.tsx index 08950dd9..da4e7e0b 100644 --- a/examples/contexts/index.tsx +++ b/examples/contexts/index.tsx @@ -12,13 +12,10 @@ const UserContext = gsx.createContext({ type GreetingOutput = string; // Use the context in a component -const Greeting = gsx.Component, GreetingOutput>( - "Greeting", - () => { - const user = gsx.useContext(UserContext); - return `Hello, ${user.name}!`; - }, -); +const Greeting = gsx.Component<{}, GreetingOutput>("Greeting", () => { + const user = gsx.useContext(UserContext); + return `Hello, ${user.name}!`; +}); async function main() { // Provide a value to the context diff --git a/examples/deepResearch/eslint.config.mjs b/examples/deepResearch/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/deepResearch/eslint.config.mjs +++ b/examples/deepResearch/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/eslint.config.mjs b/examples/eslint.config.mjs new file mode 100644 index 00000000..757adc69 --- /dev/null +++ b/examples/eslint.config.mjs @@ -0,0 +1,15 @@ +export default [ + { + files: ["**/*.ts", "**/*.tsx"], + rules: { + "@typescript-eslint/no-empty-object-type": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", + "no-console": "off", + "node/no-unsupported-features/es-syntax": "off", + }, + }, +]; diff --git a/examples/groq-deepseek-r1-distilled/eslint.config.mjs b/examples/groq-deepseek-r1-distilled/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/groq-deepseek-r1-distilled/eslint.config.mjs +++ b/examples/groq-deepseek-r1-distilled/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/hackerNewsAnalyzer/eslint.config.mjs b/examples/hackerNewsAnalyzer/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/hackerNewsAnalyzer/eslint.config.mjs +++ b/examples/hackerNewsAnalyzer/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/providers/eslint.config.mjs b/examples/providers/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/providers/eslint.config.mjs +++ b/examples/providers/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/reflection/eslint.config.mjs b/examples/reflection/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/reflection/eslint.config.mjs +++ b/examples/reflection/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/streaming/eslint.config.mjs b/examples/streaming/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/streaming/eslint.config.mjs +++ b/examples/streaming/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ]; diff --git a/examples/structuredOutputs/eslint.config.mjs b/examples/structuredOutputs/eslint.config.mjs index 1e822356..43705eb3 100644 --- a/examples/structuredOutputs/eslint.config.mjs +++ b/examples/structuredOutputs/eslint.config.mjs @@ -1,7 +1,9 @@ import rootConfig from "../../eslint.config.mjs"; +import examplesConfig from "../eslint.config.mjs"; export default [ ...rootConfig, + ...examplesConfig, { files: ["**/*.{js,mjs,cjs,jsx,ts,tsx}"], languageOptions: { @@ -10,13 +12,5 @@ export default [ project: "./tsconfig.json", }, }, - rules: { - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "node/no-unsupported-features/es-syntax": "off", - }, }, ];