Skip to content

Commit

Permalink
Merge pull request #4 from zolplay-cn/cali
Browse files Browse the repository at this point in the history
Add cva and config packages
  • Loading branch information
CaliCastle committed Oct 19, 2022
2 parents d7fe3d1 + 34b0b53 commit 467bd8c
Show file tree
Hide file tree
Showing 28 changed files with 2,972 additions and 137 deletions.
39 changes: 39 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pnpm-lock.yaml

# changeset
.changeset/

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# next.js
.next
.next/
out/

# production
build
dist

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.*

# vercel
.vercel

README.md
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./packages/config/prettier/preset')
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"release": "pnpm run build && changeset version && changeset publish"
},
"devDependencies": {
"eslint": "^8.21.0",
"jest": "^29.2.1",
"prettier": "latest",
"tsup": "^6.3.0",
"turbo": "latest",
Expand Down
7 changes: 7 additions & 0 deletions packages/config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @zolplay/config

## 0.1.0

### Minor Changes

- Formatted code
94 changes: 94 additions & 0 deletions packages/config/eslint/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
globals: {
React: true,
JSX: true,
},
extends: [
'eslint:recommended',
'next',
'next/core-web-vitals',
'plugin:@typescript-eslint/recommended',
'prettier',
],
plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports'],
settings: {
next: {
rootDir: ['apps/*/', 'packages/*/'],
},
},
rules: {
'@next/next/no-html-link-for-pages': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'react/display-name': 'off',
'react/jsx-key': 'off',
'no-unused-vars': 'off',
'no-console': 'off',

//#region //*=========== Unused Import ===========
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'warn',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
//#endregion //*======== Unused Import ===========

//#region //*=========== Import Sort ===========
'simple-import-sort/exports': 'warn',
'simple-import-sort/imports': [
'warn',
{
groups: [
// ext library & side effect imports
['^~?\\w', '^\\u0000'],
// {s}css files
['^.+\\.s?css$'],
// Lib and hooks
['^~/lib', '^~/hooks'],
// components
['^~/components', '^~/container'],
// zustand store
['^~/store'],
// Other imports
['^~/'],
// relative paths up until 3 level
[
'^\\./?$',
'^\\.(?!/?$)',
'^\\.\\./?$',
'^\\.\\.(?!/?$)',
'^\\.\\./\\.\\./?$',
'^\\.\\./\\.\\.(?!/?$)',
'^\\.\\./\\.\\./\\.\\./?$',
'^\\.\\./\\.\\./\\.\\.(?!/?$)',
],
['^~/types'],
// other that didn't fit in
['^'],
],
},
],
//#endregion //*======== Import Sort ===========
},
ignorePatterns: [
'**/*.js',
'**/*.json',
'node_modules',
'public',
'styles',
'.next',
'coverage',
'dist',
'.turbo',
],
}
56 changes: 56 additions & 0 deletions packages/config/eslint/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'no-unused-vars': 'off',
'no-console': 'off',

//#region //*=========== Unused Import ===========
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'warn',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
//#endregion //*======== Unused Import ===========

