Skip to content

Commit 557bffb

Browse files
committed
(maint) Simple eslint fixes
Apply all eslint automated fixes using existing rulesets.
1 parent 2a23ee3 commit 557bffb

22 files changed

+118
-118
lines changed

src/configuration.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class AggregateConfiguration implements IAggregateConfiguration {
139139
}
140140

141141
private safeJoin(...paths: string[]): string {
142-
let foundUndefined: Boolean = false;
142+
let foundUndefined = false;
143143
// path.join makes sure that no elements are 'undefined' and throws if there is. Instead
144144
// we can search for it and just return undefined ourself.
145145
paths.forEach((item) => {
@@ -182,24 +182,24 @@ export class AggregateConfiguration implements IAggregateConfiguration {
182182
puppetBaseDir: string,
183183
rubydir: string,
184184
): string {
185-
return new Array(
185+
return [
186186
path.join(puppetDir, 'bin'),
187187
path.join(facterDir, 'bin'),
188188
// path.join(hieraDir, 'bin'),
189189
path.join(puppetBaseDir, 'bin'),
190190
path.join(rubydir, 'bin'),
191191
path.join(puppetBaseDir, 'sys', 'tools', 'bin'),
192-
).join(PathResolver.pathEnvSeparator());
192+
].join(PathResolver.pathEnvSeparator());
193193
}
194194

195195
// RUBYLIB=%PUPPET_DIR%\lib;%FACTERDIR%\lib;%HIERA_DIR%\lib;%RUBYLIB%
196196
private calculateRubylib(puppetDir: string, facterDir: string): string {
197197
return this.replaceSlashes(
198-
new Array(
198+
[
199199
path.join(puppetDir, 'lib'),
200200
path.join(facterDir, 'lib'),
201201
// path.join(this.hieraDir, 'lib'),
202-
).join(PathResolver.pathEnvSeparator()),
202+
].join(PathResolver.pathEnvSeparator()),
203203
);
204204
}
205205

@@ -232,7 +232,7 @@ export class AggregateConfiguration implements IAggregateConfiguration {
232232
}
233233

234234
private getAgentBasePath() {
235-
let programFiles = PathResolver.getprogramFiles();
235+
const programFiles = PathResolver.getprogramFiles();
236236
switch (process.platform) {
237237
case 'win32':
238238
// On Windows we have a subfolder called 'Puppet' that has
@@ -245,7 +245,7 @@ export class AggregateConfiguration implements IAggregateConfiguration {
245245
}
246246

247247
private getPdkBasePath() {
248-
let programFiles = PathResolver.getprogramFiles();
248+
const programFiles = PathResolver.getprogramFiles();
249249
switch (process.platform) {
250250
case 'win32':
251251
return path.join(programFiles, 'Puppet Labs', 'DevelopmentKit');
@@ -255,9 +255,9 @@ export class AggregateConfiguration implements IAggregateConfiguration {
255255
}
256256

257257
private getPdkVersionFromFile(puppetBaseDir: string) {
258-
let basePath = path.join(puppetBaseDir, 'PDK_VERSION');
258+
const basePath = path.join(puppetBaseDir, 'PDK_VERSION');
259259
if (fs.existsSync(basePath)) {
260-
let contents = fs.readFileSync(basePath, 'utf8').toString();
260+
const contents = fs.readFileSync(basePath, 'utf8').toString();
261261
return contents.trim();
262262
} else {
263263
return '';
@@ -268,8 +268,8 @@ export class AggregateConfiguration implements IAggregateConfiguration {
268268
if (!fs.existsSync(rootDir)) {
269269
return undefined;
270270
}
271-
var files = fs.readdirSync(rootDir);
272-
let result = files.sort((a, b) => a.localeCompare(b, undefined, { numeric: true })).reverse()[0];
271+
const files = fs.readdirSync(rootDir);
272+
const result = files.sort((a, b) => a.localeCompare(b, undefined, { numeric: true })).reverse()[0];
273273
return path.join(rootDir, result);
274274
}
275275

src/configuration/pathResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ export class PathResolver {
1818
}
1919

2020
public static resolveSubDirectory(rootDir: string, subDir: string) {
21-
var versionDir = path.join(rootDir, subDir);
21+
const versionDir = path.join(rootDir, subDir);
2222

2323
if (fs.existsSync(versionDir)) {
2424
return versionDir;
2525
} else {
26-
var subdir = PathResolver.getDirectories(rootDir)[1];
26+
const subdir = PathResolver.getDirectories(rootDir)[1];
2727
return subdir;
2828
}
2929
}

src/configuration/pdkResolver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class PDKRubyInstances implements IPDKRubyInstances {
8484
return this.rubyInstances;
8585
}
8686

87-
var rubyDir = path.join(this.pdkDirectory, 'private', 'ruby');
87+
const rubyDir = path.join(this.pdkDirectory, 'private', 'ruby');
8888
if (!fs.existsSync(rubyDir)) {
8989
return this.rubyInstances;
9090
}
@@ -199,7 +199,7 @@ class PDKRubyInstance implements IPDKRubyInstance {
199199
return this._puppetVersions;
200200
}
201201
this._puppetVersions = [];
202-
let gemdir = path.join(this._rubyVerDir, 'gems');
202+
const gemdir = path.join(this._rubyVerDir, 'gems');
203203
if (!fs.existsSync(gemdir)) {
204204
return this._puppetVersions;
205205
}
@@ -208,7 +208,7 @@ class PDKRubyInstance implements IPDKRubyInstance {
208208
// the gem cache is just as easy and doesn't need to spawn a ruby process per
209209
// ruby version.
210210
fs.readdirSync(gemdir).forEach((item) => {
211-
let pathMatch = item.match(/^puppet-(\d+\.\d+\.\d+)(?:(-|$))/);
211+
const pathMatch = item.match(/^puppet-(\d+\.\d+\.\d+)(?:(-|$))/);
212212
if (pathMatch !== null) {
213213
this._puppetVersions.push(pathMatch[1]);
214214
}
@@ -242,7 +242,7 @@ class PDKRubyInstance implements IPDKRubyInstance {
242242
// This is a little naive however there doesn't appear to be a native semver module
243243
// loaded in VS Code. The gem path is always the <Major>.<Minor>.0 version of the
244244
// corresponding Ruby version
245-
let gemDirName = this._rubyVersion.replace(/\.\d+$/, '.0');
245+
const gemDirName = this._rubyVersion.replace(/\.\d+$/, '.0');
246246
// Calculate gem paths
247247
this._rubyVerDir = path.join(pdkDirectory, 'private', 'puppet', 'ruby', gemDirName);
248248
this._gemVerDir = path.join(this._rubyDir, 'lib', 'ruby', 'gems', gemDirName);

src/extension.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ let configSettings: IAggregateConfiguration;
3636
let extensionFeatures: IFeature[] = [];
3737

3838
export function activate(context: vscode.ExtensionContext) {
39-
let pkg = vscode.extensions.getExtension('jpogran.puppet-vscode');
39+
const pkg = vscode.extensions.getExtension('jpogran.puppet-vscode');
4040
if (pkg) {
41-
let message =
41+
const message =
4242
'The "jpogran.puppet-vscode" extension has been detected, which will conflict with the "puppet.puppet-vscode" extension. This will cause problems activating when each extension tries to load at the same time and may cause errors. Please uninstall it by executing the following from the commandline: "code --uninstall-extension jpogran.puppet-vscode"';
4343
vscode.window.showWarningMessage(message, { modal: false });
4444
}
@@ -116,7 +116,7 @@ export function activate(context: vscode.ExtensionContext) {
116116
extensionFeatures.push(new PuppetModuleHoverFeature(extContext, logger));
117117
}
118118

119-
let facts = new PuppetFactsProvider(connectionHandler);
119+
const facts = new PuppetFactsProvider(connectionHandler);
120120
vscode.window.registerTreeDataProvider('puppetFacts', facts);
121121
}
122122

@@ -134,9 +134,9 @@ export function deactivate() {
134134

135135
function checkForLegacySettings() {
136136
// Raise a warning if we detect any legacy settings
137-
const legacySettingValues: Map<string, Object> = legacySettings();
137+
const legacySettingValues: Map<string, Record<string, any>> = legacySettings();
138138
if (legacySettingValues.size > 0) {
139-
let settingNames: string[] = [];
139+
const settingNames: string[] = [];
140140
for (const [settingName, _value] of legacySettingValues) {
141141
settingNames.push(settingName);
142142
}
@@ -163,7 +163,7 @@ function checkInstallDirectory(config: IAggregateConfiguration, logger: ILogger)
163163
// Need to use SettingsFromWorkspace() here because the AggregateConfiguration
164164
// changes the installType from Auto, to its calculated value
165165
if (SettingsFromWorkspace().installType === PuppetInstallType.AUTO) {
166-
let m = [
166+
const m = [
167167
'The extension failed to find a Puppet installation automatically in the default locations for PDK and for Puppet Agent.',
168168
'While syntax highlighting and grammar detection will still work, intellisense and other advanced features will not.',
169169
];

src/feature/BoltFeature.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class BoltFeature implements IFeature {
88
dispose() {}
99

1010
showDeprecation() {
11-
let message =
11+
const message =
1212
'The "Open Bolt User Configuration File" and "Open Bolt User Inventory File" commands will be removed in a future release. Do you think they should be kept? Think there are other ways for this extension to help using Puppet Bolt? Let us know by clicking "Feedback" to add a comment to Github Issue #639';
1313
window.showWarningMessage(message, { modal: false }, { title: 'Feedback' }).then((result) => {
1414
if (result === undefined) {
@@ -26,7 +26,7 @@ export class BoltFeature implements IFeature {
2626
commands.registerCommand('puppet-bolt.OpenUserConfigFile', () => {
2727
this.showDeprecation();
2828

29-
let userInventoryFile = path.join(process.env['USERPROFILE'] || '~', '.puppetlabs', 'bolt', 'bolt.yaml');
29+
const userInventoryFile = path.join(process.env['USERPROFILE'] || '~', '.puppetlabs', 'bolt', 'bolt.yaml');
3030

3131
this.openOrCreateFile(
3232
userInventoryFile,
@@ -44,7 +44,7 @@ export class BoltFeature implements IFeature {
4444
commands.registerCommand('puppet-bolt.OpenUserInventoryFile', () => {
4545
this.showDeprecation();
4646

47-
let userInventoryFile = path.join(process.env['USERPROFILE'] || '~', '.puppetlabs', 'bolt', 'inventory.yaml');
47+
const userInventoryFile = path.join(process.env['USERPROFILE'] || '~', '.puppetlabs', 'bolt', 'inventory.yaml');
4848

4949
this.openOrCreateFile(
5050
userInventoryFile,

src/feature/DebuggingFeature.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ export class DebugAdapterDescriptorFactory implements vscode.DebugAdapterDescrip
3636
): vscode.ProviderResult<vscode.DebugAdapterDescriptor> {
3737
// Right now we don't care about session as we only have one type of adapter, which is launch. When
3838
// we add the ability to attach to a debugger remotely we'll need to switch scenarios based on `session`
39-
let thisFactory = this;
39+
const thisFactory = this;
4040

4141
return new Promise<vscode.DebugAdapterDescriptor>(function (resolve, reject) {
42-
let debugServer = CommandEnvironmentHelper.getDebugServerRubyEnvFromConfiguration(
42+
const debugServer = CommandEnvironmentHelper.getDebugServerRubyEnvFromConfiguration(
4343
thisFactory.Context.asAbsolutePath(thisFactory.Config.ruby.debugServerPath),
4444
thisFactory.Config,
4545
);
4646

47-
let spawn_options: cp.SpawnOptions = {};
47+
const spawn_options: cp.SpawnOptions = {};
4848
spawn_options.env = debugServer.options.env;
4949
spawn_options.stdio = 'pipe';
5050
if (process.platform !== 'win32') {
@@ -54,17 +54,17 @@ export class DebugAdapterDescriptorFactory implements vscode.DebugAdapterDescrip
5454
thisFactory.Logger.verbose(
5555
'Starting the Debug Server with ' + debugServer.command + ' ' + debugServer.args.join(' '),
5656
);
57-
let debugServerProc = cp.spawn(debugServer.command, debugServer.args, spawn_options);
57+
const debugServerProc = cp.spawn(debugServer.command, debugServer.args, spawn_options);
5858
thisFactory.ChildProcesses.push(debugServerProc);
5959

60-
let debugSessionRunning: boolean = false;
60+
let debugSessionRunning = false;
6161
debugServerProc.stdout.on('data', (data) => {
6262
thisFactory.Logger.debug('Debug Server STDOUT: ' + data.toString());
6363
// If the debug client isn't already running and it's sent the trigger text, start up a client
6464
if (!debugSessionRunning && data.toString().match('DEBUG SERVER RUNNING') !== null) {
6565
debugSessionRunning = true;
6666

67-
var p = data.toString().match(/DEBUG SERVER RUNNING (.*):(\d+)/);
67+
const p = data.toString().match(/DEBUG SERVER RUNNING (.*):(\d+)/);
6868
if (p === null) {
6969
reject('Debug Server started but unable to parse hostname and port');
7070
} else {
@@ -119,7 +119,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
119119
}
120120

121121
private createLaunchConfigFromContext(folder: vscode.WorkspaceFolder | undefined): vscode.DebugConfiguration {
122-
let config = {
122+
const config = {
123123
type: this.debugType,
124124
request: 'launch',
125125
name: 'Puppet Apply current file',

src/feature/FormatDocumentFeature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class FormatDocumentProvider {
3232
return [];
3333
}
3434

35-
let requestParams = new RequestParams();
35+
const requestParams = new RequestParams();
3636
requestParams.documentUri = document.uri.toString(false);
3737
requestParams.alwaysReturnContent = false;
3838

src/feature/PDKFeature.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ export class PDKFeature implements IFeature {
5353
}
5454

5555
private pdkNewModuleCommand() {
56-
let nameOpts: vscode.QuickPickOptions = {
56+
const nameOpts: vscode.QuickPickOptions = {
5757
placeHolder: 'Enter a name for the new Puppet module',
5858
matchOnDescription: true,
5959
matchOnDetail: true,
6060
};
61-
let dirOpts: vscode.QuickPickOptions = {
61+
const dirOpts: vscode.QuickPickOptions = {
6262
placeHolder: 'Enter a path for the new Puppet module',
6363
matchOnDescription: true,
6464
matchOnDetail: true,
@@ -81,7 +81,7 @@ export class PDKFeature implements IFeature {
8181
}
8282

8383
private pdkNewClassCommand() {
84-
let nameOpts: vscode.QuickPickOptions = {
84+
const nameOpts: vscode.QuickPickOptions = {
8585
placeHolder: 'Enter a name for the new Puppet class',
8686
matchOnDescription: true,
8787
matchOnDetail: true,
@@ -96,7 +96,7 @@ export class PDKFeature implements IFeature {
9696
}
9797

9898
private pdkNewTaskCommand() {
99-
let nameOpts: vscode.QuickPickOptions = {
99+
const nameOpts: vscode.QuickPickOptions = {
100100
placeHolder: 'Enter a name for the new Puppet Task',
101101
matchOnDescription: true,
102102
matchOnDetail: true,

src/feature/PuppetModuleHoverFeature.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ILogger } from '../logging';
55

66
export class PuppetModuleHoverFeature implements IFeature {
77
constructor(public context: vscode.ExtensionContext, public logger: ILogger) {
8-
let selector = [{ language: 'json', scheme: '*', pattern: '**/metadata.json' }];
8+
const selector = [{ language: 'json', scheme: '*', pattern: '**/metadata.json' }];
99
context.subscriptions.push(vscode.languages.registerHoverProvider(selector, new PuppetModuleHoverProvider(logger)));
1010
}
1111

@@ -40,10 +40,10 @@ export class PuppetModuleHoverProvider implements vscode.HoverProvider {
4040

4141
this.logger.debug('Metadata hover info found ' + word + ' module');
4242

43-
let name = word.replace('"', '').replace('"', '').replace('/', '-');
43+
const name = word.replace('"', '').replace('"', '').replace('/', '-');
4444

4545
return this.getModuleInfo(name).then(function (result: any) {
46-
let msg: string[] = [];
46+
const msg: string[] = [];
4747
msg.push(`### ${result.slug}`);
4848

4949
const releaseDate = new Date(result.releases[0].created_at);
@@ -64,14 +64,14 @@ export class PuppetModuleHoverProvider implements vscode.HoverProvider {
6464
msg.push(`\nProject: \[${result.homepage_url}\](${result.homepage_url})\n`);
6565
}
6666

67-
let md = msg.join('\n');
67+
const md = msg.join('\n');
6868

6969
return Promise.resolve(new vscode.Hover(new vscode.MarkdownString(md), range));
7070
});
7171
}
7272

7373
private getModuleInfo(name: string) {
74-
var options = {
74+
const options = {
7575
url: `https://forgeapi.puppet.com/v3/modules/${name}?exclude_fields=readme%20changelog%20license%20reference`,
7676
};
7777
return new Promise(function (resolve, reject) {

src/feature/PuppetNodeGraphFeature.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class PuppetNodeGraphFeature implements IFeature {
4040
return;
4141
}
4242

43-
let provider = new NodeGraphWebViewProvider(
43+
const provider = new NodeGraphWebViewProvider(
4444
vscode.window.activeTextEditor.document.uri,
4545
handler,
4646
logger,
@@ -81,7 +81,7 @@ class NodeGraphWebViewProvider implements vscode.Disposable {
8181
protected logger: ILogger,
8282
protected context: vscode.ExtensionContext,
8383
) {
84-
let fileName = path.basename(resource.fsPath);
84+
const fileName = path.basename(resource.fsPath);
8585
this.panel = vscode.window.createWebviewPanel(
8686
'puppetNodeGraph', // Identifies the type of the webview. Used internally
8787
`Node Graph '${fileName}'`, // Title of the panel displayed to the user
@@ -104,8 +104,8 @@ class NodeGraphWebViewProvider implements vscode.Disposable {
104104
});
105105
}
106106

107-
async show(redraw: boolean = false) {
108-
let notificationType = this.getNotificationType();
107+
async show(redraw = false) {
108+
const notificationType = this.getNotificationType();
109109
if (notificationType === undefined) {
110110
return this.connectionHandler.languageClient
111111
.sendRequest(PuppetNodeGraphRequest.type, {
@@ -165,7 +165,7 @@ class NodeGraphWebViewProvider implements vscode.Disposable {
165165
// Calculate where the progress message should go, if at all.
166166
const currentSettings: ISettings = SettingsFromWorkspace();
167167

168-
var notificationType = vscode.ProgressLocation.Notification;
168+
let notificationType = vscode.ProgressLocation.Notification;
169169

170170
if (currentSettings.notification !== undefined && currentSettings.notification.nodeGraph !== undefined) {
171171
switch (currentSettings.notification.nodeGraph.toLowerCase()) {
@@ -187,17 +187,17 @@ class NodeGraphWebViewProvider implements vscode.Disposable {
187187
}
188188

189189
private getHtml(extensionPath: string): string {
190-
let cytoPath = this.panel.webview.asWebviewUri(
190+
const cytoPath = this.panel.webview.asWebviewUri(
191191
vscode.Uri.file(path.join(extensionPath, 'vendor', 'cytoscape', 'cytoscape.min.js')),
192192
);
193-
let mainScript = this.panel.webview.asWebviewUri(
193+
const mainScript = this.panel.webview.asWebviewUri(
194194
vscode.Uri.file(path.join(extensionPath, 'assets', 'js', 'main.js')),
195195
);
196-
let mainCss = this.panel.webview.asWebviewUri(
196+
const mainCss = this.panel.webview.asWebviewUri(
197197
vscode.Uri.file(path.join(extensionPath, 'assets', 'css', 'main.css')),
198198
);
199199

200-
let html = `<!DOCTYPE html>
200+
const html = `<!DOCTYPE html>
201201
<html>
202202
<head>
203203
<meta charset="UTF-8">

0 commit comments

Comments
 (0)