Skip to content

Commit fe596df

Browse files
authored
Merge pull request #269 from gadget-inc/fix-extensions-lint
Add import-extensions lint rules and fix latent lint warnings
2 parents aac2962 + c299d6d commit fe596df

File tree

20 files changed

+48
-43
lines changed

20 files changed

+48
-43
lines changed

.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ module.exports = {
44
tsconfigRootDir: __dirname,
55
project: ["./packages/*/tsconfig.json", "./scripts/tsconfig.json", "./packages/blog-example/tsconfig.node.json"],
66
},
7+
settings: {
8+
"import/extensions": [".js", ".jsx"],
9+
},
710
rules: {
811
"lodash/import-scope": "off",
912
"react/react-in-jsx-scope": "off",
13+
"@typescript-eslint/require-await": "off",
14+
"import/extensions": ["error", "ignorePackages"],
1015
},
1116
};

packages/api-client-core/spec/GadgetConnection-suite.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Response } from "cross-fetch";
22
import gql from "gql-tag";
33
import nock from "nock";
4-
import { AuthenticationMode, BrowserSessionStorageType, GadgetConnection } from "../src";
4+
import { AuthenticationMode, BrowserSessionStorageType, GadgetConnection } from "../src/index.js";
55
import { base64 } from "./helpers.js";
66

77
nock.disableNetConnect();
@@ -404,7 +404,7 @@ export const GadgetConnectionSharedSuite = (queryExtra = "") => {
404404
(init.headers as any).authorization = `FancyMode whatever`;
405405
},
406406
// eslint-disable-next-line @typescript-eslint/no-empty-function
407-
processTransactionConnectionParams: async (params) => {},
407+
processTransactionConnectionParams: async (_params) => {},
408408
},
409409
},
410410
});
@@ -474,7 +474,7 @@ export const GadgetConnectionSharedSuite = (queryExtra = "") => {
474474
(init.headers as any)["x-whatever"] = `FancyMode whatever`;
475475
},
476476
// eslint-disable-next-line @typescript-eslint/no-empty-function
477-
processTransactionConnectionParams: async (params) => {},
477+
processTransactionConnectionParams: async (_params) => {},
478478
},
479479
},
480480
});
@@ -555,7 +555,7 @@ export const GadgetConnectionSharedSuite = (queryExtra = "") => {
555555
(init.headers as any).authorization = `FancyMode whatever`;
556556
},
557557
// eslint-disable-next-line @typescript-eslint/no-empty-function
558-
processTransactionConnectionParams: async (params) => {},
558+
processTransactionConnectionParams: async (_params) => {},
559559
},
560560
});
561561

packages/api-client-core/spec/operationRunners.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import nock from "nock";
22
import type { GadgetErrorGroup } from "../src/index.js";
33
import { GadgetConnection, actionRunner } from "../src/index.js";
4-
import { mockUrqlClient } from "./mockUrqlClient";
4+
import { mockUrqlClient } from "./mockUrqlClient.js";
55

66
nock.disableNetConnect();
77

packages/api-client-core/src/GadgetConnection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
12
import type { ClientOptions, RequestPolicy } from "@urql/core";
23
import { Client, cacheExchange, fetchExchange, subscriptionExchange } from "@urql/core";
34

packages/blog-example/src/App.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useFetch, useFindMany } from "@gadgetinc/react";
22
import { Suspense, useEffect, useState } from "react";
3-
import { api } from "./api";
3+
import { api } from "./api.js";
44
import "./styles/App.css";
55

