Skip to content

Commit

Permalink
CI/GitHub test workflow (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
trinhthinh388 authored Jan 27, 2024
1 parent 88e7086 commit 6658e64
Show file tree
Hide file tree
Showing 36 changed files with 308 additions and 229 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lint

on:
pull_request:
branches:
- 'master'
- 'release'
push:
branches:
- 'master'
- 'release'

permissions:
actions: write
contents: read

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 18.17.x

- name: 📥 Download deps
run: yarn install --frozen-lockfile

- name: 🔬 Lint
run: yarn lint
44 changes: 0 additions & 44 deletions .github/workflows/release.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test

on:
pull_request:
branches:
- 'master'
- 'release'
push:
branches:
- 'master'
- 'release'

permissions:
actions: write
contents: read

jobs:
unit-test:
name: ʦ Vitest
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0

- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 18.17.x

- name: 📥 Download deps
run: yarn install --frozen-lockfile

- name: 🔎 Type check
run: yarn test
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yarn test

yarn format
12 changes: 6 additions & 6 deletions apps/docs/src/components/examples/PhoneInput/Default.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useState } from 'react';
import { useState } from "react";
import {
PhoneInput,
PhoneInputChangeMetadata,
} from '@react-awesome/phone-input';
} from "@react-awesome/phone-input";

export const DefaultPhoneInput = (props: any) => {
const [value, setValue] = useState<PhoneInputChangeMetadata>({
isPossible: false,
isValid: false,
e164Value: '',
country: 'VN',
phoneCode: '84',
formattedValue: '',
e164Value: "",
country: "VN",
phoneCode: "84",
formattedValue: "",
isSupported: true,
});

Expand Down
14 changes: 7 additions & 7 deletions apps/docs/src/components/examples/PhoneInput/SupportCountry.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useState } from 'react';
import { useState } from "react";
import {
PhoneInput,
PhoneInputChangeMetadata,
} from '@react-awesome/phone-input';
} from "@react-awesome/phone-input";

export const SupportCountryPhoneInput = () => {
const [value, setValue] = useState<PhoneInputChangeMetadata>({
isPossible: false,
isValid: false,
e164Value: '',
country: 'VN',
phoneCode: '84',
formattedValue: '',
e164Value: "",
country: "VN",
phoneCode: "84",
formattedValue: "",
isSupported: true,
});

Expand All @@ -24,7 +24,7 @@ export const SupportCountryPhoneInput = () => {
}}
value={value?.formattedValue}
defaultCountry={value.country}
supportedCountries={['US', 'CA', 'VN']}
supportedCountries={["US", "CA", "VN"]}
/>

<h3 className="mt-3 font-bold text-xl underline underline-offset-4">
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/src/components/examples/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './PhoneInput/Default';
export * from './PhoneInput/SupportCountry';
export * from "./PhoneInput/Default";
export * from "./PhoneInput/SupportCountry";
8 changes: 4 additions & 4 deletions apps/docs/src/components/pages/LandingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from 'next/link';
import { ArrowRight, Code2, Rabbit, Feather, Server } from 'lucide-react';
import Link from "next/link";
import { ArrowRight, Code2, Rabbit, Feather, Server } from "lucide-react";

