Skip to content

Commit

Permalink
feat: initial commit with work component
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Mangabeira Gregio committed Aug 7, 2022
1 parent 223f840 commit f953408
Show file tree
Hide file tree
Showing 38 changed files with 7,766 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/
dist/
coverage/
public/
.eslintrc.js
jest.setup.ts
ci-scripts
46 changes: 46 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
ignorePatterns: ['**/*.config.js', '**/*.config.ts'],
plugins: ['@typescript-eslint', 'prettier', 'import'],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {},
},
},
env: {
browser: true,
jest: true,
},
rules: {
'prettier/prettier': 'error',
'no-console': 'error',
'import/prefer-default-export': 0,
'import/no-extraneous-dependencies': [
2,
{
devDependencies: [
'**/*.test.*',
'**/*.spec.*',
'jest.setup.ts',
'**/mocks/*',
],
},
],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
classes: false,
variables: true,
},
],
},
}
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Purpose

_Describe what you are trying to accomplish_

## Approach and changes

_Describe how you solved the problem_

## Definition of done

- [ ] Unit tests
- [ ] Documentation

## Jira

_https://creditas.atlassian.net/browse/CARD-NUMBER_
143 changes: 143 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

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"

npx --no-install 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"

npx --no-install pretty-quick --staged
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.gitignore
.prettierignore
LICENSE
coverage
public
dist
package-lock.json
pnpm-lock.yaml
yarn.lock
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version-git-message "[skip ci] v%s"
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @gregio/google-optimize

Library too integrate with google optimize

## Test environment

We use swc to run jest tests bacause this improve speed

> Ref: https://miyauchi.dev/posts/speeding-up-jest/
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
testEnvironment: 'jest-environment-jsdom',
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest'],
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
}
71 changes: 71 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "@gregio/google-optimize",
"version": "0.0.4-development",
"repository": "git@github.com:Creditas/person-classification-frontend-sdk.git",
"author": "Guilherme Mangabeira Gregio <guilherme.gregio@creditas.com.br>",
"license": "MIT",
"scripts": {
"build": "vite build",
"semantic-release": "semantic-release",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"format": "prettier --write .",
"check-format": "prettier --check .",
"check-types": "tsc -p tsconfig.prod.json ",
"test": "cross-env NODE_ENV=test jest --passWithNoTests --colors",
"test:ci": "cross-env CI=1 yarn test --no-watch --ci --runInBand",
"test:coverage": "yarn test --coverage",
"test:watch": "yarn test --watch",
"prepare": "husky install"
},
"sideEffects": false,
"files": [
"dist"
],
"types": "./dist/main.d.ts",
"typings": "dist/main.d.ts",
"main": "./dist/google-optimize.umd.js",
"module": "./dist/google-optimize.es.js",
"exports": {
".": {
"import": "./dist/google-optimize.es.js",
"require": "./dist/google-optimize.umd.js"
}
},
"publishConfig": {
"access": "restricted"
},
"peerDependencies": {
"react": ">=16.0.0",
"react-dom": ">=16.0.0"
},
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@swc/core": "^1.2.224",
"@swc/jest": "^0.2.22",
"@types/jest": "^28.1.6",
"@types/node": "^18.6.4",
"@types/ramda": "^0.28.15",
"@types/react": "^18.0.16",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"cross-env": "^7.0.3",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.4.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-json": "^3.1.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"jest": "^28.1.3",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
"react": "^17.0.1",
"semantic-release": "^19.0.3",
"typescript": "^4.7.4",
"vite": "^3.0.4",
"vite-aliases": "^0.9.2",
"vite-plugin-dts": "^1.4.1"
},
"dependencies": {}
}
19 changes: 19 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict'

module.exports = {
arrowParens: 'avoid',
bracketSpacing: false,
endOfLine: 'lf',
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
jsxSingleQuote: false,
printWidth: 80,
proseWrap: 'always',
quoteProps: 'as-needed',
requirePragma: false,
semi: false,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
}
3 changes: 3 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
branches: ['main', {name: '[a-z-]*', prerelease: true}],
}
17 changes: 17 additions & 0 deletions src/application/experimentContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {createContext} from 'react'
import {ExperimentStatus, ExperimentResult} from '@/domain'

const defaultValue = {
experiment: {
experimentId: 'NOT_DEFINED',
experimentStatus: ExperimentStatus.INATIVE,
variant: '0',
},
activate: () => {},
}

const Context = createContext<ExperimentResult>(defaultValue)

const {Provider} = Context

export {Context, Provider}
6 changes: 6 additions & 0 deletions src/application/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './experimentContext'
export * from './useExperiment'
export * from './useExperimentActivate'
export * from './useExperimentContext'
export * from './useExperimentValue'
export * from './useExperimentVariant'
Loading

0 comments on commit f953408

Please sign in to comment.