Skip to content

Commit

Permalink
feat: setup typescript check, prettier, eslint, conventional commits,…
Browse files Browse the repository at this point in the history
… prevent push to main branch (#8)
  • Loading branch information
ahmadshaheer authored Oct 23, 2024
1 parent aac0a6f commit f98f94f
Show file tree
Hide file tree
Showing 15 changed files with 2,008 additions and 117 deletions.
12 changes: 12 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pnpm commitlint --edit $1

branch="$(git rev-parse --abbrev-ref HEAD)"

color_red="$(tput setaf 1)"
bold="$(tput bold)"
reset="$(tput sgr0)"

if [ "$branch" = "main" ]; then
echo "${color_red}${bold}You can't commit directly to the main branch${reset}"
exit 1
fi
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
public
build
dist
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
trailingComma: 'all',
useTabs: true,
tabWidth: 1,
singleQuote: true,
jsxSingleQuote: false,
semi: true,
};
71 changes: 36 additions & 35 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
{
"name": "docs",
"version": "0.1.18",
"type": "module",
"private": true,
"scripts": {
"dev": "storybook dev -p 6006",
"build": "storybook build --docs",
"preview-storybook": "serve storybook-static",
"clean": "rm -rf .turbo && rm -rf node_modules",
"lint": "eslint ./stories/*.stories.tsx --max-warnings 0"
},
"dependencies": {
"@signozhq/button": "workspace:*",
"@signozhq/input": "workspace:*",
"@signozhq/tailwind-config": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^1",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@storybook/addon-actions": "^8.3.3",
"@storybook/addon-designs": "^8.0.3",
"@storybook/addon-essentials": "^8.3.3",
"@storybook/addon-links": "^8.3.3",
"@storybook/react": "^8.3.3",
"@storybook/react-vite": "^8.3.3",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^9.11.0",
"serve": "^14.2.1",
"storybook": "^8.3.3",
"typescript": "^5.3.3",
"vite": "^5.1.4"
}
"name": "docs",
"version": "0.1.18",
"type": "module",
"private": true,
"scripts": {
"dev": "storybook dev -p 6006",
"build": "storybook build --docs",
"preview-storybook": "serve storybook-static",
"clean": "rm -rf .turbo && rm -rf node_modules",
"lint": "eslint ./stories/*.stories.tsx --max-warnings 0"
},
"dependencies": {
"@signozhq/button": "workspace:*",
"@signozhq/input": "workspace:*",
"@signozhq/tailwind-config": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^1",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@storybook/addon-actions": "^8.3.3",
"@storybook/addon-designs": "^8.0.3",
"@storybook/addon-essentials": "^8.3.3",
"@storybook/addon-links": "^8.3.3",
"@storybook/react": "^8.3.3",
"@storybook/react-vite": "^8.3.3",
"@types/react": "^18.3.11",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^9.11.0",
"serve": "^14.2.1",
"storybook": "^8.3.3",
"typescript": "^5.3.3",
"vite": "^5.1.4"
}
}
6 changes: 3 additions & 3 deletions apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@repo/typescript-config/react-app.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
"extends": "@repo/typescript-config/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}
35 changes: 18 additions & 17 deletions apps/packages-playground/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
import { ThemeProvider, useTheme } from "@signozhq/theme";
import React from 'react';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import './index.css';
import { ThemeProvider, useTheme } from '@signozhq/theme';

function ThemedApp() {
const { theme } = useTheme();
const { theme } = useTheme();

return (
<div className={`app ${theme}`}>
<App />
</div>
);
return (
<div className={`app ${theme}`}>
<App />
</div>
);
}

createRoot(document.getElementById("root")!).render(
<StrictMode>
<ThemeProvider>
<ThemedApp />
</ThemeProvider>
</StrictMode>
createRoot(document.getElementById('root')!).render(
<StrictMode>
<ThemeProvider>
<ThemedApp />
</ThemeProvider>
</StrictMode>,
);
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { extends: ['@commitlint/config-conventional'] };
22 changes: 22 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';

export default [
{
ignores: [
'dist',
'node_modules',
'packages/**/dist',
'apps/**/dist',
'packages/**/node_modules',
'apps/**/node_modules',
],
},
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
];
67 changes: 47 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,49 @@
{
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"lint": "turbo run lint",
"clean": "turbo run clean && rm -rf node_modules",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"changeset": "changeset",
"version-packages": "changeset version",
"update-version": "changeset && changeset version",
"release": "turbo run build --filter=docs^... && changeset publish"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"inquirer": "^11.0.2",
"prettier": "^3.2.5",
"turbo": "^2.1.2"
},
"packageManager": "[email protected]",
"name": "design-system"
"private": true,
"type": "module",
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"lint": "turbo run lint",
"clean": "turbo run clean && rm -rf node_modules",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"changeset": "changeset",
"version-packages": "changeset version",
"update-version": "changeset && changeset version",
"release": "turbo run build --filter=docs^... && changeset publish",
"prepare": "husky",
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js, jsx,ts,tsx}": [
"sh scripts/typecheck-staged.sh",
"eslint --quiet --fix",
"prettier --write"
],
"*.{json,js,ts,jsx,tsx,html}": [
"prettier --write --ignore-unknown"
]
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/js": "^9.9.0",
"@repo/typescript-config": "workspace:*",
"@turbo/gen": "^2.1.2",
"@types/fs-extra": "^11.0.4",
"eslint": "^9.11.0",
"eslint-plugin-react": "^7.37.1",
"fs-extra": "^11.2.0",
"globals": "^15.9.0",
"husky": "^9.1.6",
"inquirer": "^11.0.2",
"lint-staged": "^15.2.10",
"prettier": "^3.2.5",
"turbo": "^2.1.2",
"typescript": "^5.6.2",
"typescript-eslint": "^8.0.1"
},
"packageManager": "[email protected]",
"name": "design-system"
}
20 changes: 11 additions & 9 deletions packages/typescript-config/react-library.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "React Library",
"extends": "./base.json",
"compilerOptions": {
"jsx": "react-jsx",
"lib": ["dom", "ES2015"],
"module": "ESNext",
"target": "es6"
}
"$schema": "https://json.schemastore.org/tsconfig",
"display": "React Library",
"extends": "./base.json",
"compilerOptions": {
"jsx": "react-jsx",
"lib": ["dom", "ES2015"],
"module": "ESNext",
"target": "es6",
"noImplicitAny": true,
"noFallthroughCasesInSwitch": true
}
}
Loading

0 comments on commit f98f94f

Please sign in to comment.