enable lint rule for indentation (#2229)

This commit is contained in:
Bob Brown 2021-11-03 11:42:50 -07:00 коммит произвёл GitHub
Родитель 33ffa5d3be
Коммит d2d98f8006
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 70 добавлений и 117 удалений

Просмотреть файл

@ -27,7 +27,7 @@ module.exports = {
"format": ["PascalCase"]
}
],
//"@typescript-eslint/indent": "error",
"@typescript-eslint/indent": "error",
"@typescript-eslint/member-delimiter-style": [
"error",
{

Просмотреть файл

@ -482,15 +482,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
await drv.asyncDispose();
}
}
for (const disp of [this._statusMessage,
this._targetName,
this._activeVariant,
this._ctestEnabled,
this._testResults,
this._isBusy,
this._variantManager,
this._ctestController
]) {
for (const disp of [this._statusMessage, this._targetName, this._activeVariant, this._ctestEnabled, this._testResults, this._isBusy, this._variantManager, this._ctestController]) {
disp.dispose();
}
}
@ -1003,8 +995,8 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
this._cmakeDriver = Promise.resolve(null);
if (e instanceof BadHomeDirectoryError) {
void vscode.window
.showErrorMessage(localize('source.directory.does.not.match',
'The source directory "{0}" does not match the source directory in the CMake cache: {1}. You will need to run a clean-configure to configure this project.', e.expecting, e.cached),
.showErrorMessage(
localize('source.directory.does.not.match', 'The source directory "{0}" does not match the source directory in the CMake cache: {1}. You will need to run a clean-configure to configure this project.', e.expecting, e.cached),
{},
{ title: localize('clean.configure.title', 'Clean Configure') }
)
@ -1280,16 +1272,16 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
if (!save_good) {
log.debug(localize('saving.open.files.failed', 'Saving open files failed'));
const yesButtonTitle: string = localize('yes.button', 'Yes');
const chosen = await vscode.window.showErrorMessage<
vscode.MessageItem>(localize('not.saved.continue.anyway', 'Not all open documents were saved. Would you like to continue anyway?'),
{
title: yesButtonTitle,
isCloseAffordance: false
},
{
title: localize('no.button', 'No'),
isCloseAffordance: true
});
const chosen = await vscode.window.showErrorMessage<vscode.MessageItem>(
localize('not.saved.continue.anyway', 'Not all open documents were saved. Would you like to continue anyway?'),
{
title: yesButtonTitle,
isCloseAffordance: false
},
{
title: localize('no.button', 'No'),
isCloseAffordance: true
});
return chosen !== undefined && (chosen.title === yesButtonTitle);
}
}

Просмотреть файл

@ -22,8 +22,7 @@ const localize: nls.LocalizeFunc = nls.loadMessageBundle();
const log = createLogger('cpptools');
type Architecture = 'x86' | 'x64' | 'arm' | 'arm64' | undefined;
type StandardVersion = "c89" | "c99" | "c11" | "c17" | "c++98" | "c++03" | "c++11" | "c++14" | "c++17" | "c++20"
| "gnu89" | "gnu99" | "gnu11" | "gnu17" | "gnu++98" | "gnu++03" | "gnu++11" | "gnu++14" | "gnu++17" | "gnu++20" | undefined;
type StandardVersion = "c89" | "c99" | "c11" | "c17" | "c++98" | "c++03" | "c++11" | "c++14" | "c++17" | "c++20" | "gnu89" | "gnu99" | "gnu11" | "gnu17" | "gnu++98" | "gnu++03" | "gnu++11" | "gnu++14" | "gnu++17" | "gnu++20" | undefined;
export interface DiagnosticsCpptools {
isReady: boolean;
@ -423,8 +422,7 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
* @param fileGroup The file group from the code model to create config data for
* @param opts Index update options
*/
private _buildConfigurationData(fileGroup: codemodel_api.CodeModelFileGroup, opts: codemodel_api.CodeModelParams, target: TargetDefaults, sysroot: string):
cpt.SourceFileConfiguration {
private _buildConfigurationData(fileGroup: codemodel_api.CodeModelFileGroup, opts: codemodel_api.CodeModelParams, target: TargetDefaults, sysroot: string): cpt.SourceFileConfiguration {
// If the file didn't have a language, default to C++
const lang = fileGroup.language === "RC" ? undefined : fileGroup.language;
// First try to get toolchain values directly reported by CMake. Check the

Просмотреть файл

@ -57,12 +57,11 @@ export class CMakeOutputConsumer implements OutputConsumer {
* a warning or error with blank lines
*/
blankLines: number;
}
= {
state: 'init',
diag: null,
blankLines: 0
};
} = {
state: 'init',
diag: null,
blankLines: 0
};
/**
* Consume a line of stderr.
* @param line The line from stderr

Просмотреть файл

@ -77,8 +77,7 @@ function findPropertyValue(cacheElement: index_api.Cache.CMakeCacheEntry, name:
return property_element ? property_element.value : '';
}
function convertFileApiCacheToExtensionCache(cache_from_cmake: index_api.Cache.CacheContent):
Map<string, api.CacheEntry> {
function convertFileApiCacheToExtensionCache(cache_from_cmake: index_api.Cache.CacheContent): Map<string, api.CacheEntry> {
return cache_from_cmake.entries.reduce((acc, el) => {
const entry_type_translation_map: { [key: string]: api.CacheEntryType | undefined } = {
BOOL: api.CacheEntryType.Bool,

Просмотреть файл

@ -232,8 +232,8 @@ export class CMakeServerClientDriver extends CMakeDriver {
targetType: 'META'
});
}
return build_config.projects.reduce<RichTarget[]>((acc, project) => acc.concat(project.targets.map(
t => ({
return build_config.projects.reduce<RichTarget[]>(
(acc, project) => acc.concat(project.targets.map(t => ({
type: 'rich' as 'rich',
name: t.name,
filepath: t.artifacts && t.artifacts.length

Просмотреть файл

@ -342,8 +342,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
return util.mergeEnvironment(cur_env, kit_env, (opts && opts.environment) ? opts.environment : {});
}
executeCommand(command: string, args?: string[], consumer?: proc.OutputConsumer, options?: proc.ExecutionOptions):
proc.Subprocess {
executeCommand(command: string, args?: string[], consumer?: proc.OutputConsumer, options?: proc.ExecutionOptions): proc.Subprocess {
const environment = this.getEffectiveSubprocessEnvironment(options);
const exec_options = { ...options, environment };
return proc.execute(command, args, consumer, exec_options);

Просмотреть файл

@ -552,27 +552,24 @@ class ExtensionManager implements vscode.Disposable {
title: string;
persistMode: 'user' | 'workspace';
}
const persist_pr
// Try to persist the user's selection to a `settings.json`
= vscode.window
.showInformationMessage<Choice2>(
perist_message,
{},
{ title: button_messages[0], persistMode: 'user' },
{ title: button_messages[1], persistMode: 'workspace' }
)
.then(async choice => {
if (!choice) {
// Use cancelled. Do nothing.
return;
}
const config = vscode.workspace.getConfiguration(undefined, ws.uri);
let config_target = vscode.ConfigurationTarget.Global;
if (choice.persistMode === 'workspace') {
config_target = vscode.ConfigurationTarget.WorkspaceFolder;
}
await config.update('cmake.configureOnOpen', chosen.doConfigure, config_target);
});
// Try to persist the user's selection to a `settings.json`
const persist_pr = vscode.window.showInformationMessage<Choice2>(
perist_message,
{},
{ title: button_messages[0], persistMode: 'user' },
{ title: button_messages[1], persistMode: 'workspace' })
.then(async choice => {
if (!choice) {
// Use cancelled. Do nothing.
return;
}
const config = vscode.workspace.getConfiguration(undefined, ws.uri);
let config_target = vscode.ConfigurationTarget.Global;
if (choice.persistMode === 'workspace') {
config_target = vscode.ConfigurationTarget.WorkspaceFolder;
}
await config.update('cmake.configureOnOpen', chosen.doConfigure, config_target);
});
rollbar.takePromise(localize('persist.config.on.open.setting', 'Persist config-on-open setting'), {}, persist_pr);
should_configure = chosen.doConfigure;
}
@ -683,17 +680,7 @@ class ExtensionManager implements vscode.Disposable {
}
private _disposeSubs() {
for (const sub of [this._statusMessageSub,
this._targetNameSub,
this._buildTypeSub,
this._launchTargetSub,
this._ctestEnabledSub,
this._testResultsSub,
this._isBusySub,
this._activeConfigurePresetSub,
this._activeBuildPresetSub,
this._activeTestPresetSub
]) {
for (const sub of [this._statusMessageSub, this._targetNameSub, this._buildTypeSub, this._launchTargetSub, this._ctestEnabledSub, this._testResultsSub, this._isBusySub, this._activeConfigurePresetSub, this._activeBuildPresetSub, this._activeTestPresetSub]) {
sub.dispose();
}
}
@ -838,10 +825,9 @@ class ExtensionManager implements vscode.Disposable {
/**
* Watches for changes to the kits file
*/
private readonly _kitsWatcher =
util.chokidarOnAnyChange(chokidar.watch(USER_KITS_FILEPATH,
{ ignoreInitial: true }),
_ => rollbar.takePromise(localize('rereading.kits', 'Re-reading kits'), {}, KitsController.readUserKits(this._folders.activeFolder?.cmakeTools)));
private readonly _kitsWatcher = util.chokidarOnAnyChange(
chokidar.watch(USER_KITS_FILEPATH, { ignoreInitial: true }),
_ => rollbar.takePromise(localize('rereading.kits', 'Re-reading kits'), {}, KitsController.readUserKits(this._folders.activeFolder?.cmakeTools)));
/**
* Set the current kit for the specified workspace folder
@ -1149,9 +1135,8 @@ class ExtensionManager implements vscode.Disposable {
}
configure(folder?: vscode.WorkspaceFolder, showCommandOnly?: boolean) {
return this.mapCMakeToolsFolder(cmt => cmt.configureInternal(ConfigureTrigger.commandConfigure,
[],
showCommandOnly ? ConfigureType.ShowCommandOnly : ConfigureType.Normal),
return this.mapCMakeToolsFolder(
cmt => cmt.configureInternal(ConfigureTrigger.commandConfigure, [], showCommandOnly ? ConfigureType.ShowCommandOnly : ConfigureType.Normal),
folder, undefined, true);
}

Просмотреть файл

@ -638,8 +638,7 @@ const MSVC_ENVIRONMENT_VARIABLES = [
* @param devbat Path to a VS environment batch file
* @param args List of arguments to pass to the batch file
*/
async function collectDevBatVars(hostArch: string, devbat: string, args: string[], major_version: number, common_dir: string):
Promise<Map<string, string> | undefined> {
async function collectDevBatVars(hostArch: string, devbat: string, args: string[], major_version: number, common_dir: string): Promise<Map<string, string> | undefined> {
const fname = Math.random().toString() + '.bat';
const batfname = `vs-cmt-${fname}`;
const envfname = batfname + '.env';

Просмотреть файл

@ -466,18 +466,16 @@ export class KitsController {
interface FailOptions extends vscode.MessageItem {
do: 'retry' | 'cancel';
}
const pr = vscode.window
.showErrorMessage<FailOptions>(
`Failed to write kits file to disk: ${USER_KITS_FILEPATH}: ${e.toString()}`,
{
title: localize('retry.button', 'Retry'),
do: 'retry'
},
{
title: localize('cancel.button', 'Cancel'),
do: 'cancel'
}
)
const pr = vscode.window.showErrorMessage<FailOptions>(
`Failed to write kits file to disk: ${USER_KITS_FILEPATH}: ${e.toString()}`,
{
title: localize('retry.button', 'Retry'),
do: 'retry'
},
{
title: localize('cancel.button', 'Cancel'),
do: 'cancel'
})
.then(choice => {
if (!choice) {
return false;

Просмотреть файл

@ -220,23 +220,13 @@ export function find<T>(iter: Iterable<T>, predicate: (value: T) => boolean): T
export function randint(min: number, max: number): number { return Math.floor(Math.random() * (max - min) + min); }
export function product<T>(arrays: T[][]): T[][] {
// clang-format off
return arrays.reduce((acc, curr) =>
acc
return arrays.reduce(
(acc, curr) =>
// Append each element of the current array to each list already accumulated
.map(
prev => curr.map(
item => prev.concat(item)
)
)
.reduce(
acc.map(prev => curr.map(item => prev.concat(item)))
// Join all the lists
(a, b) => a.concat(b),
[]
),
[[]] as T[][]
);
// clang-format on
.reduce((a, b) => a.concat(b), []),
[[]] as T[][]);
}
export interface CMakeValue {

Просмотреть файл

@ -321,7 +321,7 @@ export class VariantManager implements vscode.Disposable {
long: [acc.long, el.long].join(', '),
env: util.mergeEnvironment(acc.env || {}, el.env || {})
}),
init);
init);
}
get activeVariantOptions(): VariantOption {
@ -408,8 +408,7 @@ export class VariantManager implements vscode.Disposable {
return this.stateManager.activeVariantSettings;
}
transformChoiceCombinationToKeywordSettings(choiceCombination: { settingKey: string; settingValue: string }[]):
Map<string, string> {
transformChoiceCombinationToKeywordSettings(choiceCombination: { settingKey: string; settingValue: string }[]): Map<string, string> {
const keywords = new Map<string, string>();
choiceCombination.forEach(kv => keywords.set(kv.settingKey, kv.settingValue));
return keywords;

Просмотреть файл

@ -33,10 +33,8 @@ export class DefaultEnvironment {
readonly sandbox = sinon.createSandbox();
readonly projectFolder = new ProjectRootHelper(this.projectRoot, this.buildLocation);
readonly result: TestProgramResult
= new TestProgramResult(this.projectFolder.buildDirectory.location, this.executableResult);
readonly defaultKitLabel
= this._defaultKitLabelIn ? this._defaultKitLabelIn : (process.platform === 'win32' ? /^Visual/ : /\s\S/);
readonly result: TestProgramResult = new TestProgramResult(this.projectFolder.buildDirectory.location, this.executableResult);
readonly defaultKitLabel = this._defaultKitLabelIn ? this._defaultKitLabelIn : (process.platform === 'win32' ? /^Visual/ : /\s\S/);
readonly vsContext: DefaultExtensionContext = new DefaultExtensionContext();
private _config = ConfigurationReader.create(vscode.workspace.workspaceFolders![0]);
public get config() { return this._config; }

Просмотреть файл

@ -260,10 +260,7 @@ export function makeCodeModelDriverTestsuite(
const codemodel_data = await generateCodeModelForConfiguredDriver([], sourceOutsideOfWorkspace);
expect(codemodel_data).to.be.not.null;
for (const [target_name, target_subdir, sourcefile_name] of [['root_target', '', '../main.cpp'],
['subdir_target', 'subdir', '../../main.cpp']] as
const) {
for (const [target_name, target_subdir, sourcefile_name] of [['root_target', '', '../main.cpp'], ['subdir_target', 'subdir', '../../main.cpp']] as const) {
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type === 'EXECUTABLE'
&& t.name === target_name);
expect(target).to.be.not.undefined;