Skip to content

Commit e189bd7

Browse files
committed
Updates build, improves types, changes onChange behavior
1 parent db0ad8e commit e189bd7

File tree

12 files changed

+3010
-3108
lines changed

12 files changed

+3010
-3108
lines changed

.babelrc

Lines changed: 0 additions & 36 deletions
This file was deleted.

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
"@typescript-eslint/camelcase": "off",
2121
"@typescript-eslint/explicit-function-return-type": "off",
2222
"@typescript-eslint/no-use-before-define": "off",
23+
"@typescript-eslint/no-empty-function": "off",
24+
"@typescript-eslint/explicit-module-boundary-types": "off",
25+
"@typescript-eslint/ban-ts-comment": "off",
2326
"no-console": "off",
2427
"no-prototype-builtins": "off",
2528
"react/no-children-prop": "off",
2629
"react/display-name": "off",
27-
"react/prop-types": "off"
30+
"react/prop-types": "off",
31+
"react-hooks/rules-of-hooks": "error",
32+
"react-hooks/exhaustive-deps": "warn"
2833
},
2934
"settings": {
3035
"react": {

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
3-
coverage
3+
coverage
4+
*.log

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cache:
66
- node_modules
77
notifications:
88
email: false
9-
node_js: '10'
9+
node_js: '12'
1010
install: yarn install
1111
script: yarn validate
1212
after_script: npx codecov@3

babel.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = (api) => {
2+
const module = api.env('module')
3+
const esm = api.env('esm')
4+
const presetEnv = [
5+
'@lunde/es',
6+
{
7+
env: {
8+
modules: esm || module ? false : 'commonjs',
9+
targets: module
10+
? {
11+
browsers: 'cover 80% in US',
12+
}
13+
: {
14+
node: esm ? '12' : '10',
15+
},
16+
},
17+
restSpread: false,
18+
devExpression: false,
19+
objectAssign: false,
20+
},
21+
]
22+
23+
return {
24+
presets: [['@babel/preset-react', {useSpread: true}], presetEnv],
25+
plugins: ['optimize-react', 'annotate-pure-calls'],
26+
}
27+
}

package.json

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@accessible/checkbox",
3-
"version": "2.0.1",
3+
"version": "3.0.0",
44
"homepage": "https://github.com/accessible-ui/checkbox#readme",
55
"repository": "github:accessible-ui/checkbox",
66
"bugs": "https://github.com/accessible-ui/checkbox/issues",
@@ -19,35 +19,53 @@
1919
"react checkbox component",
2020
"react checkbox"
2121
],
22-
"main": "dist/cjs/index.js",
23-
"module": "dist/es/index.js",
22+
"main": "dist/main/index.js",
23+
"module": "dist/module/index.js",
24+
"source": "src/index.tsx",
25+
"types": "types/index.d.ts",
2426
"files": [
25-
"/dist"
27+
"/dist",
28+
"/src",
29+
"/types"
2630
],
31+
"exports": {
32+
".": {
33+
"browser": "./dist/module/index.js",
34+
"import": "./dist/esm/index.mjs",
35+
"require": "./dist/main/index.js",
36+
"source": "./src/index.tsx",
37+
"types": "./types/index.d.ts",
38+
"default": "./dist/main/index.js"
39+
},
40+
"./package.json": "./package.json",
41+
"./": "./"
42+
},
2743
"sideEffects": false,
2844
"scripts": {
29-
"build": "npm run build:cjs && npm run build:es && npm run build:types",
30-
"build:cjs": "babel src -d dist/cjs -x .ts,.tsx --ignore \"**/*.test.ts\",\"**/test.ts\",\"**/*.test.tsx\",\"**/test.tsx\" --delete-dir-on-start",
31-
"build:es": "cross-env BABEL_ENV=es babel src -d dist/es -x .ts,.tsx --ignore \"**/*.test.ts\",\"**/test.ts\",\"**/*.test.tsx\",\"**/test.tsx\" --delete-dir-on-start",
32-
"build:types": "tsc -p tsconfig.json -d --outDir dist/es --emitDeclarationOnly && mkdir -p dist/cjs && cp -R dist/es/**.d.ts dist/cjs && rimraf dist/**/*.test.d.ts",
45+
"build": "npm run build-esm && npm run build-main && npm run build-module && npm run build-types",
46+
"build-esm": "npm run compile -- -d dist/esm --env-name esm --out-file-extension .mjs",
47+
"build-main": "npm run compile -- -d dist/main --env-name main",
48+
"build-module": "npm run compile -- -d dist/module --env-name module",
49+
"build-types": "tsc -p tsconfig.json -d --outDir types --emitDeclarationOnly",
3350
"check-types": "tsc --noEmit -p tsconfig.json",
34-
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,md,yml,json,babelrc,eslintrc,prettierrc}\"",
51+
"compile": "babel src -x .ts,.tsx --ignore \"**/*.test.ts\",\"**/*.test.tsx\" --delete-dir-on-start",
52+
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,md,yml,json,eslintrc,prettierrc}\"",
3553
"lint": "eslint . --ext .ts,.tsx",
3654
"prepublishOnly": "npm run lint && npm run test && npm run build && npm run format",
3755
"test": "jest",
3856
"validate": "npm run check-types && npm run lint && npm run test -- --coverage"
3957
},
4058
"husky": {
4159
"hooks": {
42-
"pre-commit": "lint-staged && npm run build:types"
60+
"pre-commit": "npm run build-types && git add types && lint-staged"
4361
}
4462
},
4563
"lint-staged": {
4664
"**/*.{ts,tsx,js,jsx}": [
4765
"eslint",
4866
"prettier --write"
4967
],
50-
"**/*.{md,yml,json,babelrc,eslintrc,prettierrc}": [
68+
"**/*.{md,yml,json,eslintrc,prettierrc}": [
5169
"prettier --write"
5270
]
5371
},
@@ -57,14 +75,14 @@
5775
"@testing-library/jest-dom": "latest",
5876
"@testing-library/react": "latest",
5977
"@testing-library/react-hooks": "latest",
78+
"@testing-library/user-event": "latest",
6079
"@types/jest": "latest",
6180
"@types/react": "latest",
6281
"@types/react-dom": "latest",
6382
"@typescript-eslint/eslint-plugin": "latest",
6483
"@typescript-eslint/parser": "latest",
65-
"babel-plugin-optimize-react": "^0.0.4",
66-
"babel-plugin-typescript-to-proptypes": "^1.1.0",
67-
"cross-env": "latest",
84+
"babel-plugin-annotate-pure-calls": "latest",
85+
"babel-plugin-optimize-react": "latest",
6886
"eslint": "latest",
6987
"eslint-import-resolver-jest": "latest",
7088
"eslint-plugin-jest": "latest",
@@ -77,18 +95,15 @@
7795
"react": "latest",
7896
"react-dom": "latest",
7997
"react-test-renderer": "latest",
80-
"rimraf": "^2.6.3",
8198
"ts-jest": "latest",
82-
"typescript": "latest",
83-
"typescript-to-proptypes": "^1.4.0"
99+
"typescript": "latest"
84100
},
85101
"dependencies": {
86-
"@accessible/visually-hidden": "^1.0.1",
87-
"@react-hook/switch": "^1.0.4",
88-
"clsx": "^1.0.4"
102+
"@accessible/visually-hidden": "^1.1.0",
103+
"@react-hook/switch": "^1.1.0",
104+
"clsx": "^1.1.1"
89105
},
90106
"peerDependencies": {
91-
"prop-types": ">=15.7.2",
92107
"react": ">=16.8",
93108
"react-dom": ">=16.8"
94109
}

src/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('<Checkbox>', () => {
9393

9494
render(
9595
<Checkbox>
96-
{context => {
96+
{(context) => {
9797
cxt = context
9898
return <div />
9999
}}

0 commit comments

Comments
 (0)