66
function ExampleFetch() {
@@ -9,6 +9,7 @@ function ExampleFetch() {
99

1010
useEffect(() => {
1111
setHistory([...history, result]);
12+
// eslint-disable-next-line react-hooks/exhaustive-deps
1213
}, [result]);
1314

1415
return (
@@ -27,8 +28,9 @@ function ExampleFindMany() {
2728
const [result, send] = useFindMany(api.post);
2829

2930
useEffect(() => {
30-
const { operation, ...keep } = result;
31+
const { operation: _operation, ...keep } = result;
3132
setHistory([...history, keep]);
33+
// eslint-disable-next-line react-hooks/exhaustive-deps
3234
}, [result]);
3335

3436
return (
@@ -64,8 +66,9 @@ function ExampleSuspenseInner() {
6466
const [result, send] = useFindMany(api.post, { suspense: true, sort: { id: "Descending" } });
6567

6668
useEffect(() => {
67-
const { operation, ...keep } = result;
69+
const { operation: _operation, ...keep } = result;
6870
setHistory([...history, keep]);
71+
// eslint-disable-next-line react-hooks/exhaustive-deps
6972
}, [result]);
7073

7174
return (

packages/blog-example/src/main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Provider } from "@gadgetinc/react";
22
import React from "react";
33
import ReactDOM from "react-dom/client";
4-
import App from "./App";
5-
import { api } from "./api";
4+
import App from "./App.js";
5+
import { api } from "./api.js";
66
import "./styles/index.css";
77

88
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(

packages/react-shopify-app-bridge/spec/useGadget.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { AppType } from "../src/index.js";
55
import { useGadget } from "../src/index.js";
66

77
// these functions are typechecked but never run to avoid actually making API calls
8-
const TestUseGadgetReturnsAppropriateTypes = () => {
8+
const _TestUseGadgetReturnsAppropriateTypes = () => {
99
const { loading, appType, isEmbedded, appBridge, canAuth, isAuthenticated, isRootFrameRequest } = useGadget();
1010

1111
assert<IsExact<typeof loading, boolean>>(true);

packages/react/spec/components/auth/SignedOut.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "@testing-library/jest-dom";
22
import { render } from "@testing-library/react";
33
import React from "react";
4-
import { SignedOut } from "../../../src/components/auth/SignedOut";
4+
import { SignedOut } from "../../../src/components/auth/SignedOut.js";
55
import { superAuthApi } from "../../apis.js";
66
import { MockClientWrapper } from "../../testWrappers.js";
77
import { expectMockDeletedUser, expectMockSignedInUser, expectMockSignedOutUser } from "../../utils.js";

packages/react/spec/jsdom-environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import JSDOMEnvironment from "jest-environment-jsdom";
22
import { ReadableStream, TextDecoderStream } from "stream/web";
33
import { TextDecoder, TextEncoder } from "util";
44

5+
// eslint-disable-next-line jsdoc/require-jsdoc
56
export default class extends JSDOMEnvironment {
67
constructor(...args: ConstructorParameters<typeof JSDOMEnvironment>) {
78
super(...args);

packages/react/spec/useAction.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { MockClientWrapper, createMockUrqlClient, mockUrqlClient } from "./testW
1313

1414
describe("useAction", () => {
1515
// these functions are typechecked but never run to avoid actually making API calls
16-
const TestUseActionCanRunUpdateActionsWithVariables = () => {
16+
const _TestUseActionCanRunUpdateActionsWithVariables = () => {
1717
const [_, mutate] = useAction(relatedProductsApi.user.update);
1818

1919
// can call with variables
@@ -32,7 +32,7 @@ describe("useAction", () => {
3232
void mutate({ foo: "123" });
3333
};
3434

35-
const TestUseActionCanRunCreateActionsWithVariables = () => {
35+
const _TestUseActionCanRunCreateActionsWithVariables = () => {
3636
const [_, mutate] = useAction(relatedProductsApi.user.create);
3737

3838
// can call with variables
@@ -48,7 +48,7 @@ describe("useAction", () => {
4848
void mutate({ foo: "123" });
4949
};
5050

51-
const TestUseActionCanRunWithoutModelApiIdentifier = () => {
51+
const _TestUseActionCanRunWithoutModelApiIdentifier = () => {
5252
const [_, mutate] = useAction(relatedProductsApi.unambiguous.update);
5353

5454
// can call using flat style
@@ -64,7 +64,7 @@ describe("useAction", () => {
6464
void mutate({});
6565
};
6666

67-
const TestUseActionCannotRunWithoutModelApiIdentifier = () => {
67+
const _TestUseActionCannotRunWithoutModelApiIdentifier = () => {
6868
const [_, mutate] = useAction(relatedProductsApi.ambiguous.update);
6969

7070
// @ts-expect-error models with ambigous identifiers can't be called with flat style signature
@@ -80,8 +80,8 @@ describe("useAction", () => {
8080
void mutate({});
8181
};
8282

83-
const TestUseActionReturnsTypedDataWithExplicitSelection = () => {
84-
const [{ data, fetching, error }, mutate] = useAction(relatedProductsApi.user.update, {
83+
const _TestUseActionReturnsTypedDataWithExplicitSelection = () => {
84+
const [{ data, fetching, error }, _mutate] = useAction(relatedProductsApi.user.update, {
8585
select: { id: true, email: true },
8686
});
8787

@@ -96,7 +96,7 @@ describe("useAction", () => {
9696
}
9797
};
9898

99-
const TestUseActionReturnsTypedDataWithNoSelection = () => {
99+
const _TestUseActionReturnsTypedDataWithNoSelection = () => {
100100
const [{ data }] = useAction(relatedProductsApi.user.update);
101101

102102
if (data) {

0 commit comments

Comments
 (0)