Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Package updates #49

Merged
merged 11 commits into from
Jul 7, 2023
Merged
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 .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
jasmine: true
jest: true
es6: true
parser: babel-eslint
parser: "@babel/eslint-parser"
parserOptions:
sourceType: module
ecmaFeatures:
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- '8'
- '18'
dist: 'jammy'
notifications:
email: false
before_script: yarn size
Expand All @@ -10,5 +11,5 @@ deploy:
api_key:
secure: Mu68/DGE+RC2TilCle7RXuqeluOCsR2MMSFge2MLNGWDdtv/j5S5gMYFuHKw61ASpBQ1bJsJmuIJ1/MHrAQ5S67N6/8lA2LVVSzWMB30h28anUm+lCSGZMWcy+Z+z1xXLMOAMrDglHGwAmt5NabUKIpHc9YWuPE3T3yp2ilVq81ameFObPZ08ISM8pmF90bp1qIXwk1iUPTcCWa6UkIfhpfAdMVHVWXLWIyaZ3+/p8mYNpc27mW23GrWcejDfgUUI9Oe+5pv/fb3RBO2HXLmIt582s+H3/evY9VSHTKt2e/CbBO2umgE1Bgn5Al7VIX8YRb62effbxUyNMVLk15UQnTVWu7m3/V2+N3pnFrJzMFJMS7JNmIPzCb+xFKvKaqo6qklfc6Wir8IW8mMyB1KznoaqEeOJ9daehmQgCQkCulzl5h6HLQ08OFQ5WUcsSHgAJgUlXsL2u5izQNZhbhT1eMP/YwNZvbI072Yxw468U0oaeGaj1Y0rnmtQR0UT3QcfyEyzzZ/2+FwDRF9AfZwhMDx7BNrlCuQ0Z2lnj54fggXe2q0G6NBrpC6Vw610FTCwBQ3yzQKnQ8IQckYxp/nD7ew2mnaQJnj0V4wn9MqquijOukBKUfEFmRjliKYLdTIUZBPJ9wBua1PrBlO6QIeBJzPlsDA039CB4icBYE2CCw=
on:
branch: master
branch: main
skip_cleanup: true
2 changes: 1 addition & 1 deletion .babelrc → babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
module.exports = {
"presets": [ "@launchpadlab/babel-preset/react" ]
}
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-flash",
"version": "2.0.6",
"version": "2.0.7",
"description": "Redux action creators for displaying flash messages",
"main": "lib/index.js",
"scripts": {
Expand All @@ -12,8 +12,7 @@
"prepublish": "yarn run lint && yarn run clean && yarn run build",
"test": "jest",
"size": "yarn build && size-limit",
"test:coverage": "jest --coverage",
"report-coverage": "codeclimate-test-reporter < coverage/lcov.info"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command doesn't work on main currently and it might never have worked. The package itself has been deprecated. Given that it's not used by anything, I'd rather remove it then "fix" it.

"test:coverage": "jest --coverage"
},
"repository": "launchpadlab/redux-flash",
"keywords": [
Expand All @@ -31,23 +30,23 @@
"lib/"
],
"devDependencies": {
"@babel/eslint-parser": "^7.22.6",
"@launchpadlab/babel-preset": "^2.1.0",
"@size-limit/preset-small-lib": "^2.1.1",
"babel-eslint": "^10.0.2",
"codeclimate-test-reporter": "^0.4.1",
"eslint": "^6.1.0",
"@size-limit/file": "^8.2.6",
"@size-limit/webpack": "^8.2.6",
Comment on lines +35 to +36
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@size-limit switched from defaulting to webpack in v6 to esbuild in v7/v8. For some reason, this caused our reported build size to nearly quadruple (8.63 kb -> 31.05 kb). I tried to dig into what was going on, but I wasn't able to make much progress.

Given that webpack is what we were using to determine the size, this feels like less of a breaking change (despite the swap out in packages) and intuitively makes more sense.

"eslint": "^8.44.0",
"eslint-plugin-import": "^2.2.0",
"jest": "^24.8.0",
"jest": "^29.5.0",
"redux": "^4.0.4",
"redux-mock-store": "^1.3.0",
"size-limit": "^2.1.1"
"size-limit": "^8.2.6"
},
"dependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"prop-types": "^15.6.1",
"redux-actions": "^2.6.5",
"uuid": "^3.1.0"
"uuid": "^9.0.0"
},
"peerDependencies": {
"redux": "^4.0.0 || ^3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export {
clearMessages,
removeMessage,
} from './actions'
export flashMessageType from './flashMessageType'
export middleware from './middleware'
export { default as flashMessageType } from './flashMessageType'
export { default as middleware } from './middleware'
export {
reducer,
getFlashMessages,
Expand Down
4 changes: 2 additions & 2 deletions src/middleware.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uuid from 'uuid/v4'
import { v4 as uuidv4 } from 'uuid'
import * as actions from './actions'

const DEFAULT_TIMEOUT = 3000
Expand Down Expand Up @@ -26,7 +26,7 @@ function middleware (options={}) {
}
}
} = action
const id = uuid()
const id = uuidv4()
// Dispatch appropriate internal actions
if (push) next(actions.clearMessages())
next(actions._addMessage({ id, message, isError, props: { ...globalProps, ...props }}))
Expand Down
8 changes: 4 additions & 4 deletions test/actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ test('flashMessage sets default timeout if none is provided', () => {
const store = createMockStore()
store.dispatch(flashMessage('Hi'))
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE])
jest.runTimersToTime(4000)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method was deprecated

jest.advanceTimersByTime(4000)
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE, REMOVE_MESSAGE_ACTION_TYPE])
})

test('flashMessage sets custom timeout if one is provided in action creator', () => {
const store = createMockStore()
store.dispatch(flashMessage('Hi', { timeout: 500 }))
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE])
jest.runTimersToTime(1000)
jest.advanceTimersByTime(1000)
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE, REMOVE_MESSAGE_ACTION_TYPE])
})

test('flashMessage sets custom timeout if one is provided in middleware config', () => {
const store = createMockStore({}, { timeout: 500 })
store.dispatch(flashMessage('Hi'))
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE])
jest.runTimersToTime(1000)
jest.advanceTimersByTime(1000)
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE, REMOVE_MESSAGE_ACTION_TYPE])
})

test('flashMessage sets no timeout if "false" is provided', () => {
const store = createMockStore()
store.dispatch(flashMessage('Hi', { timeout: false }))
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE])
jest.runTimersToTime(4000)
jest.advanceTimersByTime(4000)
expect(store.getActionTypes()).toEqual([ADD_MESSAGE_ACTION_TYPE])
})

Expand Down
2 changes: 2 additions & 0 deletions test/flashMessageType.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
} from '../src'
import { createMockStore } from './helpers'

jest.useFakeTimers()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, jest was reporting a potential unhandled operation (as a result of setTimeout in middleware.js)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. I'm sure that was fun to figure out.


function validatePropType (propType, value) {
// checkPropTypes will log an error if it fails
const spy = jest.spyOn(console, 'error')
Expand Down
Loading