Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Update eslint related packages
Browse files Browse the repository at this point in the history
  • Loading branch information
melissaluu committed Nov 30, 2023
1 parent 6799c8a commit 9dafaaf
Show file tree
Hide file tree
Showing 30 changed files with 568 additions and 391 deletions.
2 changes: 2 additions & 0 deletions .changeset/angry-lies-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^11.0.0",
"@shopify/babel-preset": "^25.0.0",
"@shopify/eslint-plugin": "^42.0.0",
"@shopify/eslint-plugin": "^43.0.0",
"@shopify/prettier-config": "^1.1.2",
"@shopify/typescript-configs": "^5.1.0",
"@types/jest": "^29.5.0",
"@types/regenerator-runtime": "^0.13.1",
"@typescript-eslint/parser": "^6.7.5",
"babel-jest": "^29.5.0",
"eslint": "^7.32.0",
"eslint": "^8.54.0",
"jest": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"jest-runner-eslint": "^2.1.2",
"prettier": "^2.5.1",
"prettier": "^3.1.0",
"regenerator-runtime": "^0.13.11",
"rollup": "^3.19.1",
"rollup-plugin-dts": "^5.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/admin-api-client/src/admin-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function createAdminApiClient({
const apiUrlFormatter = generateApiUrlFormatter(
storeUrl,
apiVersion,
baseApiVersionValidationParams
baseApiVersionValidationParams,
);

const config: AdminApiClientConfig = {
Expand Down Expand Up @@ -114,7 +114,7 @@ function generateApiUrlFormatter(
baseApiVersionValidationParams: Omit<
Parameters<typeof validateApiVersion>[0],
"apiVersion"
>
>,
) {
return (apiVersion?: string) => {
if (apiVersion) {
Expand All @@ -132,7 +132,7 @@ function generateApiUrlFormatter(

function generateGetApiUrl(
config: AdminApiClientConfig,
apiUrlFormatter: (version?: string) => string
apiUrlFormatter: (version?: string) => string,
): AdminApiClient["getApiUrl"] {
return (propApiVersion?: string) => {
return propApiVersion ? apiUrlFormatter(propApiVersion) : config.apiUrl;
Expand Down
72 changes: 36 additions & 36 deletions packages/admin-api-client/src/tests/admin-api-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ describe("Admin API Client", () => {
it("calls the graphql client with headers and API URL", () => {
createAdminApiClient({ ...config });
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("headers", {
"Content-Type": "application/json",
Accept: "application/json",
"X-Shopify-Access-Token": "access-token",
"User-Agent": "Admin API Client vROLLUP_REPLACE_CLIENT_VERSION",
});
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("url", mockApiUrl);
});

Expand All @@ -69,7 +69,7 @@ describe("Admin API Client", () => {

expect(createGraphQLClient).toHaveBeenCalled();
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("retries", 0);
});

Expand All @@ -80,7 +80,7 @@ describe("Admin API Client", () => {

expect(createGraphQLClient).toHaveBeenCalled();
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("retries", retries);
});

Expand All @@ -89,7 +89,7 @@ describe("Admin API Client", () => {

createAdminApiClient({ ...config, userAgentPrefix });
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("headers", {
"Content-Type": "application/json",
Accept: "application/json",
Expand All @@ -98,7 +98,7 @@ describe("Admin API Client", () => {
"test-UAP | Admin API Client vROLLUP_REPLACE_CLIENT_VERSION",
});
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("url", mockApiUrl);
});

Expand All @@ -109,7 +109,7 @@ describe("Admin API Client", () => {

expect(createGraphQLClient).toHaveBeenCalled();
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("fetchApi", customFetchApi);
});

Expand All @@ -120,7 +120,7 @@ describe("Admin API Client", () => {

expect(createGraphQLClient).toHaveBeenCalled();
expect(
(createGraphQLClient as jest.Mock).mock.calls[0][0]
(createGraphQLClient as jest.Mock).mock.calls[0][0],
).toHaveProperty("logger", logger);
});

Expand All @@ -142,11 +142,11 @@ describe("Admin API Client", () => {
createAdminApiClient({
...config,
storeDomain: undefined as any,
})
}),
).toThrow(
new Error(
'Admin API Client: a valid store domain ("undefined") must be provided'
)
'Admin API Client: a valid store domain ("undefined") must be provided',
),
);
});

Expand All @@ -155,11 +155,11 @@ describe("Admin API Client", () => {
createAdminApiClient({
...config,
storeDomain: " " as any,
})
}),
).toThrow(
new Error(
'Admin API Client: a valid store domain (" ") must be provided'
)
'Admin API Client: a valid store domain (" ") must be provided',
),
);
});

Expand All @@ -168,11 +168,11 @@ describe("Admin API Client", () => {
createAdminApiClient({
...config,
storeDomain: 123 as any,
})
}),
).toThrow(
new Error(
'Admin API Client: a valid store domain ("123") must be provided'
)
'Admin API Client: a valid store domain ("123") must be provided',
),
);
});

Expand All @@ -181,13 +181,13 @@ describe("Admin API Client", () => {
createAdminApiClient({
...config,
apiVersion: undefined as any,
})
}),
).toThrow(
new Error(
`Admin API Client: the provided apiVersion ("undefined") is invalid. Current supported API versions: ${mockApiVersions.join(
", "
)}`
)
", ",
)}`,
),
);
});

Expand All @@ -203,8 +203,8 @@ describe("Admin API Client", () => {

expect(consoleWarnSpy).toHaveBeenCalledWith(
`Admin API Client: the provided apiVersion ("2022-07") is deprecated or not supported. Current supported API versions: ${mockApiVersions.join(
", "
)}`
", ",
)}`,
);
});

