Skip to content

Commit

Permalink
fix: lint config
Browse files Browse the repository at this point in the history
  • Loading branch information
jagoral committed Dec 18, 2023
1 parent 181e919 commit a6b6c15
Show file tree
Hide file tree
Showing 22 changed files with 1,318 additions and 208 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@types/jest": "^26.0.24",
"@types/node": "^16",
"@vue-storefront/api-extractor-config": "^0.0.4",
"@vue-storefront/eslint-config": "~2.0.0-rc.7",
"@vue-storefront/eslint-config-integrations": "^0.0.19",
"@vue-storefront/integrations-tsconfig": "^0.0.4",
"@vue-storefront/jest-config": "^0.0.3",
Expand Down
5 changes: 3 additions & 2 deletions packages/storefront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
},
"devDependencies": {
"@vue-storefront/api-extractor-config": "^0.0.4",
"@vue-storefront/eslint-config-integrations": "^0.0.19",
"@vue-storefront/integrations-tsconfig": "^0.0.4"
"@vue-storefront/eslint-config": "~2.0.0-rc.7",
"@vue-storefront/integrations-tsconfig": "^0.0.4",
"eslint": "^8.55.0"
},
"workspaces": {
"packages": [
Expand Down
15 changes: 15 additions & 0 deletions packages/storefront/packages/next/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
extends: [
"@vue-storefront/eslint-config",
"@vue-storefront/eslint-config/react",
],
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
},
rules: {
complexity: 0,
"max-statements": "off",
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-unresolved, import/extensions
import { ClientComponentUsingSdk } from "./ClientComponent";

export default function ClientSidePage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ReactNode } from "react";
// eslint-disable-next-line import/extensions, import/no-unresolved
import { Providers } from "./providers";

export default function RootLayout({ children }: { children: ReactNode }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-unresolved
import { createSdkContext } from "@vue-storefront/next/client";
import { getSdk } from "../sdk.config";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-unresolved */
import { createSdkContext } from "@vue-storefront/next/client";
import { getSdk } from "../sdk.config";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-unresolved */
/* eslint-disable import/no-relative-packages */
import { exampleSdkModule } from "@storefront/shared";
import { CreateSdkOptions, createSdk } from "@vue-storefront/next";

Expand Down
1 change: 0 additions & 1 deletion packages/storefront/packages/next/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// eslint-disable-next-line import/extensions, import/no-unresolved
export * from "./sdk";
2 changes: 0 additions & 2 deletions packages/storefront/packages/next/src/sdk/client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */

"use client";

import { SDKApi } from "@vue-storefront/sdk";
Expand Down
1 change: 0 additions & 1 deletion packages/storefront/packages/next/src/sdk/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// eslint-disable-next-line import/extensions, import/no-unresolved
export * from "./resolveDynamicContext";
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DynamicContext, GetSdkContext } from "../types";

const BLACKLISTED_HEADERS = ["host"];
const BLACKLISTED_HEADERS = new Set(["host"]);

function isAppRouterHeaders(
headers: ReturnType<GetSdkContext["getRequestHeaders"]>
Expand All @@ -16,13 +16,11 @@ export function resolveDynamicContext(context: GetSdkContext): DynamicContext {
const resolvedHeaders = isAppRouterHeaders(headers)
? Object.fromEntries(headers.entries())
: headers;
const allowedHeaders = Object.fromEntries(
return Object.fromEntries(
Object.entries(resolvedHeaders).filter(
([key]) => !BLACKLISTED_HEADERS.includes(key)
([key]) => !BLACKLISTED_HEADERS.has(key)
)
);

return allowedHeaders;
},
};
}
7 changes: 1 addition & 6 deletions packages/storefront/packages/next/src/sdk/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SDKApi, buildModule } from "@vue-storefront/sdk";
import { JSX, ReactNode } from "react";
import { ReactNode } from "react";

export type GetSdkContext = {
/**
Expand Down Expand Up @@ -27,11 +27,6 @@ export type SdkProviderProps = {
children: ReactNode;
};

type CreateSdkContextReturn<TConfig extends Record<string, any>> = readonly [
(props: SdkProviderProps) => JSX.Element,
() => SDKApi<TConfig>
];

export interface CreateSdkReturn<TConfig extends Record<string, any>> {
/**
* Creates a new SDK instance. This function is dedicated for server-side usage,
Expand Down
2 changes: 1 addition & 1 deletion packages/storefront/packages/next/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
}
},
"exclude": ["node_modules"],
"include": ["src/**/*.ts"]
"include": ["**/*.ts"]
}
1 change: 0 additions & 1 deletion packages/storefront/packages/next/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-unresolved
import { defineConfig } from "vitest/config";

export default defineConfig({
Expand Down
16 changes: 16 additions & 0 deletions packages/storefront/packages/nuxt/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
extends: [
"@vue-storefront/eslint-config",
"@vue-storefront/eslint-config/vue3",
],
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
extraFileExtensions: [".vue"],
},
rules: {
complexity: 0,
"max-statements": "off",
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-relative-packages
import { exampleSdkModule } from "../../../shared";

export default defineSdkConfig(
Expand Down
2 changes: 1 addition & 1 deletion packages/storefront/packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build:app": "cd __tests__/app && yarn build",
"dev": "cd __tests__/app && yarn dev",
"dev:middleware": "cd ../shared/src/__tests__/middleware && yarn dev",
"lint": "eslint .",
"lint": "eslint --ext .vue,.js,.ts .",
"test": "start-server-and-test dev:middleware localhost:4000/test_integration/success dev localhost:3000/ssr \"yarn test:e2e\"",
"test:e2e": "cd ../shared/ && yarn test:e2e",
"test:watch": "vitest watch",
Expand Down
1 change: 0 additions & 1 deletion packages/storefront/packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
addPluginTemplate,
addTypeTemplate,
addImportsSources,
// eslint-disable-next-line import/no-unresolved
} from "@nuxt/kit";
import { genInlineTypeImport } from "knitwork";
import { SdkModuleOptions } from "./types";
Expand Down
1 change: 0 additions & 1 deletion packages/storefront/packages/nuxt/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-unresolved
import { defineConfig } from "vitest/config";

export default defineConfig({
Expand Down
Loading

0 comments on commit a6b6c15

Please sign in to comment.