//#region //*=========== Import Sort ===========
'simple-import-sort/exports': 'warn',
'simple-import-sort/imports': [
'warn',
{
groups: [
// ext library & side effect imports
['^~?\\w', '^\\u0000'],
// Other imports
['^~/'],
// relative paths up until 3 level
[
'^\\./?$',
'^\\.(?!/?$)',
'^\\.\\./?$',
'^\\.\\.(?!/?$)',
'^\\.\\./\\.\\./?$',
'^\\.\\./\\.\\.(?!/?$)',
'^\\.\\./\\.\\./\\.\\./?$',
'^\\.\\./\\.\\./\\.\\.(?!/?$)',
],
['^~/types'],
// other that didn't fit in
['^'],
],
},
],
//#endregion //*======== Import Sort ===========
},
}
17 changes: 17 additions & 0 deletions packages/config/jest/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
...require('./preset'),
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['@testing-library/jest-dom'],
collectCoverageFrom: [
'**/*.{js,ts,jsx,tsx}',
'!**/*.d.ts',
'!**/node_modules/**',
],
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
transform: {
'^.+\\.tsx?$': 'esbuild-jest',
'^.+\\.jsx?$': 'esbuild-jest',
},
coveragePathIgnorePatterns: [],
coverageThreshold: null,
}
4 changes: 4 additions & 0 deletions packages/config/jest/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
resetMocks: true,
moduleDirectories: ['node_modules'],
}
29 changes: 29 additions & 0 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@zolplay/config",
"version": "0.1.0",
"main": "index.js",
"license": "MIT",
"files": [
"eslint",
"jest",
"postcss",
"prettier"
],
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"eslint": "^8.21.0",
"eslint-config-next": "^12.2.4",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"prettier": "^2.5.1",
"typescript": "^4.8.4"
},
"peerDependencies": {
"next": "^12.0.0",
"react": "^17.0.2||^18.0.0",
"react-dom": "^17.0.2||^18.0.0"
}
}
7 changes: 7 additions & 0 deletions packages/config/postcss/tailwind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
plugins: {
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {},
},
}
4 changes: 4 additions & 0 deletions packages/config/prettier/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
...require('./preset'),
plugins: [require('prettier-plugin-tailwindcss')],
}
9 changes: 9 additions & 0 deletions packages/config/prettier/preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
arrowParens: 'always',
semi: false,
trailingComma: 'es5',
singleQuote: true,
jsxSingleQuote: false,
tabWidth: 2,
useTabs: false,
}
1 change: 1 addition & 0 deletions packages/cva/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@zolplay/config/eslint/preset')
7 changes: 7 additions & 0 deletions packages/cva/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @zolplay/cva

## 0.1.0

### Minor Changes

- Formatted code
9 changes: 9 additions & 0 deletions packages/cva/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @zolplay/cva

[![npm version](https://badge.fury.io/js/%40zolplay%2Fcva.svg)](https://badge.fury.io/js/%40zolplay%2Fcva)

An adapter for the awesome original package `class-variance-authority`.

CSS-in-TS libraries such as [Stitches](https://stitches.dev/docs/variants) and [Vanilla Extract](https://vanilla-extract.style/documentation/) are **fantastic** options for building type-safe UI components; taking away all the worries of class names and StyleSheet composition.

`cva` aims to take those pain points away, allowing you to focus on the more fun aspects of UI development.
38 changes: 38 additions & 0 deletions packages/cva/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@zolplay/cva",
"version": "0.1.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"license": "MIT",
"files": [
"dist"
],
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "pnpm run build --watch",
"lint": "eslint *.ts*"
},
"devDependencies": {
"@zolplay/config": "workspace:*",
"@zolplay/tsconfig": "workspace:*",
"typescript": "^4.8.4"
},
"dependencies": {
"class-variance-authority": "^0.2.4"
},
"repository": {
"type": "git",
"url": "git+https://github.com/zolplay-cn/core.git"
},
"keywords": [
"utils",
"cva",
"class-variance-authority"
],
"author": "Cali Castle",
"bugs": {
"url": "https://github.com/zolplay-cn/core/issues"
},
"homepage": "https://github.com/zolplay-cn/core#readme"
}
2 changes: 2 additions & 0 deletions packages/cva/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { VariantProps } from 'class-variance-authority'
export { cva } from 'class-variance-authority'
6 changes: 6 additions & 0 deletions packages/cva/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "@zolplay/tsconfig/public-base.json",
"compilerOptions": {
"target": "ESNext"
}
}
7 changes: 7 additions & 0 deletions packages/tsconfig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @zolplay/tsconfig

## 0.1.0

### Minor Changes

- Formatted code
11 changes: 7 additions & 4 deletions packages/tsconfig/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "tsconfig",
"version": "0.0.0",
"private": true,
"name": "@zolplay/tsconfig",
"version": "0.1.0",
"license": "MIT",
"files": [
"base.json",
"nextjs.json",
"react-library.json",
"public-base.json"
]
],
"peerDependencies": {
"typescript": "^4.5.0"
}
}
1 change: 1 addition & 0 deletions packages/utils/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@zolplay/config/eslint/preset')
6 changes: 6 additions & 0 deletions packages/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @zolplay/utils

## 1.1.2

### Patch Changes

- Formatted code

## 1.1.1

### Patch Changes
Expand Down
Loading

0 comments on commit 467bd8c

Please sign in to comment.