const Card = ({
title,
Expand Down Expand Up @@ -27,10 +27,10 @@ export const LandingPage = () => {
<div className="mx-auto max-w-[900px] px-4 sm:px-8 xl:px-0 relative z-1">
<div className="text-center">
<h1 className="mb-6 text-4xl font-extrabold sm:text-6xl xl:text-heading-1">
A collection of{' '}
A collection of{" "}
<span className="bg-gradient-to-r from-blue-600 via-green-500 to-indigo-400 inline-block text-transparent bg-clip-text">
Awesome
</span>{' '}
</span>{" "}
React components and hooks.
</h1>
<p className="max-w-[600px] mx-auto mb-9 md:text-lg">
Expand Down
22 changes: 11 additions & 11 deletions apps/docs/theme.config.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useRouter } from 'next/router';
import { useConfig } from 'nextra-theme-docs';
import React from "react";
import { useRouter } from "next/router";
import { useConfig } from "nextra-theme-docs";

const logo = (
<svg
Expand Down Expand Up @@ -35,21 +35,21 @@ const logo = (
export default {
logo,
project: {
link: 'https://github.com/trinhthinh388/react-awesome-components',
link: "https://github.com/trinhthinh388/react-awesome-components",
},
docsRepositoryBase:
'https://github.com/trinhthinh388/react-awesome-components/blob/master/apps/docs',
"https://github.com/trinhthinh388/react-awesome-components/blob/master/apps/docs",
useNextSeoProps() {
const { asPath } = useRouter();
if (asPath !== '/') {
if (asPath !== "/") {
return {
titleTemplate: '%s – React Awesome Components',
titleTemplate: "%s – React Awesome Components",
};
}
},
sidebar: {
titleComponent({ title, type }) {
if (type === 'separator') {
if (type === "separator") {
return <span className="cursor-default">{title}</span>;
}
return <>{title}</>;
Expand Down Expand Up @@ -89,7 +89,7 @@ export default {
},
head: function useHead() {
const { title } = useConfig();
const socialCard = 'https://react-awesome-components.vercel.app/og.svg';
const socialCard = "https://react-awesome-components.vercel.app/og.svg";

return (
<>
Expand Down Expand Up @@ -119,8 +119,8 @@ export default {
name="og:title"
content={
title
? title + ' – React Awesome Components'
: 'React Awesome Components'
? title + " – React Awesome Components"
: "React Awesome Components"
}
/>
<meta name="og:image" content={socialCard} />
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
"dev": "turbo dev",
"lint": "turbo lint",
"test": "turbo test",
"typecheck": "turbo typecheck",
"clean": "turbo clean && rimraf node_modules",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"format:fix": "prettier --write \"**/*.{ts,tsx,md}\"",
"changeset": "changeset",
"version-packages": "changeset version",
"release": "turbo build --filter=docs^... && changeset publish",
"docs": "yarn workspace @react-awesome/docs",
"phone-input": "yarn workspace @react-awesome/phone-input",
"hooks": "yarn workspace @react-awesome/hooks",
"eslint": "yarn workspace @react-awesome/eslint-config"
"eslint": "yarn workspace @react-awesome/eslint-config",
"prepare": "husky"
},
"devDependencies": {
"@changesets/cli": "2.26.2",
Expand All @@ -25,6 +28,7 @@
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.56.0",
"husky": "^9.0.6",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"tty-table": "^4.2.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/declaration.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module '*.scss';
declare module "*.scss";
3 changes: 1 addition & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"build": "vite --config ../../vite.config.ts build",
"dev": "vite --watch --config ../../vite.config.ts build",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rimraf .turbo && rimraf node_modules && rimraf dist",
"test": "vitest --config ../../vite.config.ts --coverage"
"clean": "rimraf .turbo && rimraf node_modules && rimraf dist"
},
"devDependencies": {
"@react-awesome/eslint-config": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from '@react-awesome/phone-input'
export * from '@react-awesome/hooks'
export * from "@react-awesome/phone-input";

Check warning on line 1 in packages/components/src/index.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Definition for rule '@typescript-eslint/no-unused-vars' was not found
export * from "@react-awesome/hooks";
3 changes: 2 additions & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"build": "vite --config ../../vite.config.ts build",
"dev": "vite --watch --config ../../vite.config.ts build",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rimraf .turbo && rimraf node_modules && rimraf dist"
"clean": "rimraf .turbo && rimraf node_modules && rimraf dist",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@react-awesome/eslint-config": "*",
Expand Down
10 changes: 5 additions & 5 deletions packages/hooks/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';
export { usePrevious } from './usePrevious/usePrevious';
export { useSelectionRange } from './useSelectionRange/useSelectionRange';
export { usePreserveInputCaretPosition } from './usePreserveInputCaretPosition/usePreserveInputCaretPosition';
export { useClickOutside } from './useClickOutside/useClickOutside';
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect/useIsomorphicLayoutEffect";

Check warning on line 1 in packages/hooks/src/index.ts

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Definition for rule '@typescript-eslint/no-unused-vars' was not found
export { usePrevious } from "./usePrevious/usePrevious";
export { useSelectionRange } from "./useSelectionRange/useSelectionRange";
export { usePreserveInputCaretPosition } from "./usePreserveInputCaretPosition/usePreserveInputCaretPosition";
export { useClickOutside } from "./useClickOutside/useClickOutside";
8 changes: 4 additions & 4 deletions packages/hooks/src/useClickOutside/useClickOutside.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect } from 'react';
import { useEffect } from "react";

Check warning on line 1 in packages/hooks/src/useClickOutside/useClickOutside.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint

Definition for rule '@typescript-eslint/no-unused-vars' was not found

export const useClickOutside = (
el: HTMLElement | null,
callback?: (event: MouseEvent) => any
callback?: (event: MouseEvent) => any,
) => {
useEffect(() => {
if (!callback) return;
Expand All @@ -11,10 +11,10 @@ export const useClickOutside = (
callback(e);
}
};
window.document.addEventListener('click', check);
window.document.addEventListener("click", check);

return () => {
window.document.removeEventListener('click', check);
window.document.removeEventListener("click", check);
};
}, [callback, el]);
};
Loading

0 comments on commit 6658e64

Please sign in to comment.