Expand All @@ -213,9 +213,9 @@ describe("Admin API Client", () => {
createAdminApiClient({
...config,
accessToken: undefined as any,
})
}),
).toThrow(
new Error(`Admin API Client: an access token must be provided`)
new Error(`Admin API Client: an access token must be provided`),
);
});

Expand All @@ -226,11 +226,11 @@ describe("Admin API Client", () => {
createAdminApiClient({
...config,
accessToken: "access-token",
})
}),
).toThrow(
new Error(
"Admin API Client: this client should not be used in the browser"
)
"Admin API Client: this client should not be used in the browser",
),
);

delete (global as any).window;
Expand Down Expand Up @@ -298,7 +298,7 @@ describe("Admin API Client", () => {
it("returns a header object that includes the content-type header", () => {
const client = createAdminApiClient(config);
expect(client.config.headers["Content-Type"]).toBe(
DEFAULT_CONTENT_TYPE
DEFAULT_CONTENT_TYPE,
);
});

Expand All @@ -310,7 +310,7 @@ describe("Admin API Client", () => {
it("returns a header object that includes the access token headers when an access token is provided", () => {
const client = createAdminApiClient(config);
expect(client.config.headers[ACCESS_TOKEN_HEADER]).toEqual(
config.accessToken
config.accessToken,
);
});
});
Expand Down Expand Up @@ -356,7 +356,7 @@ describe("Admin API Client", () => {
const version = "unstable";
const url = client.getApiUrl(version);
expect(url).toEqual(
`${config.storeDomain}/admin/api/${version}/graphql.json`
`${config.storeDomain}/admin/api/${version}/graphql.json`,
);
});

Expand All @@ -365,9 +365,9 @@ describe("Admin API Client", () => {
expect(() => client.getApiUrl(version)).toThrow(
new Error(
`Admin API Client: the provided apiVersion ("123") is invalid. Current supported API versions: ${mockApiVersions.join(
", "
)}`
)
", ",
)}`,
),
);
});

Expand All @@ -381,8 +381,8 @@ describe("Admin API Client", () => {

expect(consoleWarnSpy).toHaveBeenCalledWith(
`Admin API Client: the provided apiVersion ("2021-01") is deprecated or not supported. Current supported API versions: ${mockApiVersions.join(
", "
)}`
", ",
)}`,
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/api-codegen-preset/src/helpers/get-schema-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { apiConfigs } from "./api-configs";
export function getSchemaData(
outputDir: string,
apiType: ApiType,
apiVersion?: string
apiVersion?: string,
) {
const config = apiConfigs[apiType];

return {
schema: config.schema.replace(
"%%API_VERSION%%",
apiVersion ? `/${apiVersion}` : ""
apiVersion ? `/${apiVersion}` : "",
),
schemaFile: `${outputDir}/${config.schemaFile.replace(
"%%API_VERSION%%",
apiVersion ? `-${apiVersion}` : ""
apiVersion ? `-${apiVersion}` : "",
)}`,
};
}
2 changes: 1 addition & 1 deletion packages/api-codegen-preset/src/tests/api-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ describe("shopifyApiProject", () => {
},
});
});
}
},
);
});
2 changes: 1 addition & 1 deletion packages/api-codegen-preset/src/tests/api-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ describe("shopifyApiTypes", () => {
},
});
});
}
},
);
});
8 changes: 4 additions & 4 deletions packages/api-codegen-preset/src/tests/preset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ describe("Preset", () => {
expect(result).toHaveLength(1);

const generatedCode = result.find(
(file) => file.filename === "out.d.ts"
(file) => file.filename === "out.d.ts",
)!.content;

// Disables ESLint
expect(generatedCode).toMatch("/* eslint-disable */");

// Imports Admin API
expect(generatedCode).toMatch(
`import * as AdminTypes from './admin.types.d.ts';`
`import * as AdminTypes from './admin.types.d.ts';`,
);

// Uses Pick<...>
expect(generatedCode).toMatch(`Pick<AdminTypes.`);

// Generates query and mutation types
expect(generatedCode).toMatch(
/interface GeneratedQueryTypes \{\s+"#graphql/
/interface GeneratedQueryTypes \{\s+"#graphql/,
);
expect(generatedCode).toMatch(
/interface GeneratedMutationTypes \{\s+"#graphql/
/interface GeneratedMutationTypes \{\s+"#graphql/,
);

// Augments query/mutation types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type UnpackedInputMaybe<InputType> = InputType extends InputMaybe<infer R>

export type OperationVariables<
Operation extends keyof Operations,
Operations extends AllOperations
Operations extends AllOperations,
> = Operations[Operation]["variables"] extends { [key: string]: never }
? { [key: string]: never }
: {
Expand All @@ -31,5 +31,5 @@ export type ResponseWithType<T = any> = Omit<Response, "json"> & {

export type ReturnData<
Operation extends keyof Operations,
Operations extends AllOperations
Operations extends AllOperations,
> = Operation extends keyof Operations ? Operations[Operation]["return"] : any;
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("generateGetHeaders()", () => {

const headers = getHeader(customHeaders);
expect(headers["X-Shopify-Storefront-Access-Token"]).toEqual(
config.headers["X-Shopify-Storefront-Access-Token"]
config.headers["X-Shopify-Storefront-Access-Token"],
);
});
});
Expand Down
Loading

0 comments on commit 9dafaaf

Please sign in to comment.