2017-09-01 174 views
0

我需要設置在Visual Studio -> Tools -> Options -> Text Editor -> JavaScript/TypeScript -> EsLint中找到的Visual Studio選項的值,但我似乎找不到此選項的CollectionPath使用Settings Store更改VS選項:找到正確的CollectionPath?

GetSubCollectionNames("Text Editor");產生若干結果,而GetSubCollectionNames("Text Editor\\JavaScript");產生0結果。

TL; DR 一個如何去找到下面的圖像中描繪的選擇權CollectionPath

enter image description here

這是我使用的是什麼目前。

[ImportingConstructor] 
internal VSOptions([Import] SVsServiceProvider serviceProvider) 
{ 
    var settingsManager = new ShellSettingsManager(serviceProvider); 

    _writableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings) 
     ?? throw new Exception(nameof(settingsManager)); 

    var textEditorSubCollections = _writableSettingsStore.GetSubCollectionNames("Text Editor"); 
    var javaScriptSubCollections = _writableSettingsStore.GetSubCollectionNames("Text Editor\\JavaScript"); 

    // TODO: set option value when we have the right CollectionPath 
} 

回答

0

WritabelSettingsStore類用於擴展Visual Studio中的Visual Studio常用設置。您可以使用GetPropertyNames(「Text Editor \ JavaScript」)列出JavaScript的所有writabel設置,您將在其中列出並未列出JavaScript子集合下的所有Properties。

EsLint是不常見的Visual Studio設置。它是識別和報告ECMAScript/JavaScript代碼中發現的模式的第三部分工具,其目標是使代碼更加一致並避免錯誤。

所以我們不能直接用WritableSettingsStore類來改變它。您需要知道EsLint如何在Visual Studio中添加,然後修改其Visual Studio的配置文件。