Skip to content

Commit

Permalink
lint: format & fix style issues in project
Browse files Browse the repository at this point in the history
  • Loading branch information
suryarajendhran committed Jul 25, 2024
1 parent 247accb commit 79850dc
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 66 deletions.
1 change: 1 addition & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run build --if-present
- run: npm test --workspaces --if-present
4 changes: 1 addition & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"recommendations": [
"graphql.vscode-graphql"
]
"recommendations": ["graphql.vscode-graphql"]
}
17 changes: 17 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"formatter": {
"enabled": true,
"indentWidth": 2,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
6 changes: 3 additions & 3 deletions extensions/checkout-ui-2/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
['@babel/preset-react', { runtime: 'automatic' }],
'@babel/preset-typescript',
["@babel/preset-env", { targets: { node: "current" } }],
["@babel/preset-react", { runtime: "automatic" }],
"@babel/preset-typescript",
],
};
45 changes: 24 additions & 21 deletions extensions/checkout-ui-2/src/Checkout.test.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import { mount } from '@remote-ui/testing'
import { createRoot } from '@remote-ui/react'
import { Extension } from './Checkout'
import * as Shopify from '@shopify/ui-extensions-react/checkout';
import '@remote-ui/testing/matchers';
import { createRoot } from "@remote-ui/react";
import { mount } from "@remote-ui/testing";
import * as Shopify from "@shopify/ui-extensions-react/checkout";
import { Extension } from "./Checkout";
import "@remote-ui/testing/matchers";

jest.mock('@shopify/ui-extensions-react/checkout', () => {
return {
__esModule: true,
...jest.requireActual('@shopify/ui-extensions-react/checkout'),
};
jest.mock("@shopify/ui-extensions-react/checkout", () => {
return {
__esModule: true,
...jest.requireActual("@shopify/ui-extensions-react/checkout"),
};
});

jest
.spyOn(Shopify, 'useTranslate')
.mockImplementation(() => (translationKey: string) => translationKey as any);
.spyOn(Shopify, "useTranslate")
// biome-ignore lint/suspicious/noExplicitAny: can't mock an i18n function
.mockImplementation(() => (translationKey: string) => translationKey as any);

jest.spyOn(Shopify, 'useApi').mockImplementation(() => ({ extension: { target: 'purchase.checkout.block.render' } }));
jest.spyOn(Shopify, "useApi").mockImplementation(() => ({
extension: { target: "purchase.checkout.block.render" },
}));

describe('Header', () => {
it('renders the header', () => {
const app = mount((root) => {
createRoot(root).render(<Extension />)
})
describe("Extension", () => {
it("renders the welcome text", () => {
const app = mount((root) => {
createRoot(root).render(<Extension />);
});

expect(app).toContainRemoteText('welcome');
})
})
expect(app).toContainRemoteText("welcome");
});
});
4 changes: 2 additions & 2 deletions extensions/checkout-ui-2/src/Checkout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
reactExtension,
Banner,
BlockStack,
Text,
reactExtension,
useApi,
useTranslate,
} from "@shopify/ui-extensions-react/checkout";
Expand All @@ -24,4 +24,4 @@ export function Extension() {
</Banner>
</BlockStack>
);
}
}
12 changes: 6 additions & 6 deletions extensions/checkout-ui/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
presets: [
'@babel/preset-env',
['@babel/preset-react', {runtime: 'automatic'}],
"@babel/preset-typescript",
],
};
presets: [
"@babel/preset-env",
["@babel/preset-react", { runtime: "automatic" }],
"@babel/preset-typescript",
],
};
5 changes: 2 additions & 3 deletions extensions/checkout-ui/src/Checkout.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
reactExtension,
Banner,
BlockStack,
Text,
reactExtension,
useApi,
useTranslate,
} from "@shopify/ui-extensions-react/checkout";
Expand All @@ -15,7 +15,6 @@ export function Extension() {
const translate = useTranslate();
const { extension } = useApi();

// 3. Render a UI
return (
<BlockStack border={"dotted"} padding={"tight"}>
<Banner title="checkout-ui">
Expand All @@ -25,4 +24,4 @@ export function Extension() {
</Banner>
</BlockStack>
);
}
}
44 changes: 23 additions & 21 deletions extensions/checkout-ui/src/Checkout.test.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import { mount } from '@remote-ui/testing'
import { createRoot } from '@remote-ui/react'
import { Extension } from './Checkout'
import * as Shopify from '@shopify/ui-extensions-react/checkout';
import '@remote-ui/testing/matchers';
import { createRoot } from "@remote-ui/react";
import { mount } from "@remote-ui/testing";
import * as Shopify from "@shopify/ui-extensions-react/checkout";
import { Extension } from "./Checkout";
import "@remote-ui/testing/matchers";

jest.mock('@shopify/ui-extensions-react/checkout', () => {
return {
__esModule: true,
...jest.requireActual('@shopify/ui-extensions-react/checkout'),
};
jest.mock("@shopify/ui-extensions-react/checkout", () => {
return {
__esModule: true,
...jest.requireActual("@shopify/ui-extensions-react/checkout"),
};
});

jest
.spyOn(Shopify, 'useTranslate')
.mockImplementation(() => (translationKey) => translationKey);
.spyOn(Shopify, "useTranslate")
.mockImplementation(() => (translationKey) => translationKey);

jest.spyOn(Shopify, 'useApi').mockImplementation(() => ({ extension: { target: 'purchase.checkout.block.render' } }));
jest.spyOn(Shopify, "useApi").mockImplementation(() => ({
extension: { target: "purchase.checkout.block.render" },
}));

describe('Header', () => {
it('renders the header', () => {
const app = mount((root) => {
createRoot(root).render(<Extension />)
})
describe("Extension", () => {
it("renders the welcome text", () => {
const app = mount((root) => {
createRoot(root).render(<Extension />);
});

expect(app).toContainRemoteText('welcome');
})
})
expect(app).toContainRemoteText("welcome");
});
});
158 changes: 158 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 79850dc

Please sign in to comment.