Skip to content

Commit

Permalink
Refactor: Replace use of key-mirror with inline code (#29857)
Browse files Browse the repository at this point in the history
The `key-mirror` package is useful but not enough to warrant pulling in
the dependency. It was being referenced in only a few files and this
change replaces those instances where we were using it with the code the
produces the same effect. It's actually so trivial of a change that the
warrant for removing the library and the function calls should be
obvious.

**Before**
```js
const items = keyMirror( {
	ONE: null,
	TWO: null,
	THREE: null,
} );
```

**After**
```js
const items = {
	ONE: 'ONE',
	TWO: 'TWO',
	THREE: 'THREE',
};
```
  • Loading branch information
dmsnell committed Jan 2, 2019
1 parent 52f7dbb commit 383a00b
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 199 deletions.
14 changes: 0 additions & 14 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1147,20 +1147,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

### https://github.com/wmira/key-mirror
```text
The MIT License (MIT)
Copyright (c) 2015 Warren Mira
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```


### https://github.com/gaearon/react-pure-render
```text
The MIT License (MIT)
Expand Down
34 changes: 14 additions & 20 deletions client/lib/invites/constants.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
/** @format */

/**
* External dependencies
*/

import keyMirror from 'key-mirror';

/**
* Module variables
*/
export const action = keyMirror( {
FETCH_INVITE: null,
RECEIVE_INVITE: null,
RECEIVE_INVITE_ERROR: null,
INVITE_ACCEPTED: null,
RECEIVE_INVITE_ACCEPTED_SUCCESS: null,
RECEIVE_INVITE_ACCEPTED_ERROR: null,
SENDING_INVITES: null,
RECEIVE_SENDING_INVITES_ERROR: null,
RECEIVE_SENDING_INVITES_SUCCESS: null,
CREATE_INVITE_VALIDATION: null,
RECEIVE_CREATE_INVITE_VALIDATION_ERROR: null,
RECEIVE_CREATE_INVITE_VALIDATION_SUCCESS: null,
} );
export const action = {
FETCH_INVITE: 'FETCH_INVITE',
RECEIVE_INVITE: 'RECEIVE_INVITE',
RECEIVE_INVITE_ERROR: 'RECEIVE_INVITE_ERROR',
INVITE_ACCEPTED: 'INVITE_ACCEPTED',
RECEIVE_INVITE_ACCEPTED_SUCCESS: 'RECEIVE_INVITE_ACCEPTED_SUCCESS',
RECEIVE_INVITE_ACCEPTED_ERROR: 'RECEIVE_INVITE_ACCEPTED_ERROR',
SENDING_INVITES: 'SENDING_INVITES',
RECEIVE_SENDING_INVITES_ERROR: 'RECEIVE_SENDING_INVITES_ERROR',
RECEIVE_SENDING_INVITES_SUCCESS: 'RECEIVE_SENDING_INVITES_SUCCESS',
CREATE_INVITE_VALIDATION: 'CREATE_INVITE_VALIDATION',
RECEIVE_CREATE_INVITE_VALIDATION_ERROR: 'RECEIVE_CREATE_INVITE_VALIDATION_ERROR',
RECEIVE_CREATE_INVITE_VALIDATION_SUCCESS: 'RECEIVE_CREATE_INVITE_VALIDATION_SUCCESS',
};
26 changes: 10 additions & 16 deletions client/lib/media/constants.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
/** @format */

/**
* External dependencies
*/

import keyMirror from 'key-mirror';

/**
* An enum set of possible media validation errors.
*
* @type {Object}
* @typedef MediaValidationError
*/
export const ValidationErrors = keyMirror( {
FILE_TYPE_UNSUPPORTED: null,
FILE_TYPE_NOT_IN_PLAN: null,
SERVER_ERROR: null,
UPLOAD_VIA_URL_404: null,
EXCEEDS_MAX_UPLOAD_SIZE: null,
EXCEEDS_PLAN_STORAGE_LIMIT: null,
NOT_ENOUGH_SPACE: null,
SERVICE_FAILED: null,
} );
export const ValidationErrors = {
FILE_TYPE_UNSUPPORTED: 'FILE_TYPE_UNSUPPORTED',
FILE_TYPE_NOT_IN_PLAN: 'FILE_TYPE_NOT_IN_PLAN',
SERVER_ERROR: 'SERVER_ERROR',
UPLOAD_VIA_URL_404: 'UPLOAD_VIA_URL_404',
EXCEEDS_MAX_UPLOAD_SIZE: 'EXCEEDS_MAX_UPLOAD_SIZE',
EXCEEDS_PLAN_STORAGE_LIMIT: 'EXCEEDS_PLAN_STORAGE_LIMIT',
NOT_ENOUGH_SPACE: 'NOT_ENOUGH_SPACE',
SERVICE_FAILED: 'SERVICE_FAILED',
};

export const ThumbnailSizeDimensions = {
thumbnail: {
Expand Down
9 changes: 4 additions & 5 deletions client/me/security-account-recovery/manage-contact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import PropTypes from 'prop-types';
import React, { Component } from 'react';
import keyMirror from 'key-mirror';
import { localize } from 'i18n-calypso';

/**
Expand All @@ -15,10 +14,10 @@ import { localize } from 'i18n-calypso';
import FormButton from 'components/forms/form-button';
import analytics from 'lib/analytics';

const views = keyMirror( {
VIEWING: null,
EDITING: null,
} );
const views = {
VIEWING: 'VIEWING',
EDITING: 'EDITING',
};

class ManageContact extends Component {
constructor( props ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
/** @format */

/**
* External dependencies
*/

import keyMirror from 'key-mirror';

export const actionType = keyMirror( {
CLOSE: null,
READY_TO_SUBMIT: null,
SUBMITTING: null,
REDIRECTING: null,
} );
export const actionType = {
CLOSE: 'CLOSE',
READY_TO_SUBMIT: 'READY_TO_SUBMIT',
SUBMITTING: 'SUBMITTING',
REDIRECTING: 'REDIRECTING',
};

export const noticeType = {
ERROR: 'is-error',
Expand Down

0 comments on commit 383a00b

Please sign in to comment.