Skip to content

Commit

Permalink
chore: initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Jul 8, 2021
1 parent 32cd421 commit e7caf41
Show file tree
Hide file tree
Showing 28 changed files with 8,697 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@commitlint/config-conventional"
]
}
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist
node_modules
coverage
.next
build
examples/vue-ts
78 changes: 78 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 10,
"ecmaFeatures": {
"jsx": true
},
"project": "tsconfig.json"
},
"extends": [
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
],
"plugins": ["jest", "@typescript-eslint/eslint-plugin", "testing-library"],
"env": {
"es6": true,
"browser": true,
"node": true
},
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-use-before-define": "off",
"no-param-reassign": "off",
"no-console": "off",
"jsx-a11y/no-autofocus": "off",
"import/prefer-default-export": "off",
"no-underscore-dangle": "off",
"no-shadow": "off",
"no-plusplus": "off",
"spaced-comment": "off",
"guard-for-in": "off",
"operator-assignment": "off",
"prefer-destructuring": "off",
"consistent-return": "off",
"no-restricted-syntax": "off",
"no-continue": "off",
"eqeqeq": "off",
"@typescript-eslint/dot-notation": "off",
"no-bitwise": "off",
"no-redeclare": "off",
"@typescript-eslint/naming-convention": "off",
"import/no-extraneous-dependencies": "off",
"@typescript-eslint/lines-between-class-members": "off",
"no-alert": "off",
"@typescript-eslint/no-shadow": "off",
"import/no-named-as-default": "off",
"prefer-object-spread": "off",
"arrow-body-style": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"default-case": "off"
},
"overrides": [
{
"files": ["*.js", "*.jsx"],
"parserOptions": {
"project": "tsconfig.eslint.json"
}
},
{
"files": ["*.test.*", "*.test.*"],
"extends": ["plugin:jest/recommended", "plugin:jest/style"],
"rules": {
"jsx-a11y/label-has-associated-control": "off",
"global-require": "off",
"no-new": "off"
}
}
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
8 changes: 8 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"**/*.{ts,tsx,js,jsx}": [
"prettier --write"
],
"**/*.{md,yml,json,babelrc,eslintrc,prettierrc}": [
"prettier --write"
]
}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
coverage
.next
build
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"bracketSpacing": true,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "always",
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all"
}
32 changes: 32 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const BABEL_ENV = process.env.BABEL_ENV
const isCommonJS = BABEL_ENV !== undefined && BABEL_ENV === "cjs"
const isESM = BABEL_ENV !== undefined && BABEL_ENV === "esm"

module.exports = function babelConfig(api) {
api.cache(true)

const presets = [
[
"@babel/env",
{
loose: true,
modules: isCommonJS ? "commonjs" : false,
targets: {
node: "current",
esmodules: isESM ? true : undefined,
},
},
],
"@babel/preset-typescript",
]

const plugins = [
["@babel/plugin-proposal-private-methods", { loose: false }],
"@babel/plugin-proposal-class-properties",
]

return {
presets,
plugins,
}
}
21 changes: 21 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest/dist",
},
transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"],
setupFilesAfterEnv: ["@testing-library/jest-dom/extend-expect"],
globals: {
"ts-jest": {
tsconfig: "tsconfig.json",
},
},
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
],
collectCoverageFrom: ["**/src/**/*.(ts|tsx)"],
modulePathIgnorePatterns: ["dist"],
}
89 changes: 89 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"name": "ui-machines",
"private": true,
"description": "Chakra UI Core mono repo root package",
"repository": {
"type": "git",
"url": "git+https://github.com/chakra-ui/core.git"
},
"author": "Segun Adebayo <sage@adebayosegun.com>",
"license": "MIT",
"scripts": {
"build": "preconstruct build",
"clean": "yarn workspaces run clean",
"fix:pkgs": "manypkg fix",
"fix:preconstruct": "preconstruct fix",
"gen:pkg": "ts-node scripts/generate-package.ts",
"gen:machine": "ts-node scripts/generate-machine.ts",
"lint": "npm-run-all lint:**",
"lint:code": "eslint . --ext .js,.jsx,.ts,.tsx -c .eslintrc",
"lint:pkgs": "manypkg check",
"lint:types": "tsc --noEmit --incremental",
"lint:validate": "preconstruct validate",
"pkg": "manypkg run",
"prebuild": "yarn clean",
"prepare": "npm-run-all -s prepare:**",
"prepare:husky": "husky install",
"prepare:preconstruct": "preconstruct dev",
"release": "changeset publish",
"start": "preconstruct watch",
"test": "jest --maxWorkers=50%",
"test:ci": "jest --runInBand"
},
"dependencies": {
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/eslint-parser": "^7.14.2",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-transform-runtime": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"@babel/preset-typescript": "^7.13.0",
"@babel/runtime": "^7.14.0",
"@changesets/changelog-github": "^0.4.0",
"@changesets/cli": "^2.16.0",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@manypkg/cli": "^0.17.0",
"@preconstruct/cli": "^2.1.0",
"@testing-library/jest-dom": "^5.12.0",
"@types/form-serialize": "^0.7.1",
"@types/jest": "^26.0.23",
"@types/lodash": "^4.14.169",
"@types/shelljs": "^0.8.8",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"commitlint": "^12.1.4",
"eslint": "^7.26.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.2",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-testing-library": "^4.4.0",
"form-serialize": "^0.7.2",
"husky": "^6.0.0",
"jest": "^26.6.3",
"jest-environment-jsdom": "^26.6.2",
"jest-watch-typeahead": "^0.6.3",
"lint-staged": "^11.0.0",
"lodash": "^4.17.21",
"node-plop": "^0.26.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.4",
"ts-jest": "^26.5.6",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
},
"preconstruct": {
"packages": [
"packages/*"
]
},
"workspaces": [
"core/*",
"machines/*",
"examples/*"
]
}
Empty file added packages/core/.gitkeep
Empty file.
Empty file added packages/machines/.gitkeep
Empty file.
Empty file added packages/utilities/.gitkeep
Empty file.
24 changes: 24 additions & 0 deletions plop-templates/machine-template/README.md.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @chakra-ui/{{packageName}}

