mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Merge pull request #261672 from mjbvz/broad-leopard
Enable a few more stylistic eslint options for my extensions
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
||||
import * as pluginLocal from './.eslint-plugin-local/index.js';
|
||||
@@ -1395,17 +1394,33 @@ export default tseslint.config(
|
||||
]
|
||||
}
|
||||
},
|
||||
// typescript-language-features
|
||||
// Additional extension strictness rules
|
||||
{
|
||||
files: [
|
||||
'extensions/markdown-language-features/**/*.ts',
|
||||
'extensions/media-preview/**/*.ts',
|
||||
'extensions/simple-browser/**/*.ts',
|
||||
'extensions/typescript-language-features/**/*.ts',
|
||||
],
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
parserOptions: {
|
||||
project: [
|
||||
// Markdown
|
||||
'extensions/markdown-language-features/tsconfig.json',
|
||||
'extensions/markdown-language-features/notebook/tsconfig.json',
|
||||
'extensions/markdown-language-features/preview-src/tsconfig.json',
|
||||
|
||||
// Media preview
|
||||
'extensions/media-preview/tsconfig.json',
|
||||
|
||||
// Media preview
|
||||
'extensions/simple-browser/tsconfig.json',
|
||||
'extensions/simple-browser/preview-src/tsconfig.json',
|
||||
|
||||
// TypeScript
|
||||
'extensions/typescript-language-features/tsconfig.json',
|
||||
'extensions/typescript-language-features/web/tsconfig.json'
|
||||
'extensions/typescript-language-features/web/tsconfig.json',
|
||||
],
|
||||
}
|
||||
},
|
||||
@@ -1415,6 +1430,7 @@ export default tseslint.config(
|
||||
rules: {
|
||||
'@typescript-eslint/prefer-optional-chain': 'warn',
|
||||
'@typescript-eslint/prefer-readonly': 'warn',
|
||||
'@typescript-eslint/consistent-generic-constructors': ['warn', 'constructor'],
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -24,7 +24,7 @@ export class CspAlerter {
|
||||
});
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event && event.data && event.data.name === 'vscode-did-block-svg') {
|
||||
if (event?.data && event.data.name === 'vscode-did-block-svg') {
|
||||
this._onCspWarning();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -432,7 +432,7 @@ function domEval(el: Element): void {
|
||||
const trustedScript = node.innerText;
|
||||
scriptTag.text = trustedScript as string;
|
||||
for (const key of preservedScriptAttributes) {
|
||||
const val = node.getAttribute && node.getAttribute(key);
|
||||
const val = node.getAttribute?.(key);
|
||||
if (val) {
|
||||
scriptTag.setAttribute(key, val as any);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { MessagePoster } from './messaging';
|
||||
|
||||
export class StyleLoadingMonitor {
|
||||
private _unloadedStyles: string[] = [];
|
||||
private readonly _unloadedStyles: string[] = [];
|
||||
private _finishedLoading: boolean = false;
|
||||
|
||||
private _poster?: MessagePoster;
|
||||
|
||||
@@ -17,7 +17,7 @@ import { ResourceMap } from '../util/resourceMap';
|
||||
*/
|
||||
export class VsCodeMdWorkspace extends Disposable {
|
||||
|
||||
private _watcher: vscode.FileSystemWatcher | undefined;
|
||||
private readonly _watcher: vscode.FileSystemWatcher | undefined;
|
||||
|
||||
private readonly _documentCache = new ResourceMap<ITextDocument>();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ async function showPreview(
|
||||
return;
|
||||
}
|
||||
|
||||
const resourceColumn = (vscode.window.activeTextEditor && vscode.window.activeTextEditor.viewColumn) || vscode.ViewColumn.One;
|
||||
const resourceColumn = vscode.window.activeTextEditor?.viewColumn || vscode.ViewColumn.One;
|
||||
webviewManager.openDynamicPreview(resource, {
|
||||
resourceColumn: resourceColumn,
|
||||
previewColumn: previewSettings.sideBySide ? vscode.ViewColumn.Beside : resourceColumn,
|
||||
@@ -62,7 +62,7 @@ export class ShowPreviewCommand implements Command {
|
||||
for (const uri of Array.isArray(allUris) ? allUris : [mainUri]) {
|
||||
showPreview(this._webviewManager, this._telemetryReporter, uri, {
|
||||
sideBySide: false,
|
||||
locked: previewSettings && previewSettings.locked
|
||||
locked: previewSettings?.locked
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ export class ShowPreviewToSideCommand implements Command {
|
||||
public execute(uri?: vscode.Uri, previewSettings?: DynamicPreviewSettings) {
|
||||
showPreview(this._webviewManager, this._telemetryReporter, uri, {
|
||||
sideBySide: true,
|
||||
locked: previewSettings && previewSettings.locked
|
||||
locked: previewSettings?.locked
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class UpdateLinksOnFileRenameHandler extends Disposable {
|
||||
|
||||
const result = await this._getEditsForFileRename(renames, noopToken);
|
||||
|
||||
if (result && result.edit.size) {
|
||||
if (result?.edit.size) {
|
||||
if (await this._confirmActionWithUser(result.resourcesBeingRenamed)) {
|
||||
await vscode.workspace.applyEdit(result.edit);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ export class MarkdownItEngine implements IMdParser {
|
||||
private _md?: Promise<MarkdownIt>;
|
||||
|
||||
private _slugCount = new Map<string, number>();
|
||||
private _tokenCache = new TokenCache();
|
||||
private readonly _tokenCache = new TokenCache();
|
||||
|
||||
public readonly slugifier: Slugifier;
|
||||
|
||||
@@ -433,7 +433,7 @@ async function getMarkdownOptions(md: () => MarkdownIt): Promise<MarkdownIt.Opti
|
||||
}
|
||||
|
||||
function normalizeHighlightLang(lang: string | undefined) {
|
||||
switch (lang && lang.toLowerCase()) {
|
||||
switch (lang?.toLowerCase()) {
|
||||
case 'shell':
|
||||
return 'sh';
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ export namespace MarkdownContributions {
|
||||
const map = new Map<string, Thenable<(md: any) => any>>();
|
||||
if (contributes['markdown.markdownItPlugins']) {
|
||||
map.set(extension.id, extension.activate().then(() => {
|
||||
if (extension.exports && extension.exports.extendMarkdownIt) {
|
||||
if (extension.exports?.extendMarkdownIt) {
|
||||
return (md: any) => extension.exports.extendMarkdownIt(md);
|
||||
}
|
||||
return (md: any) => md;
|
||||
|
||||
@@ -53,7 +53,7 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
|
||||
private readonly _webviewPanel: vscode.WebviewPanel;
|
||||
|
||||
private _line: number | undefined;
|
||||
private _scrollToFragment: string | undefined;
|
||||
private readonly _scrollToFragment: string | undefined;
|
||||
private _firstUpdate = true;
|
||||
private _currentVersion?: PreviewDocumentVersion;
|
||||
private _isScrolling = false;
|
||||
|
||||
@@ -36,7 +36,7 @@ export class MarkdownPreviewConfiguration {
|
||||
this.scrollBeyondLastLine = editorConfig.get<boolean>('scrollBeyondLastLine', false);
|
||||
|
||||
this.wordWrap = editorConfig.get<string>('wordWrap', 'off') !== 'off';
|
||||
if (markdownEditorConfig && markdownEditorConfig['editor.wordWrap']) {
|
||||
if (markdownEditorConfig?.['editor.wordWrap']) {
|
||||
this.wordWrap = markdownEditorConfig['editor.wordWrap'] !== 'off';
|
||||
}
|
||||
|
||||
@@ -83,13 +83,11 @@ export class MarkdownPreviewConfigurationManager {
|
||||
return config;
|
||||
}
|
||||
|
||||
public hasConfigurationChanged(
|
||||
resource: vscode.Uri
|
||||
): boolean {
|
||||
public hasConfigurationChanged(resource: vscode.Uri): boolean {
|
||||
const key = this._getKey(resource);
|
||||
const currentConfig = this._previewConfigurationsForWorkspaces.get(key);
|
||||
const newConfig = MarkdownPreviewConfiguration.getForResource(resource);
|
||||
return (!currentConfig || !currentConfig.isEqualTo(newConfig));
|
||||
return !currentConfig?.isEqualTo(newConfig);
|
||||
}
|
||||
|
||||
private _getKey(
|
||||
|
||||
@@ -17,8 +17,8 @@ export class TopmostLineMonitor extends Disposable {
|
||||
|
||||
private readonly _pendingUpdates = new ResourceMap<number>();
|
||||
private readonly _throttle = 50;
|
||||
private _previousTextEditorInfo = new ResourceMap<LastScrollLocation>();
|
||||
private _previousStaticEditorInfo = new ResourceMap<LastScrollLocation>();
|
||||
private readonly _previousTextEditorInfo = new ResourceMap<LastScrollLocation>();
|
||||
private readonly _previousStaticEditorInfo = new ResourceMap<LastScrollLocation>();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -49,7 +49,7 @@ export function loadDefaultTelemetryReporter(): TelemetryReporter {
|
||||
|
||||
function getPackageInfo(): IPackageInfo | null {
|
||||
const extension = vscode.extensions.getExtension('Microsoft.vscode-markdown');
|
||||
if (extension && extension.packageJSON) {
|
||||
if (extension?.packageJSON) {
|
||||
return {
|
||||
name: extension.packageJSON.name,
|
||||
version: extension.packageJSON.version,
|
||||
|
||||
@@ -39,7 +39,7 @@ export class Delayer<T> {
|
||||
}).then(() => {
|
||||
this._cancelTimeout = null;
|
||||
this._onSuccess = null;
|
||||
const result = this._task && this._task?.();
|
||||
const result = this._task?.() ?? null;
|
||||
this._task = null;
|
||||
return result;
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ class TscTaskProvider extends Disposable implements vscode.TaskProvider {
|
||||
return [];
|
||||
}
|
||||
|
||||
const configPaths: Set<string> = new Set();
|
||||
const configPaths = new Set<string>();
|
||||
const tasks: vscode.Task[] = [];
|
||||
for (const project of await this.getAllTsConfigs(token)) {
|
||||
if (!configPaths.has(project.fsPath)) {
|
||||
|
||||
@@ -40,7 +40,7 @@ export class WebTypingsInstallerClient implements ts.server.ITypingsInstaller {
|
||||
|
||||
private requestedRegistry = false;
|
||||
|
||||
private typesRegistryCache: Map<string, ts.MapLike<string>> = new Map();
|
||||
private typesRegistryCache = new Map<string, ts.MapLike<string>>();
|
||||
|
||||
private readonly server: Promise<WebTypingsInstallerServer>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user