Skip to content

Commit cefc6d7

Browse files
committed
Fixed utils eslint issues
1 parent d81b7f0 commit cefc6d7

File tree

6 files changed

+30
-38
lines changed

6 files changed

+30
-38
lines changed

packages/utils/lib/config-manager.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ export class ConfigManagerOptions {
1313
configPaths = ConfigManagerOptions.DEFAULT_CONFIG_PATHS,
1414
...rest
1515
} = {}) {
16-
1716
/**
1817
* The path where to load the config from.
1918
* If an array of paths is passed, all found configs will be merged in that order.
2019
* @type {string|Array<string>}
2120
*/
2221
this.configPaths = configPaths;
2322

24-
// Allows for additional properties to be inherited
23+
// Allows for additional properties to be inherited
2524
Object.assign(this, rest);
2625
}
2726
}
@@ -71,9 +70,6 @@ export class ConfigManager {
7170
return null;
7271
}
7372

74-
constructor() {
75-
}
76-
7773
/**
7874
* Loads the config in the following order of overrides:
7975
* defaults < json < user < argv
@@ -85,13 +81,13 @@ export class ConfigManager {
8581
*/
8682
loadConfig(userConfig = null, yargsCallback = null) {
8783
if (userConfig) {
88-
this._config = {...this._config, ...userConfig};
84+
this._config = { ...this._config, ...userConfig };
8985
}
9086

9187
let argv = yargs(hideBin(process.argv))
9288
.parserConfiguration({
9389
// See https://github.com/yargs/yargs-parser#camel-case-expansion
94-
"camel-case-expansion": false
90+
'camel-case-expansion': false
9591
})
9692
.config('config', 'Path to your config file. Can contain comments.', this._loadConfigFromFile.bind(this));
9793

@@ -101,13 +97,13 @@ export class ConfigManager {
10197

10298
const parsedArgv = argv.help().parse();
10399

104-
this._config = {...this._config, ...parsedArgv};
100+
this._config = { ...this._config, ...parsedArgv };
105101

106102
// console.log(this._config);
107103

108104
if (!parsedArgv.config) {
109105
for (const configPath of this._config.configPaths) {
110-
this._config = {...this._config, ...this._loadConfigFromFile(configPath)};
106+
this._config = { ...this._config, ...this._loadConfigFromFile(configPath) };
111107
}
112108
}
113109

@@ -160,14 +156,12 @@ export class ConfigManager {
160156
absPath = resolvedPath;
161157
console.info(chalk.gray(`Loading config from ${chalk.white(absPath)}`));
162158
break;
163-
164159
} else if (i >= maxLevels) {
165160
throw new Error(`No config found at '${chalk.white(configPath)}'.`);
166-
167161
} else {
168162
const dirPath = path.dirname(absPath);
169163
const filePath = path.basename(absPath);
170-
const parentPath = path.resolve(dirPath, `..`, filePath);
164+
const parentPath = path.resolve(dirPath, '..', filePath);
171165

172166
if (absPath === parentPath) {
173167
// Can't navigate any more levels up
@@ -186,13 +180,12 @@ export class ConfigManager {
186180
}
187181

188182
return config;
189-
190183
} catch (err) {
191184
console.warn(`${err.message}`);
192185
}
193186

194-
return {};
187+
return {};
195188
}
196189
}
197190

198-
export default ConfigManager;
191+
export default ConfigManager;

packages/utils/lib/exec-script.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const execScript = async (script, cwd, logger = console) => {
1111
logger.debug(`execScript: '${script}'`);
1212
return new Promise((resolve, reject) => {
1313
const child = exec(script, {
14-
cwd: cwd
14+
cwd
1515
});
1616
child.stdout.on('data', (data) => {
1717
logger.info(data);
@@ -28,6 +28,6 @@ export const execScript = async (script, cwd, logger = console) => {
2828
resolve(code);
2929
});
3030
});
31-
}
31+
};
3232

33-
export default execScript;
33+
export default execScript;

packages/utils/lib/launch-from-cli.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const launchFromCli = async (importMeta, {
2020
relativePaths = null,
2121
yargsCallback = null
2222
} = {}) => {
23-
2423
// Ensure relativePaths is an array
2524
if (!relativePaths) {
2625
relativePaths = [];
@@ -29,6 +28,7 @@ export const launchFromCli = async (importMeta, {
2928
}
3029

3130
if (!isMain(importMeta, relativePaths)) {
31+
// eslint-disable-next-line prefer-promise-reject-errors
3232
return Promise.reject();
3333
}
3434

@@ -50,8 +50,7 @@ const isMain = (importMeta, relativePaths) => {
5050
const metaUrl = importMeta.url;
5151
/** @type {string} */
5252
const processUrl = url.pathToFileURL(process.argv[1]).href;
53-
return (metaUrl === processUrl)
54-
|| relativePaths.some(p => processUrl.endsWith(p));
55-
}
53+
return (metaUrl === processUrl) || relativePaths.some(p => processUrl.endsWith(p));
54+
};
5655

5756
export default launchFromCli;

packages/utils/lib/log-manager.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import path from 'path';
6-
import winston, { loggers } from 'winston';
6+
import winston from 'winston';
77
import Logger from 'winston/lib/winston/logger.js';
88
import 'winston-daily-rotate-file';
99
import slugify from '@sindresorhus/slugify';
@@ -81,7 +81,7 @@ export class LogOptions {
8181
* @type {boolean}
8282
* @default true
8383
*/
84-
this.overrideConsole = true;
84+
this.overrideConsole = true;
8585

8686
Object.assign(this, rest);
8787
}
@@ -154,7 +154,7 @@ export class LogFileOptions {
154154
}
155155
}
156156

157-
class LogManager {
157+
export class LogManager {
158158
/**
159159
* @type {LogManager}
160160
*/
@@ -190,10 +190,10 @@ class LogManager {
190190
...this._config,
191191
transports: [
192192
new winston.transports.Console({ level: this._config.level }),
193-
new winston.transports.DailyRotateFile({ ...this._config.fileOptions, filename: this.getFilePath('launchpad-info', false), level: 'info'}),
194-
new winston.transports.DailyRotateFile({ ...this._config.fileOptions, filename: this.getFilePath('launchpad-debug', false), level: 'debug'}),
195-
new winston.transports.DailyRotateFile({ ...this._config.fileOptions, filename: this.getFilePath('launchpad-error', false), level: 'error'}),
196-
],
193+
new winston.transports.DailyRotateFile({ ...this._config.fileOptions, filename: this.getFilePath('launchpad-info', false), level: 'info' }),
194+
new winston.transports.DailyRotateFile({ ...this._config.fileOptions, filename: this.getFilePath('launchpad-debug', false), level: 'debug' }),
195+
new winston.transports.DailyRotateFile({ ...this._config.fileOptions, filename: this.getFilePath('launchpad-error', false), level: 'error' })
196+
]
197197
});
198198

199199
if (this._config.overrideConsole) {
@@ -209,7 +209,7 @@ class LogManager {
209209
getLogger(moduleName = null, parent = null) {
210210
if (moduleName) {
211211
parent = parent || this._logger;
212-
const child = parent.child({module: moduleName});
212+
const child = parent.child({ module: moduleName });
213213
parent.once('close', () => child.close());
214214
return child;
215215
} else {
@@ -229,12 +229,11 @@ class LogManager {
229229
return output;
230230
}
231231

232-
233232
/**
234233
* Overrides console methods to use the parent logger instead
235234
* @private
236235
*/
237-
overrideConsoleMethods() {
236+
overrideConsoleMethods() {
238237
// Override console methods
239238
const logger = this.getLogger('console');
240239
console.log = logger.info.bind(logger);
@@ -247,7 +246,6 @@ class LogManager {
247246
// so we're freezing console here to prevent that from happening
248247
Object.freeze(console);
249248
}
250-
251249
}
252250

253251
export default LogManager;

packages/utils/lib/on-exit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
export const onExit = (callback = async () => {}, once = true, includeUncaught = false) => {
99
let triggered = false;
10-
const events = ['beforeExit', 'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT','SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM'];
10+
const events = ['beforeExit', 'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT', 'SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM'];
1111
if (includeUncaught) {
1212
events.push('uncaughtException', 'unhandledRejection');
1313
}
@@ -17,6 +17,6 @@ export const onExit = (callback = async () => {}, once = true, includeUncaught =
1717
}
1818
triggered = true;
1919
}));
20-
}
20+
};
2121

2222
export default onExit;

packages/utils/lib/task-queue.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as async from 'async';
22
import autoBind from 'auto-bind';
33
import chalk from 'chalk';
4-
import { default as LogManager, Logger } from './log-manager.js';
4+
import { LogManager, Logger } from './log-manager.js';
55

66
export class TaskQueueOptions {
77
constructor({
@@ -102,6 +102,7 @@ class Task {
102102
this.name = name;
103103
this.args = args;
104104
}
105+
105106
/**
106107
* @returns {Promise}
107108
*/
@@ -112,14 +113,15 @@ class Task {
112113
return this.taskFn(...this.args);
113114
}
114115
}
116+
115117
/**
116118
* @returns {string}
117119
*/
118120
toString() {
119121
const idStr = `#${this.id}`;
120-
return !!this.name ? `${idStr} (${this.name})` : idStr;
122+
return this.name ? `${idStr} (${this.name})` : idStr;
121123
}
122124
}
123125

124126
export default TaskQueue;
125-
export { Task };
127+
export { Task };

0 commit comments

Comments
 (0)