Skip to content

Commit 4077c07

Browse files
authored
lint: no-inner-declarations #3979
Since 14aab45, we can now enable this rule. https://eslint.org/docs/latest/rules/no-inner-declarations
1 parent 0aa56e8 commit 4077c07

File tree

4 files changed

+48
-45
lines changed

4 files changed

+48
-45
lines changed

.eslintrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ module.exports = {
8686
// This currently produces 700 non fixable by --fix errors
8787
'sort-imports': 'off',
8888
'@typescript-eslint/no-namespace': 'error',
89-
// Turn this on by removing off when we fix namespaces
90-
'no-inner-declarations': 'off',
9189
// This is off because prettier takes care of it
9290
'no-extra-semi': 'off',
9391
'no-null/no-null': 'error',

src/shared/sam/activation.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,26 @@ async function activateCodefileOverlays(
298298
async function createYamlExtensionPrompt(): Promise<void> {
299299
const settings = PromptSettings.instance
300300

301+
/**
302+
* Prompt the user to install the YAML plugin when AWSTemplateFormatVersion becomes available as a top level key
303+
* in the document
304+
* @param event An vscode text document change event
305+
* @returns nothing
306+
*/
307+
async function promptOnAWSTemplateFormatVersion(
308+
event: vscode.TextDocumentChangeEvent,
309+
yamlPromptDisposables: vscode.Disposable[]
310+
): Promise<void> {
311+
for (const change of event.contentChanges) {
312+
const changedLine = event.document.lineAt(change.range.start.line)
313+
if (changedLine.text.includes('AWSTemplateFormatVersion')) {
314+
promptInstallYamlPlugin(yamlPromptDisposables)
315+
return
316+
}
317+
}
318+
return
319+
}
320+
301321
// Show this only in VSCode since other VSCode-like IDEs (e.g. Theia) may
302322
// not have a marketplace or contain the YAML plugin.
303323
if (
@@ -327,23 +347,6 @@ async function createYamlExtensionPrompt(): Promise<void> {
327347
yamlPromptDisposables
328348
)
329349

330-
/**
331-
* Prompt the user to install the YAML plugin when AWSTemplateFormatVersion becomes available as a top level key
332-
* in the document
333-
* @param event An vscode text document change event
334-
* @returns nothing
335-
*/
336-
async function promptOnAWSTemplateFormatVersion(event: vscode.TextDocumentChangeEvent): Promise<void> {
337-
for (const change of event.contentChanges) {
338-
const changedLine = event.document.lineAt(change.range.start.line)
339-
if (changedLine.text.includes('AWSTemplateFormatVersion')) {
340-
promptInstallYamlPlugin(yamlPromptDisposables)
341-
return
342-
}
343-
}
344-
return
345-
}
346-
347350
const promptNotifications = new Map<string, Promise<unknown>>()
348351
vscode.workspace.onDidChangeTextDocument(
349352
(event: vscode.TextDocumentChangeEvent) => {
@@ -355,7 +358,9 @@ async function createYamlExtensionPrompt(): Promise<void> {
355358
) {
356359
promptNotifications.set(
357360
uri,
358-
promptOnAWSTemplateFormatVersion(event).finally(() => promptNotifications.delete(uri))
361+
promptOnAWSTemplateFormatVersion(event, yamlPromptDisposables).finally(() =>
362+
promptNotifications.delete(uri)
363+
)
359364
)
360365
}
361366
},

src/shared/sam/debugger/goSamDebug.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,22 @@ async function makeInstallScript(debuggerPath: string, isWindows: boolean): Prom
175175
// Go from trying to find the manifest file and uses GOPATH provided below.
176176
installOptions.env!['GO111MODULE'] = 'off'
177177

178+
function getDelveVersion(repo: string, silent: boolean): string {
179+
try {
180+
return execFileSync('git', ['-C', repo, 'describe', '--tags', '--abbrev=0']).toString().trim()
181+
} catch (e) {
182+
if (!silent) {
183+
throw e
184+
}
185+
return ''
186+
}
187+
}
188+
178189
// It's fine if we can't get the latest Delve version, the Toolkit will use the last built one instead
179190
try {
180191
const goPath: string = JSON.parse(execFileSync('go', ['env', '-json']).toString()).GOPATH
181192
let repoPath: string = path.join(goPath, 'src', delveRepo)
182193

183-
function getDelveVersion(repo: string, silent: boolean): string {
184-
try {
185-
return execFileSync('git', ['-C', repo, 'describe', '--tags', '--abbrev=0']).toString().trim()
186-
} catch (e) {
187-
if (!silent) {
188-
throw e
189-
}
190-
return ''
191-
}
192-
}
193-
194194
if (!getDelveVersion(repoPath, true)) {
195195
getLogger('channel').info(
196196
localize(

src/testInteg/sam.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,20 @@ describe('SAM Integration Tests', async function () {
420420
})
421421
})
422422

423+
function assertCodeLensReferencesHasSameRoot(codeLens: vscode.CodeLens, expectedUri: vscode.Uri) {
424+
assert.ok(codeLens.command, 'CodeLens did not have a command')
425+
const command = codeLens.command!
426+
427+
assert.ok(command.arguments, 'CodeLens command had no arguments')
428+
const commandArguments = command.arguments!
429+
430+
assert.strictEqual(commandArguments.length, 3, 'CodeLens command had unexpected arg count')
431+
const params: AddSamDebugConfigurationInput = commandArguments[0]
432+
assert.ok(params, 'unexpected non-defined command argument')
433+
434+
assert.strictEqual(path.dirname(params.rootUri.fsPath), path.dirname(expectedUri.fsPath))
435+
}
436+
423437
for (let scenarioIndex = 0; scenarioIndex < scenarios.length; scenarioIndex++) {
424438
const scenario = scenarios[scenarioIndex]
425439

@@ -624,20 +638,6 @@ describe('SAM Integration Tests', async function () {
624638
}
625639
})
626640
})
627-
628-
function assertCodeLensReferencesHasSameRoot(codeLens: vscode.CodeLens, expectedUri: vscode.Uri) {
629-
assert.ok(codeLens.command, 'CodeLens did not have a command')
630-
const command = codeLens.command!
631-
632-
assert.ok(command.arguments, 'CodeLens command had no arguments')
633-
const commandArguments = command.arguments!
634-
635-
assert.strictEqual(commandArguments.length, 3, 'CodeLens command had unexpected arg count')
636-
const params: AddSamDebugConfigurationInput = commandArguments[0]
637-
assert.ok(params, 'unexpected non-defined command argument')
638-
639-
assert.strictEqual(path.dirname(params.rootUri.fsPath), path.dirname(expectedUri.fsPath))
640-
}
641641
}
642642

643643
async function createSamApplication(location: string, scenario: TestScenario): Promise<void> {

0 commit comments

Comments
 (0)