Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- "11"
- '11'
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"source": "src/rehook/index.js",
"types": "dist/rehook.d.ts",
"devDependencies": {
"@otris/jsdoc-tsd": "^1.0.4",
"babel-eslint": "9.0.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
Expand All @@ -31,10 +30,14 @@
"react-scripts": "2.1.0",
"rollup": "^0.67.1",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-cleaner": "^0.2.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-copy": "^0.2.3",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-uglify": "^6.0.0"
"rollup-plugin-uglify": "^6.0.0",
"tslint": "^5.11.0",
"tslint-config-airbnb": "^5.11.1"
},
"peerDependencies": {
"react": "^16.7.0-alpha.0",
Expand All @@ -44,12 +47,12 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test:eslint": "eslint src --fix",
"test:tslint": "tslint src/rehook/index.d.ts --project tsconfig.json --fix",
"test:jest": "react-scripts test",
"test": "CI=true npm run test:eslint && CI=true npm run test:jest --findRelatedTests",
"test": "CI=true npm run test:eslint && CI=true npm run test:tslint && CI=true npm run test:jest --findRelatedTests",
"eject": "react-scripts eject",
"build:bundle": "NODE_ENV='production' rollup --config rollup.config.js",
"build:types": "jsdoc -t node_modules/@otris/jsdoc-tsd -r ./src/rehook -d dist/rehook.d.ts",
"prepublish": "npm run build:bundle && npm run build:types"
"prepublish": "npm run build:bundle"
},
"browserslist": [
">0.2%",
Expand Down
17 changes: 13 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import replace from 'rollup-plugin-replace';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import copy from 'rollup-plugin-copy'
import cleaner from 'rollup-plugin-cleaner'

export default [
{
input: './src/rehook/index.js',
external: ['react', 'react-dom'],
plugins: [
cleaner({
targets: ['dist'],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
Expand All @@ -19,6 +24,10 @@ export default [
exclude: 'node_modules/**',
runtimeHelpers: true,
}),
copy({
'src/rehook/index.d.ts': 'dist/rehook.d.ts',
verbose: true,
}),
],
output: [
{
Expand Down
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
148 changes: 148 additions & 0 deletions src/rehook/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/**
*
* @param condition
* @param left
* @param right
* @returns
*/
export function branch(
condition: Function,
left: Function,
right: Function
): Function

/**
*
* @param component
* @returns
*/
export function catchRender(component: Function): Object

/**
*
* @param defaultProps
* @returns
*/
export function defaultProps(defaultProps: Object): Object

/**
*
* @param propName
* @returns
*/
export function flattenProp(propName: string | symbol): Object

/**
*
* @param spec
* @returns
*/
export function lifecycle(spec: Object): Object

/**
*
* @param fn
* @returns
*/
export function mapProps(fn: Function): Object

/**
*
* @param propName
* @param enhance
* @returns
*/
export function namespace(propName: string | symbol, enhance: Function): Object

/**
*
* @param fns
* @returns
*/
export function pipe(...fns: Function): Object

/**
*
* @param a
* @param b
* @returns
*/
export function renameProp(a: string | symbol, b: string | symbol): Object

/**
*
* @param propMap
* @returns
*/
export function renameProps(propMap: Object): Object

/**
*
* @param comp
* @returns
*/
export function renderComponent(comp: any): Object

/**
*
* @returns
*/
export function renderNothing(): Object

/**
*
* @param handlers
* @returns
*/
export function withHandlers(handlers: Object): Object

/**
*
* @param shouldMapOrKeys
* @param createProps
* @returns
*/
export function withPropsOnChange(
shouldMapOrKeys: any,
createProps: Function
): Object

/**
*
* @param fn
*/
export function withProps(fn: object | ((props: object) => object)): (props: object) => { [key: string]: string }

/**
*
* @param stateName
* @param dispatchName
* @param reducer
* @param initialValue
*/
export function withReducer(
stateName: string | symbol,
dispatchName: string | symbol,
reducer: Function,
initialValue: any
): void

/**
*
* @param initialValue
* @param handlers
* @returns
*/
export function withStateHandlers(initialValue: any, handlers: Object): Object

/**
*
* @param stateName
* @param stateUpdaterName
* @param initialState
*/
export function withState(
stateName: string | symbol,
stateUpdaterName: string | symbol,
initialState: any
): void
2 changes: 1 addition & 1 deletion src/rehook/render-nothing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
const renderNothing = (/* props */) => {
// eslint-disable-next-line
throw null;
throw null
}

export default renderNothing
18 changes: 18 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es5",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
},
"include": ["src"]
}
18 changes: 18 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": [
"tslint:latest"
],
"rules": {
"semicolon": [
true,
"never"
],
"ban-types": [
false
],
"trailing-comma": [
true,
"never"
]
}
}