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

Update to latest version of eslint-config-expensify #410

Merged
merged 3 commits into from
Aug 25, 2021
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
4 changes: 3 additions & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ export default class ExpensiMark {
// Now we move to the next match that the js regex found in the text
match = regex.exec(textToCheck);
}
if (startIndex < textToCheck.length) replacedText = replacedText.concat(textToCheck.substr(startIndex));
if (startIndex < textToCheck.length) {
replacedText = replacedText.concat(textToCheck.substr(startIndex));
}

return replacedText;
}
Expand Down
13 changes: 6 additions & 7 deletions lib/components/form/element/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ class Combobox extends React.Component {
// If the options have an id property, we use that to compare them and determine if they changed, if not
// we'll use the whole options array.
if (has(nextProps.options, '0.id')) {
if (!_.isEqual(_.pluck(nextProps.options, 'id'), _.pluck(this.props.options, 'id')) || !_.isEqual(_.pluck(nextProps.alreadySelectedOptions, 'id'), _.pluck(this.props.alreadySelectedOptions, 'id'))) {
if (!_.isEqual(_.pluck(nextProps.options, 'id'), _.pluck(this.props.options, 'id'))
|| !_.isEqual(_.pluck(nextProps.alreadySelectedOptions, 'id'), _.pluck(this.props.alreadySelectedOptions, 'id'))) {
this.reset(false, nextProps.options, nextProps.alreadySelectedOptions);
}
} else if (!_.isEqual(nextProps.options, this.props.options) || !_.isEqual(nextProps.alreadySelectedOptions, this.props.alreadySelectedOptions)) {
Expand All @@ -239,11 +240,9 @@ class Combobox extends React.Component {
}

componentDidUpdate() {
const dropDown = ReactDOM.findDOMNode(this.dropDown);

// Set scroll position to the last known location when applicable
if (dropDown && !this.props.autoScrollToTop) {
dropDown.scrollTop = this.scrollPosition;
if (this.dropDown && !this.props.autoScrollToTop) {
this.dropDown.scrollTop = this.scrollPosition;
}
}

Expand Down Expand Up @@ -486,7 +485,7 @@ class Combobox extends React.Component {
if ($(e.target).attr('id') === 'supportPassword'
|| (
$(e.target).parents('.expensify-input-group').length
&& $(e.target).parents('.expensify-input-group')[0] === ReactDOM.findDOMNode(this)
&& $(e.target).parents('.expensify-input-group')[0] === ReactDOM.findDOMNode(this) // eslint-disable-line react/no-find-dom-node
)
) {
return;
Expand Down Expand Up @@ -846,7 +845,7 @@ class Combobox extends React.Component {
const currentlySelectedOption = _(this.options).findWhere({value: selectedValue});

// Get the scroll position of the currently selected value
this.scrollPosition = ReactDOM.findDOMNode(this.dropDown).scrollTop;
this.scrollPosition = this.dropDown.scrollTop;

this.setState({
options: this.getTruncatedOptions(selectedValue),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/form/element/dropdownItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const propTypes = {
onClick: PropTypes.func.isRequired,

// The value of the option, should be unique
value: PropTypes.any.isRequired,
value: PropTypes.any.isRequired, // eslint-disable-line react/forbid-prop-types

// The human readable text of the option
text: PropTypes.string,
Expand Down
12 changes: 8 additions & 4 deletions lib/components/form/element/switch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* globals Func, Modal */

import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import cn from 'classnames';
import _ from 'underscore';
Expand All @@ -24,7 +23,7 @@ const propTypes = {

// A configuration object that is passed to Modal.confirm() if we want to have
// the user confirm their choice
confirm: PropTypes.object,
confirm: PropTypes.object, // eslint-disable-line react/forbid-prop-types

// An array of extra classes to put on the combobox
extraClasses: PropTypes.oneOfType([
Expand Down Expand Up @@ -59,10 +58,11 @@ class Switch extends React.Component {
this.showConfirm = this.showConfirm.bind(this);

this.checkbox = null;
this.element = null;
}

componentDidMount() {
$(ReactDOM.findDOMNode(this)).tooltip('destroy').tooltip();
$(this.element).tooltip('destroy').tooltip();
}

/**
Expand Down Expand Up @@ -111,7 +111,11 @@ class Switch extends React.Component {

render() {
return (
<span className={cn('onoffswitch-wrapper js_tooltip', this.props.extraClasses)} title={this.props.tooltipText}>
<span
className={cn('onoffswitch-wrapper js_tooltip', this.props.extraClasses)}
title={this.props.tooltipText}
ref={el => this.element = el}
>
<input
ref={el => this.checkbox = el}
type="checkbox"
Expand Down
40 changes: 20 additions & 20 deletions lib/jquery.expensifyIframify.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
*
* @type {Object} jQuery Element
*/
let self = null;
let iframeElement = null; // eslint-disable-line consistent-this

/**
* Whether or not the parent window is listening to the message event
Expand Down Expand Up @@ -115,7 +115,7 @@ export default {
const source = whatIAm === 'parent' ? 'Parent' : 'Iframe';
mainArguments.unshift(`${source}:`);
mainArguments.unshift('[EXPENSIFYIFRAMEIFY]');
console.log(...mainArguments);
console.log(...mainArguments); // eslint-disable-line no-console
}
}

Expand All @@ -141,8 +141,8 @@ export default {
*/
function postMessage(name, data, postToIframe) {
let msg = 'iframeify';
if (self.iframeId) {
msg += `:${self.iframeId}`;
if (iframeElement.iframeId) {
msg += `:${iframeElement.iframeId}`;
}

msg += `:${name}`;
Expand All @@ -169,10 +169,10 @@ export default {
}

// Sending message from the parent to the iFrame
if (postToIframe && self[0].contentWindow) {
targetOrigin = `${self[0].contentWindow.location.protocol}//${self[0].contentWindow.location.hostname}`;
if (postToIframe && iframeElement[0].contentWindow) {
targetOrigin = `${iframeElement[0].contentWindow.location.protocol}//${iframeElement[0].contentWindow.location.hostname}`;
log('posting message to iframe', targetOrigin, msg);
self[0].contentWindow.postMessage(msg, targetOrigin);
iframeElement[0].contentWindow.postMessage(msg, targetOrigin);
}
}

Expand All @@ -186,7 +186,7 @@ export default {
*/
function trigger(name, data, iframeId) {
log(`heard event "${name}"`, data);
const id = iframeId || self.iframeId;
const id = iframeId || iframeElement.iframeId;
if (eventHandlers[id] && eventHandlers[id][name] && eventHandlers[id][name].length) {
const listeners = eventHandlers[id][name];
for (let i = 0; i < listeners.length; i += 1) {
Expand Down Expand Up @@ -315,15 +315,15 @@ export default {
*/
on(name, callback) {
log(`listening to event "${name}"`);
if (!eventHandlers[self.iframeId]) {
eventHandlers[self.iframeId] = {};
if (!eventHandlers[iframeElement.iframeId]) {
eventHandlers[iframeElement.iframeId] = {};
}

if (!eventHandlers[self.iframeId][name]) {
eventHandlers[self.iframeId][name] = [];
if (!eventHandlers[iframeElement.iframeId][name]) {
eventHandlers[iframeElement.iframeId][name] = [];
}

eventHandlers[self.iframeId][name].push(callback);
eventHandlers[iframeElement.iframeId][name].push(callback);
},

/**
Expand All @@ -334,12 +334,12 @@ export default {
*/
off(name) {
log(`stop listening to event "${name}"`);
if (self.iframeId) {
if (eventHandlers[self.iframeId]) {
if (iframeElement.iframeId) {
if (eventHandlers[iframeElement.iframeId]) {
if (!name) {
eventHandlers[self.iframeId] = {};
eventHandlers[iframeElement.iframeId] = {};
} else {
delete eventHandlers[self.iframeId][name];
delete eventHandlers[iframeElement.iframeId][name];
}
}
} else if (!name) {
Expand All @@ -361,7 +361,7 @@ export default {
$(window).off('message', handleWindowMessage);
parentIsListening = false;
iframeIsListening = false;
self = null;
iframeElement = null;
}
};

Expand All @@ -386,7 +386,7 @@ export default {

// There are some browsers that don't support document.domain so we have to manually create it
document.domain = domainWithoutSubdomain;
self = this;
iframeElement = this; // eslint-disable-line consistent-this

if (!wasInitalized) {
// Determine if this is the parent, or the iframe
Expand All @@ -407,7 +407,7 @@ export default {
// $( '#myIframe' ).expensifyIframeify();
//
// 'myIframe' would be the frameId
self.iframeId = whatIAm === 'iframe' ? $(window.frameElement).attr('id') : self.attr('id');
iframeElement.iframeId = whatIAm === 'iframe' ? $(window.frameElement).attr('id') : iframeElement.attr('id');

// Figure out if we are doing an action or setting options
if (typeof actionOrOptions === 'string') {
Expand Down
Loading