Skip to content

Commit bf8c8f6

Browse files
authored
Merge pull request #6174 from Expensify/marcaaron-updateEslintConfig
2 parents b12eb5f + 28e1dea commit bf8c8f6

File tree

102 files changed

+1210
-766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1210
-766
lines changed

.eslintrc.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ module.exports = {
22
extends: 'expensify',
33
parser: 'babel-eslint',
44
ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js'],
5-
rules: {
6-
'react/jsx-filename-extension': [1, {extensions: ['.js']}],
7-
'comma-dangle': ['error', 'always-multiline'],
8-
},
95
plugins: ['detox'],
106
env: {
117
jest: true,

.github/actions/bumpVersion/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ exports.updateiOSVersion = function updateiOSVersion(version) {
181181
/***/ }),
182182

183183
/***/ 7:
184-
/***/ ((module) => {
184+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
185+
186+
const _ = __nccwpck_require__(571);
185187

186188
const SEMANTIC_VERSION_LEVELS = {
187189
MAJOR: 'MAJOR',
@@ -199,7 +201,7 @@ const MAX_INCREMENTS = 99;
199201
*/
200202
const getVersionNumberFromString = (versionString) => {
201203
const [version, build] = versionString.split('-');
202-
const [major, minor, patch] = version.split('.').map(n => Number(n));
204+
const [major, minor, patch] = _.map(version.split('.'), n => Number(n));
203205

204206
return [major, minor, patch, Number.isInteger(Number(build)) ? Number(build) : 0];
205207
};

.github/actions/isPullRequestMergeable/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ const run = function () {
2929
pull_number: pullRequestNumber,
3030
})
3131
.then(({data}) => {
32-
if (!_.isNull(data.mergeable)) {
33-
console.log('Pull request mergeability is not yet resolved...');
34-
retryCount++;
35-
mergeabilityResolved = true;
36-
isMergeable = data.mergeable;
32+
if (_.isNull(data.mergeable)) {
33+
return;
3734
}
35+
36+
console.log('Pull request mergeability is not yet resolved...');
37+
retryCount++;
38+
mergeabilityResolved = true;
39+
isMergeable = data.mergeable;
3840
})
3941
.catch((githubError) => {
4042
mergeabilityResolved = true;

.github/actions/isPullRequestMergeable/isPullRequestMergeable.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ const run = function () {
1919
pull_number: pullRequestNumber,
2020
})
2121
.then(({data}) => {
22-
if (!_.isNull(data.mergeable)) {
23-
console.log('Pull request mergeability is not yet resolved...');
24-
retryCount++;
25-
mergeabilityResolved = true;
26-
isMergeable = data.mergeable;
22+
if (_.isNull(data.mergeable)) {
23+
return;
2724
}
25+
26+
console.log('Pull request mergeability is not yet resolved...');
27+
retryCount++;
28+
mergeabilityResolved = true;
29+
isMergeable = data.mergeable;
2830
})
2931
.catch((githubError) => {
3032
mergeabilityResolved = true;

.github/actions/markPullRequestsAsDeployed/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const run = function () {
9797
.then((actor) => {
9898
// Create comment on each pull request (one after another to avoid throttling issues)
9999
const deployMessage = getDeployMessage(actor, 'Deployed');
100-
prList.reduce((promise, pr) => promise.then(() => commentPR(pr, deployMessage)), Promise.resolve());
100+
_.reduce(prList, (promise, pr) => promise.then(() => commentPR(pr, deployMessage)), Promise.resolve());
101101
});
102102
}
103103

@@ -117,7 +117,7 @@ const run = function () {
117117
})
118118
.then(({data}) => {
119119
const isCP = /Merge pull request #\d+ from Expensify\/.*-?cherry-pick-staging-\d+/.test(data.message);
120-
prList.reduce((promise, PR) => promise
120+
_.reduce(prList, (promise, PR) => promise
121121

122122
// Then, for each PR, find out who merged it and determine the deployer
123123
.then(() => GithubUtils.octokit.pulls.get({

.github/actions/markPullRequestsAsDeployed/markPullRequestsAsDeployed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const run = function () {
8787
.then((actor) => {
8888
// Create comment on each pull request (one after another to avoid throttling issues)
8989
const deployMessage = getDeployMessage(actor, 'Deployed');
90-
prList.reduce((promise, pr) => promise.then(() => commentPR(pr, deployMessage)), Promise.resolve());
90+
_.reduce(prList, (promise, pr) => promise.then(() => commentPR(pr, deployMessage)), Promise.resolve());
9191
});
9292
}
9393

@@ -107,7 +107,7 @@ const run = function () {
107107
})
108108
.then(({data}) => {
109109
const isCP = /Merge pull request #\d+ from Expensify\/.*-?cherry-pick-staging-\d+/.test(data.message);
110-
prList.reduce((promise, PR) => promise
110+
_.reduce(prList, (promise, PR) => promise
111111

112112
// Then, for each PR, find out who merged it and determine the deployer
113113
.then(() => GithubUtils.octokit.pulls.get({

.github/libs/versionUpdater.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const _ = require('underscore');
2+
13
const SEMANTIC_VERSION_LEVELS = {
24
MAJOR: 'MAJOR',
35
MINOR: 'MINOR',
@@ -14,7 +16,7 @@ const MAX_INCREMENTS = 99;
1416
*/
1517
const getVersionNumberFromString = (versionString) => {
1618
const [version, build] = versionString.split('-');
17-
const [major, minor, patch] = version.split('.').map(n => Number(n));
19+
const [major, minor, patch] = _.map(version.split('.'), n => Number(n));
1820

1921
return [major, minor, patch, Number.isInteger(Number(build)) ? Number(build) : 0];
2022
};

.storybook/webpack.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-disable no-param-reassign */
33
const path = require('path');
44
const dotenv = require('dotenv');
5+
const _ = require('underscore');
56
const custom = require('../config/webpack/webpack.common');
67

78
const env = dotenv.config({path: path.resolve(__dirname, '../.env.staging')}).parsed;
@@ -14,16 +15,16 @@ module.exports = ({config}) => {
1415
};
1516

1617
// Necessary to overwrite the values in the existing DefinePlugin hardcoded to the Config staging values
17-
const definePluginIndex = config.plugins.findIndex(plugin => plugin.constructor.name === 'DefinePlugin');
18+
const definePluginIndex = _.findIndex(config.plugins, plugin => plugin.constructor.name === 'DefinePlugin');
1819
config.plugins[definePluginIndex].definitions.__REACT_WEB_CONFIG__ = JSON.stringify(env);
1920
config.resolve.extensions.push('.web.js', '.website.js');
2021

21-
const babelRulesIndex = custom.module.rules.findIndex(rule => rule.loader === 'babel-loader');
22+
const babelRulesIndex = _.findIndex(custom.module.rules, rule => rule.loader === 'babel-loader');
2223
const babelRule = custom.module.rules[babelRulesIndex];
2324
config.module.rules.push(babelRule);
2425

2526
// Allows loading SVG - more context here https://github.com/storybookjs/storybook/issues/6188
26-
const fileLoaderRule = config.module.rules.find(rule => rule.test && rule.test.test('.svg'));
27+
const fileLoaderRule = _.find(config.module.rules, rule => rule.test && rule.test.test('.svg'));
2728
fileLoaderRule.exclude = /\.svg$/;
2829
config.module.rules.push({
2930
test: /\.svg$/,

config/checkMetroBundlerPort.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ const {isPackagerRunning} = require('@react-native-community/cli-tools');
88
* - `unrecognized`: one other process is running on the port we expect the packager to be running.
99
*/
1010
isPackagerRunning().then((result) => {
11-
if (result === 'unrecognized') {
12-
console.error(
13-
'The port 8081 is currently in use.',
14-
'You can run `lsof -i :8081` to see which program is using it.\n',
15-
);
16-
process.exit(1);
11+
if (result !== 'unrecognized') {
12+
return;
1713
}
14+
15+
console.error(
16+
'The port 8081 is currently in use.',
17+
'You can run `lsof -i :8081` to see which program is using it.\n',
18+
);
19+
process.exit(1);
1820
});

config/webpack/webpack.common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const _ = require('underscore');
12
const path = require('path');
23
const {IgnorePlugin} = require('webpack');
34
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
@@ -7,7 +8,7 @@ const CustomVersionFilePlugin = require('./CustomVersionFilePlugin');
78

89
// Check for a --platform command line argument (default to 'web')
910
// If it is 'web', we want to ignore .desktop.js files, and if it is 'desktop', we want to ignore .website.js files.
10-
const platformIndex = process.argv.findIndex(arg => arg === '--platform');
11+
const platformIndex = _.findIndex(process.argv, arg => arg === '--platform');
1112
const platform = (platformIndex > 0) ? process.argv[platformIndex + 1] : 'web';
1213
const platformExclude = platform === 'web' ? new RegExp(/\.desktop\.js$/) : new RegExp(/\.website\.js$/);
1314

config/webpack/webpack.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22
const webpack = require('webpack');
33
const {merge} = require('webpack-merge');
44
const dotenv = require('dotenv');
5-
const common = require('./webpack.common.js');
5+
const common = require('./webpack.common');
66

77
const env = dotenv.config({path: path.resolve(__dirname, '../../.env')}).parsed;
88

config/webpack/webpack.prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22
const {merge} = require('webpack-merge');
33
const dotenv = require('dotenv');
4-
const common = require('./webpack.common.js');
4+
const common = require('./webpack.common');
55
const getProductionConfig = require('./productionConfig');
66

77
const env = dotenv.config({path: path.resolve(__dirname, '../../.env.production')}).parsed;

config/webpack/webpack.staging.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22
const {merge} = require('webpack-merge');
33
const dotenv = require('dotenv');
4-
const common = require('./webpack.common.js');
4+
const common = require('./webpack.common');
55
const getProductionConfig = require('./productionConfig');
66

77
const env = dotenv.config({path: path.resolve(__dirname, '../../.env.staging')}).parsed;

desktop/main.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
shell,
77
ipcMain,
88
} = require('electron');
9+
const _ = require('underscore');
910
const serve = require('electron-serve');
1011
const contextMenu = require('electron-context-menu');
1112
const {autoUpdater} = require('electron-updater');
@@ -41,7 +42,7 @@ autoUpdater.logger.transports.file.level = 'info';
4142

4243
// Send all Console logs to a log file: ~/Library/Logs/new.expensify/main.log
4344
// See https://www.npmjs.com/package/electron-log
44-
Object.assign(console, log.functions);
45+
_.assign(console, log.functions);
4546

4647
// setup Hot reload
4748
if (isDev) {
@@ -155,18 +156,18 @@ const mainWindow = (() => {
155156
}],
156157
}));
157158

158-
const appMenu = systemMenu.items.find(item => item.role === 'appmenu');
159+
const appMenu = _.find(systemMenu.items, item => item.role === 'appmenu');
159160
appMenu.submenu.insert(1, updateAppMenuItem);
160161

161162
// On mac, pressing cmd++ actually sends a cmd+=. cmd++ is generally the zoom in shortcut, but this is
162163
// not properly listened for by electron. Adding in an invisible cmd+= listener fixes this.
163-
const viewWindow = systemMenu.items.find(item => item.role === 'viewmenu');
164+
const viewWindow = _.find(systemMenu.items, item => item.role === 'viewmenu');
164165
viewWindow.submenu.append(new MenuItem({
165166
role: 'zoomin',
166167
accelerator: 'CommandOrControl+=',
167168
visible: false,
168169
}));
169-
const windowMenu = systemMenu.items.find(item => item.role === 'windowmenu');
170+
const windowMenu = _.find(systemMenu.items, item => item.role === 'windowmenu');
170171
windowMenu.submenu.append(new MenuItem({type: 'separator'}));
171172
windowMenu.submenu.append(new MenuItem({
172173
label: 'New Expensify',
@@ -193,10 +194,12 @@ const mainWindow = (() => {
193194

194195
// Closing the chat window should just hide it (vs. fully quitting the application)
195196
browserWindow.on('close', (evt) => {
196-
if (!quitting && !hasUpdate) {
197-
evt.preventDefault();
198-
browserWindow.hide();
197+
if (quitting || hasUpdate) {
198+
return;
199199
}
200+
201+
evt.preventDefault();
202+
browserWindow.hide();
200203
});
201204

202205
// Initiating a browser-back or browser-forward with mouse buttons should navigate history.
@@ -211,9 +214,11 @@ const mainWindow = (() => {
211214

212215
app.on('before-quit', () => quitting = true);
213216
app.on('activate', () => {
214-
if (!expectedUpdateVersion || app.getVersion() === expectedUpdateVersion) {
215-
browserWindow.show();
217+
if (expectedUpdateVersion && app.getVersion() !== expectedUpdateVersion) {
218+
return;
216219
}
220+
221+
browserWindow.show();
217222
});
218223

219224
// Hide the app if we expected to upgrade to a new version but never did.
@@ -259,9 +264,11 @@ const mainWindow = (() => {
259264

260265
// Start checking for JS updates
261266
.then((browserWindow) => {
262-
if (!isDev) {
263-
checkForUpdates(electronUpdater(browserWindow));
267+
if (isDev) {
268+
return;
264269
}
270+
271+
checkForUpdates(electronUpdater(browserWindow));
265272
});
266273
});
267274

metro.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
*/
55

66
const {getDefaultConfig} = require('metro-config');
7+
const _ = require('underscore');
78

89
/* eslint arrow-body-style: 0 */
910
module.exports = (() => {
1011
return getDefaultConfig()
1112
.then((config) => {
1213
return {
1314
resolver: {
14-
assetExts: config.resolver.assetExts.filter(ext => ext !== 'svg'),
15+
assetExts: _.filter(config.resolver.assetExts, ext => ext !== 'svg'),
1516
sourceExts: ['jsx', 'js', 'ts', 'tsx', 'json', 'svg'],
1617
},
1718
transformer: {

0 commit comments

Comments
 (0)