Skip to content

Commit d7f053e

Browse files
icd2k3jschrader-nr
andauthored
chore: maintain all dev dependencies and build process (#27)
Co-authored-by: Justin Schrader <[email protected]>
1 parent dcbe4fd commit d7f053e

22 files changed

+9717
-7154
lines changed

.eslintrc

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
"extends": [
33
"airbnb",
44
"plugin:@typescript-eslint/eslint-recommended",
5-
"plugin:@typescript-eslint/recommended",
6-
"plugin:prettier/recommended",
7-
"prettier/@typescript-eslint",
8-
"prettier/react"
5+
"plugin:@typescript-eslint/recommended"
96
],
107
"parser": "@typescript-eslint/parser",
118
"plugins": [
129
"@typescript-eslint",
13-
"prettier",
1410
"react-hooks"
1511
],
1612
"env": {
@@ -30,4 +26,4 @@
3026
"globals": {
3127
"jest": "writable"
3228
}
33-
}
29+
}

.github/workflows/nodejs.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

1716
strategy:
1817
matrix:
19-
node-version: [14.15.3]
18+
node-version: [15.14.0]
2019

2120
steps:
2221
- uses: actions/checkout@v2

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22
/dist/*
33
/yarn-error.log
44
/coverage
5+
.yarn/*
6+
!.yarn/patches
7+
!.yarn/releases
8+
!.yarn/plugins
9+
!.yarn/sdks
10+
!.yarn/versions
11+
.pnp.*
512
.DS_Store

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit $1

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn build && yarn lint && yarn test

.husky/pre-push

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn build && yarn types && yarn lint && yarn test-build

.npmignore

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
.git/
33
.github/
44
.gitignore
5+
.gitignore
6+
.husky/
57
.npmignore
68
.nvmrc
7-
/yarn-error.log
9+
.yarn/
10+
.yarnrc.yml
11+
CONTRIBUTING.md
12+
MIGRATIONS.md
813
babel.config.js
914
commitlint.config.js
1015
coverage/
11-
coverage/
1216
hooks/
1317
jest.config.js
1418
jest.setup.js
1519
rollup.config.js
1620
scripts/
1721
src/
22+
tsconfig.json
23+
yarn-error.log
24+
yarn.lock

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v14.15.3
1+
v15.14.0

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

+77
Large diffs are not rendered by default.

.yarn/releases/yarn-2.4.2.cjs

+55
Large diffs are not rendered by default.

.yarnrc.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
nodeLinker: node-modules
2+
3+
plugins:
4+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
5+
spec: "@yarnpkg/plugin-interactive-tools"
6+
7+
yarnPath: .yarn/releases/yarn-2.4.2.cjs

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</p>
1010

1111
<p align="center">
12-
A small (~1.6kb gzip), flexible, <a href="https://reactjs.org/docs/hooks-intro.html">hook</a> for rendering breadcrumbs with <a href="https://github.com/ReactTraining/react-router">react-router</a> (5.1 and up).
12+
A small (~1.25kb gzip), flexible, <a href="https://reactjs.org/docs/hooks-intro.html">hook</a> for rendering breadcrumbs with <a href="https://github.com/ReactTraining/react-router">react-router</a> (5.1 and up).
1313
</p>
1414

1515
<hr/>
@@ -22,7 +22,7 @@
2222

2323
<p align="center">
2424
<code>
25-
This package only works with `react-router` 5.1 and up. If you need a (very) similar solution for an earlier version, check out <a href="https://github.com/icd2k3/react-router-breadcrumbs-hoc">react-router-breadcrumbs-hoc</a>
25+
If you'd rather use a Higher Order Component, check out <a href="https://github.com/icd2k3/react-router-breadcrumbs-hoc">react-router-breadcrumbs-hoc</a>
2626
</code>
2727
</p>
2828

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ module.exports = (api) => {
77
'@babel/preset-react',
88
'@babel/preset-typescript',
99
],
10-
plugins: [],
10+
plugins: ['@babel/plugin-transform-runtime'],
1111
};
1212
};

jest.setup.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'jsdom-global/register';
12
import Enzyme from 'enzyme';
23
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
34

package.json

+36-46
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,65 @@
11
{
22
"name": "use-react-router-breadcrumbs",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "A hook for displaying and setting breadcrumbs for react router",
55
"main": "dist/cjs/index.js",
66
"module": "dist/es/index.js",
77
"umd": "dist/umd/index.js",
88
"repository": "[email protected]:icd2k3/use-react-router-breadcrumbs.git",
99
"author": "Justin Schrader <[email protected]>",
1010
"license": "MIT",
11-
"private": false,
1211
"types": "dist/index.d.ts",
1312
"peerDependencies": {
1413
"react": ">=16.8",
1514
"react-router": ">=5.1.0"
1615
},
1716
"scripts": {
18-
"prepublishOnly": "npm run build",
17+
"prepublishOnly": "yarn build && pinst --disable",
1918
"build": "rollup -c",
2019
"test": "jest",
2120
"test-build": "sh ./scripts/test-build.sh",
2221
"types": "tsc -p tsconfig.json",
23-
"lint": "eslint ./src/**"
24-
},
25-
"husky": {
26-
"hooks": {
27-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
28-
"pre-commit": "yarn build && yarn lint && yarn test",
29-
"pre-push": "yarn build && yarn types && yarn lint && yarn test-build"
30-
}
22+
"lint": "eslint ./src/**",
23+
"postpublish": "pinst --enable",
24+
"prepare": "husky install"
3125
},
3226
"devDependencies": {
33-
"@babel/cli": "^7.8.4",
34-
"@babel/core": "^7.8.7",
35-
"@babel/preset-env": "^7.8.7",
36-
"@babel/preset-react": "^7.8.3",
37-
"@babel/preset-typescript": "^7.8.3",
38-
"@commitlint/cli": "^11.0.0",
39-
"@commitlint/config-conventional": "^11.0.0",
40-
"@rollup/plugin-commonjs": "^17.0.0",
41-
"@rollup/plugin-node-resolve": "^11.0.1",
42-
"@types/react": "^17.0.0",
43-
"@types/react-dom": "^17.0.0",
44-
"@types/react-router": "^5.1.4",
45-
"@typescript-eslint/eslint-plugin": "^4.10.0",
46-
"@typescript-eslint/parser": "^4.10.0",
47-
"@wojtekmaj/enzyme-adapter-react-17": "^0.4.1",
27+
"@babel/cli": "^7.14.3",
28+
"@babel/core": "^7.14.3",
29+
"@babel/plugin-transform-runtime": "^7.14.3",
30+
"@babel/preset-env": "^7.14.4",
31+
"@babel/preset-react": "^7.13.13",
32+
"@babel/preset-typescript": "^7.13.0",
33+
"@commitlint/cli": "^12.1.4",
34+
"@commitlint/config-conventional": "^12.1.4",
35+
"@rollup/plugin-babel": "^5.3.0",
36+
"@rollup/plugin-typescript": "^8.2.1",
37+
"@types/react": "^17.0.11",
38+
"@types/react-dom": "^17.0.7",
39+
"@types/react-router": "^5.1.15",
40+
"@typescript-eslint/eslint-plugin": "^4.26.1",
41+
"@typescript-eslint/parser": "^4.26.1",
42+
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
4843
"babel-eslint": "^10.1.0",
49-
"babel-jest": "^26.6.3",
50-
"coveralls": "^3.0.9",
5144
"enzyme": "^3.11.0",
52-
"eslint": "^7.16.0",
53-
"eslint-config-airbnb": "^18.1.0",
54-
"eslint-config-prettier": "^7.1.0",
55-
"eslint-plugin-import": "^2.20.1",
56-
"eslint-plugin-jsx-a11y": "^6.2.3",
57-
"eslint-plugin-prettier": "^3.1.3",
58-
"eslint-plugin-react": "^7.19.0",
45+
"eslint": "^7.28.0",
46+
"eslint-config-airbnb": "^18.2.1",
47+
"eslint-plugin-import": "^2.23.4",
48+
"eslint-plugin-jsx-a11y": "^6.4.1",
49+
"eslint-plugin-react": "^7.24.0",
5950
"eslint-plugin-react-hooks": "^4.2.0",
60-
"husky": "^4.2.1",
61-
"jest": "^26.6.3",
62-
"js-yaml": "^3.13.1",
63-
"prettier": "^2.0.5",
51+
"husky": "^6.0.0",
52+
"jest": "^27.0.4",
53+
"jsdom-global": "^3.0.2",
54+
"pinst": "^2.1.6",
6455
"prop-types": "^15.7.2",
65-
"react": "^17.0.1",
66-
"react-dom": "^17.0.1",
67-
"react-router": "^5.1.2",
68-
"rollup": "^2.1.0",
69-
"rollup-plugin-babel": "^4.4.0",
56+
"react": "^17.0.2",
57+
"react-dom": "^17.0.2",
58+
"react-router": "^5.2.0",
59+
"rollup": "^2.51.1",
60+
"rollup-plugin-size": "^0.2.2",
7061
"rollup-plugin-terser": "^7.0.2",
71-
"rollup-plugin-typescript2": "^0.29.0",
72-
"typescript": "^4.1.3"
62+
"typescript": "^4.3.2"
7363
},
7464
"keywords": [
7565
"react",

prettier.config.js

-3
This file was deleted.

rollup.config.js

+25-39
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,51 @@
1-
import babel from 'rollup-plugin-babel';
2-
import commonjs from '@rollup/plugin-commonjs';
3-
import resolve from '@rollup/plugin-node-resolve';
1+
import babel from '@rollup/plugin-babel';
2+
import typescript from '@rollup/plugin-typescript';
3+
import size from 'rollup-plugin-size';
44
import { terser } from 'rollup-plugin-terser';
5-
import typescript from 'rollup-plugin-typescript2';
6-
import ts from 'typescript';
75

86
import pkg from './package.json';
97

10-
const external = Object.keys(pkg.peerDependencies);
8+
const external = Object.keys(pkg.peerDependencies).concat(/@babel\/runtime/);
119

1210
const extensions = ['.js', '.tsx'];
1311

14-
const plugins = [
15-
typescript({
16-
useTsconfigDeclarationDir: true,
17-
tsconfigOverride: {
18-
typescript: ts,
19-
compilerOptions: {
20-
module: 'es2015',
21-
},
22-
},
23-
}),
12+
const sharedPlugins = [
13+
typescript(),
2414
babel({
15+
babelHelpers: 'runtime',
2516
exclude: 'node_modules/**',
2617
extensions,
2718
}),
28-
resolve({
29-
mainFields: ['module', 'main', 'umd'],
30-
extensions,
31-
}),
19+
size(),
3220
];
3321

34-
const exports = [
35-
{
36-
format: 'cjs',
37-
file: pkg.main,
38-
plugins: plugins.concat([commonjs(), terser()]),
39-
},
40-
{
41-
format: 'umd',
42-
file: pkg.umd,
43-
plugins: plugins.concat([commonjs(), terser()]),
44-
},
45-
{ format: 'es', file: pkg.module, plugins },
22+
const formats = [
23+
{ format: 'umd', file: pkg.umd, plugins: sharedPlugins.concat([terser({ format: { comments: false } })]) },
24+
{ format: 'cjs', file: pkg.main, plugins: sharedPlugins },
25+
{ format: 'es', file: pkg.module, plugins: sharedPlugins },
4626
];
4727

4828
const globals = {
4929
react: 'React',
5030
'react-router': 'ReactRouter',
5131
};
5232

53-
export default exports.map((item) => ({
33+
export default formats.map(({ plugins, file, format }) => ({
5434
input: 'src/index.tsx',
55-
plugins: item.plugins,
35+
plugins,
5636
external,
5737
output: {
5838
exports: 'named',
59-
file: item.file,
60-
format: item.format,
61-
name: 'use-react-router-breadcrumbs',
62-
globals,
63-
sourcemap: true,
39+
file,
40+
format,
41+
name: 'react-router-breadcrumbs-hoc',
42+
globals: format !== 'umd'
43+
? globals
44+
: {
45+
...globals,
46+
'@babel/runtime/helpers/toConsumableArray': '_toConsumableArray',
47+
'@babel/runtime/helpers/defineProperty': '_defineProperty',
48+
'@babel/runtime/helpers/objectWithoutProperties': '_objectWithoutProperties',
49+
},
6450
},
6551
}));

src/index.test.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const components = {
2929
return (
3030
<h1>
3131
<div className="forwarded-props">
32-
{forwardedProps &&
33-
Object.values(forwardedProps)
32+
{forwardedProps
33+
&& Object.values(forwardedProps)
3434
.filter((v) => typeof v === 'string')
3535
.map((value) => <span key={value}>{value}</span>)}
3636
</div>
@@ -104,7 +104,7 @@ const render = ({ options, pathname, routes, state, props }) => {
104104
routes={routes}
105105
{...(props || {})}
106106
/>
107-
</Router>
107+
</Router>,
108108
);
109109

110110
return {
@@ -135,7 +135,7 @@ components.Breadcrumbs.propTypes = {
135135
PropTypes.func,
136136
PropTypes.object,
137137
]),
138-
})
138+
}),
139139
),
140140
};
141141

@@ -419,13 +419,11 @@ describe('use-react-router-breadcrumbs', () => {
419419

420420
describe('Invalid route object', () => {
421421
it('Should error if `path` is not provided', () => {
422-
expect(() =>
423-
getMethod()({
424-
routes: [{ breadcrumb: 'Yo' }],
425-
location: { pathname: '/1' },
426-
})
427-
).toThrow(
428-
'useBreadcrumbs: `path` must be provided in every route object'
422+
expect(() => getMethod()({
423+
routes: [{ breadcrumb: 'Yo' }],
424+
location: { pathname: '/1' },
425+
})).toThrow(
426+
'useBreadcrumbs: `path` must be provided in every route object',
429427
);
430428
});
431429
});

0 commit comments

Comments
 (0)