Skip to content

Commit

Permalink
chore: Disable no-empty-object eslint rule. (#206)
Browse files Browse the repository at this point in the history
## Proposed changes

Disable the no-empty-object eslint rule so we can do things like
`gsx.Component<{}, string>`
  • Loading branch information
jmoseley authored Jan 29, 2025
1 parent c611e61 commit 203b557
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 101 deletions.
2 changes: 1 addition & 1 deletion docs/src/content/docs/basic-concepts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ interface User {
const UserContext = gsx.createContext({ name: "" });

// Use the context in a component
const Greeting = gsx.Component<Record<never, never>, string>("Greeting", () => {
const Greeting = gsx.Component<{}, string>("Greeting", () => {
const user = gsx.useContext(UserContext);
return `Hello, ${user.name}!`;
});
Expand Down
11 changes: 4 additions & 7 deletions docs/src/content/docs/concepts/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ const UserContext = gsx.createContext<User>({
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<Record<never, never>, 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
Expand Down
3 changes: 1 addition & 2 deletions docs/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/// <reference types="astro/client" />

// This interface is used to augment the ImportMetaEnv type
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface ImportMetaEnv extends Record<string, unknown> {
interface ImportMetaEnv extends {} {
// Add environment variables here
}

Expand Down
3 changes: 1 addition & 2 deletions docs/worker-configuration.d.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown> {
interface Env extends {} {
// Add environment variables here
}
12 changes: 2 additions & 10 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
{
Expand All @@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/blogWriter/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/contexts/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
11 changes: 4 additions & 7 deletions examples/contexts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ const UserContext = gsx.createContext<User>({
type GreetingOutput = string;

// Use the context in a component
const Greeting = gsx.Component<Record<never, never>, 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
Expand Down
10 changes: 2 additions & 8 deletions examples/deepResearch/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
15 changes: 15 additions & 0 deletions examples/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/groq-deepseek-r1-distilled/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/hackerNewsAnalyzer/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/providers/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/reflection/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/streaming/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];
10 changes: 2 additions & 8 deletions examples/structuredOutputs/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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",
},
},
];

0 comments on commit 203b557

Please sign in to comment.