Skip to content

Commit 782718e

Browse files
authored
fix: Fix build and add README (#12)
1 parent 5ed7563 commit 782718e

File tree

6 files changed

+1122
-532
lines changed

6 files changed

+1122
-532
lines changed

.babelrc.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
module.exports = api => ({
32
presets: [
43
[
5-
'@4c/4catalyzer',
4+
'@4c',
65
{
76
target: 'web',
8-
modules: api.env() === 'esm' ? false : 'commonjs'
7+
targets: {},
8+
modules: api.env() === 'esm' ? false : 'commonjs',
99
},
1010
],
11-
]
11+
],
1212
});
13-

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
!.babelrc.js
2+
13
lib/
24
es/
35
**/node_modules/**

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# @restart/context [![npm][npm-badge]][npm]
2+
3+
React context helpers.
4+
5+
## Install
6+
7+
```sh
8+
npm install @restart/context
9+
```
10+
11+
## Usage
12+
13+
```js
14+
import React from 'react';
15+
import mapContextToProps from '@restart/context/mapContextToProps';
16+
17+
const MyValueContext = React.createContext(null);
18+
19+
function MyComponent(props) {
20+
/* ... */
21+
}
22+
23+
const MyComponentWithMyValue = mapContextToProps(
24+
MyValueContext,
25+
myValue => ({ myValue }),
26+
MyComponent,
27+
);
28+
29+
const withMyValue = Component =>
30+
mapContextToProps(
31+
{
32+
consumers: MyValueContext,
33+
mapToProps: myValue => ({ myValue }),
34+
displayName: `withMyValue(${Component.displayName || Component.name})`,
35+
},
36+
Component,
37+
);
38+
```
39+
40+
[npm-badge]: https://img.shields.io/npm/v/@restart/context.svg
41+
[npm]: https://www.npmjs.org/package/@restart/context

package.json

+25-21
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
"build": "npm run build:lib && npm run build:es && cpy types/*.d.ts lib && cpy types/*.d.ts lib/es",
2121
"prepublishOnly": "yarn run build",
2222
"lint": "eslint . && prettier --list-different --ignore-path .eslintignore '**/*.{json,css,md}'",
23-
"format": "eslint . --fix && prettier --write --ignore-path .eslintignore '**/*.{json,css,md}'",
24-
"precommit": "lint-staged"
23+
"format": "eslint . --fix && prettier --write --ignore-path .eslintignore '**/*.{json,css,md}'"
2524
},
2625
"publishConfig": {
2726
"access": "public"
2827
},
29-
"prettier": {
30-
"printWidth": 79,
31-
"singleQuote": true,
32-
"trailingComma": "all"
28+
"husky": {
29+
"hooks": {
30+
"pre-commit": "lint-staged"
31+
}
3332
},
3433
"lint-staged": {
3534
"*.js": [
@@ -41,6 +40,11 @@
4140
"git add"
4241
]
4342
},
43+
"prettier": {
44+
"printWidth": 79,
45+
"singleQuote": true,
46+
"trailingComma": "all"
47+
},
4448
"jest": {
4549
"roots": [
4650
"<rootDir>/test"
@@ -56,33 +60,33 @@
5660
"pkgRoot": "lib"
5761
},
5862
"devDependencies": {
59-
"@4c/babel-preset-4catalyzer": "^4.1.1",
60-
"@4c/semantic-release-config": "^1.0.3",
63+
"@4c/babel-preset": "^5.1.0",
64+
"@4c/semantic-release-config": "^1.0.5",
6165
"@babel/cli": "^7.2.3",
62-
"@babel/core": "^7.3.4",
63-
"@types/react": "^16.8.5",
66+
"@babel/core": "^7.4.0",
67+
"@types/react": "^16.8.10",
6468
"babel-core": "bridge",
6569
"babel-eslint": "^10.0.1",
66-
"babel-jest": "^24.1.0",
70+
"babel-jest": "^24.5.0",
6771
"codecov": "^3.2.0",
6872
"cpy-cli": "^2.0.0",
69-
"dtslint": "^0.3.0",
73+
"dtslint": "^0.5.9",
7074
"enzyme": "^3.9.0",
71-
"enzyme-adapter-react-16": "^1.10.0",
72-
"eslint": "^5.14.1",
73-
"eslint-config-4catalyzer-react": "^0.9.0",
74-
"eslint-config-prettier": "^4.0.0",
75+
"enzyme-adapter-react-16": "^1.11.2",
76+
"eslint": "^5.15.3",
77+
"eslint-config-4catalyzer-react": "^0.9.3",
78+
"eslint-config-prettier": "^4.1.0",
7579
"eslint-plugin-import": "^2.16.0",
76-
"eslint-plugin-jest": "^22.3.0",
80+
"eslint-plugin-jest": "^22.4.1",
7781
"eslint-plugin-jsx-a11y": "^6.2.1",
7882
"eslint-plugin-prettier": "^3.0.1",
7983
"eslint-plugin-react": "^7.12.4",
8084
"husky": "^1.3.1",
81-
"jest": "^24.1.0",
82-
"lint-staged": "^8.1.4",
85+
"jest": "^24.5.0",
86+
"lint-staged": "^8.1.5",
8387
"prettier": "^1.16.4",
84-
"react": "^16.8.3",
85-
"react-dom": "^16.8.3",
88+
"react": "^16.8.6",
89+
"react-dom": "^16.8.6",
8690
"semantic-release": "^15.13.3",
8791
"travis-deploy-once": "^5.0.11"
8892
},

src/forwardRef.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
export default function forwardRef(
44
renderFn,
55
{
6-
propTypes,
6+
propTypes, // eslint-disable-line react/forbid-foreign-prop-types
77
defaultProps,
88
allowFallback = false,
99
displayName = renderFn.name || renderFn.displayName,

0 commit comments

Comments
 (0)