A Quick description of the package

> This is an internal utility, not intended for public usage.

## Installation

```sh
yarn add @chakra-ui/{{packageName}}
# or
npm i @chakra-ui/{{packageName}}
```

## Contribution

Yes please! See the
[contributing guidelines](https://github.com/chakra-ui/core/blob/main/CONTRIBUTING.md)
for details.

## Licence

This project is licensed under the terms of the
[MIT license](https://github.com/chakra-ui/core/blob/main/LICENSE).
31 changes: 31 additions & 0 deletions plop-templates/machine-template/package.json.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@ui-machines/{{packageName}}",
"version": "1.0.0",
"description": "{{description}}",
"keywords": ["ui-machines", "state-machine", "statecharts", "xstate", "{{machine}}"],
"author": "Segun Adebayo <sage@adebayosegun.com>",
"homepage": "https://github.com/ui-machines/core#readme",
"license": "MIT",
"main": "dist/ui-machines-{{packageName}}.cjs.js",
"module": "dist/ui-machines-{{packageName}}.esm.js",
"repository": "https://github.com/ui-machines/core/tree/main/packages/{{packageName}}",
"sideEffects": false,
"exports": {
".": {
"require": "./dist/ui-machines-{{packageName}}.cjs.js",
"default": "./dist/ui-machines-{{packageName}}.esm.js"
}
},
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"bugs": {
"url": "https://github.com/ui-machines/core/issues"
},
"scripts": {
"clean": "rimraf dist"
}
}
2 changes: 2 additions & 0 deletions plop-templates/machine-template/src/index.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./{{machine}}.connect"
export * from "./{{machine}}.machine"
22 changes: 22 additions & 0 deletions plop-templates/machine-template/src/{{machine}}.connect.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {
defaultPropNormalizer,
PropNormalizer,
StateMachine as S,
} from "@chakra-ui/machine"
import { DOMHTMLProps } from "../type-utils"
import { getElementIds, getElements } from "./{{machine}}.dom"
import { {{capitalize machine}}MachineContext, {{capitalize machine}}MachineState } from "./{{machine}}.machine"

export function connect{{capitalize machine}}Machine(
state: S.State<{{capitalize machine}}MachineContext, {{capitalize machine}}MachineState>,
send: (event: S.Event<S.AnyEventObject>) => void,
normalize: PropNormalizer = defaultPropNormalizer,
) {
const { context: ctx } = state
const ids = getElementIds(ctx.uid)

return {
elProps: normalize<DOMHTMLProps>({
}),
}
}
16 changes: 16 additions & 0 deletions plop-templates/machine-template/src/{{machine}}.dom.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { {{capitalize machine}}MachineContext } from "./{{machine}}.machine"

export function getElementIds(uid: string) {
return {

}
}

export function getElements(ctx: {{capitalize machine}}MachineContext) {
const doc = ctx.doc ?? document
const ids = getElementIds(ctx.uid)

return {

}
}
Loading

0 comments on commit e7caf41

Please sign in to comment.