Skip to content

Commit a14adc9

Browse files
author
Benjamin Pasero
committed
some vs/base/browser linting
1 parent 06c26d8 commit a14adc9

7 files changed

Lines changed: 417 additions & 418 deletions

File tree

src/vs/base/browser/browser.ts

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ interface ISafeWindow {
1212
}
1313

1414
interface ISafeDocument {
15-
URL:string;
16-
createElement(tagName:'div'):HTMLDivElement;
17-
createElement(tagName:string):HTMLElement;
15+
URL: string;
16+
createElement(tagName: 'div'): HTMLDivElement;
17+
createElement(tagName: string): HTMLElement;
1818
}
1919

2020
interface INavigator {
21-
userAgent:string;
21+
userAgent: string;
2222
}
2323

2424
interface ILocation {
2525
search: string;
2626
}
2727

2828
interface IGlobalScope {
29-
window:ISafeWindow;
30-
navigator:INavigator;
31-
parent:IGlobalScope;
32-
document:ISafeDocument;
29+
window: ISafeWindow;
30+
navigator: INavigator;
31+
parent: IGlobalScope;
32+
document: ISafeDocument;
3333
history: {
34-
pushState:any
34+
pushState: any
3535
};
36-
isTest:boolean;
36+
isTest: boolean;
3737
location: ILocation;
3838
}
3939

40-
var globals = <IGlobalScope><any> (typeof self === 'object' ? self : global);
40+
const globals = <IGlobalScope><any>(typeof self === 'object' ? self : global);
4141

4242
// MAC:
4343
// chrome: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.100 Safari/535.2"
@@ -53,8 +53,8 @@ var globals = <IGlobalScope><any> (typeof self === 'object' ? self : global);
5353
// chrome: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"
5454
// firefox: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:34.0) Gecko/20100101 Firefox/34.0"
5555

56-
var userAgent = globals.navigator ? globals.navigator.userAgent : '';
57-
var isTest = !!globals.isTest;
56+
const userAgent = globals.navigator ? globals.navigator.userAgent : '';
57+
const isTest = !!globals.isTest;
5858

5959
// DOCUMENTED FOR FUTURE REFERENCE:
6060
// When running IE11 in IE10 document mode, the code below will identify the browser as being IE10,
@@ -77,14 +77,15 @@ export const canUseTranslate3d = !isIE9 && !isFirefox;
7777

7878
export const enableEmptySelectionClipboard = isWebKit;
7979

80+
let _disablePushState = false;
81+
8082
/**
8183
* Returns if the browser supports the history.pushState function or not.
8284
*/
8385
export function canPushState() {
8486
return (!_disablePushState && globals.history && globals.history.pushState);
8587
};
8688

87-
var _disablePushState = false;
8889
/**
8990
* Helpful when we detect that pushing state does not work for some reason (e.g. FF prevents pushState for security reasons in some cases)
9091
*/
@@ -104,11 +105,11 @@ export function hasCSSAnimationSupport() {
104105
return false;
105106
}
106107

107-
var supported = false;
108-
var element = globals.document.createElement('div');
109-
var properties = ['animationName', 'webkitAnimationName', 'msAnimationName', 'MozAnimationName', 'OAnimationName'];
110-
for (var i = 0; i < properties.length; i++) {
111-
var property = properties[i];
108+
let supported = false;
109+
let element = globals.document.createElement('div');
110+
let properties = ['animationName', 'webkitAnimationName', 'msAnimationName', 'MozAnimationName', 'OAnimationName'];
111+
for (let i = 0; i < properties.length; i++) {
112+
let property = properties[i];
112113
if (!types.isUndefinedOrNull(element.style[property]) || element.style.hasOwnProperty(property)) {
113114
supported = true;
114115
break;
@@ -127,14 +128,14 @@ export function hasCSSAnimationSupport() {
127128
/**
128129
* Returns if the browser supports the provided video mime type or not.
129130
*/
130-
export function canPlayVideo(type:string) {
131+
export function canPlayVideo(type: string) {
131132
if (!globals.document) {
132133
return false;
133134
}
134135

135-
var video:HTMLVideoElement = <HTMLVideoElement>globals.document.createElement('video');
136+
let video: HTMLVideoElement = <HTMLVideoElement>globals.document.createElement('video');
136137
if (video.canPlayType) {
137-
var canPlay = video.canPlayType(type);
138+
let canPlay = video.canPlayType(type);
138139

139140
return canPlay === 'maybe' || canPlay === 'probably';
140141
}
@@ -145,26 +146,26 @@ export function canPlayVideo(type:string) {
145146
/**
146147
* Returns if the browser supports the provided audio mime type or not.
147148
*/
148-
export function canPlayAudio(type:string) {
149+
export function canPlayAudio(type: string) {
149150
if (!globals.document) {
150151
return false;
151152
}
152153

153-
var audio:HTMLAudioElement = <HTMLAudioElement>globals.document.createElement('audio');
154+
let audio: HTMLAudioElement = <HTMLAudioElement>globals.document.createElement('audio');
154155
if (audio.canPlayType) {
155-
var canPlay = audio.canPlayType(type);
156+
let canPlay = audio.canPlayType(type);
156157

157158
return canPlay === 'maybe' || canPlay === 'probably';
158159
}
159160

160161
return false;
161162
}
162163

163-
export function isInWebWorker():boolean {
164-
return !globals.document && typeof((<any>globals).importScripts) !== 'undefined';
164+
export function isInWebWorker(): boolean {
165+
return !globals.document && typeof ((<any>globals).importScripts) !== 'undefined';
165166
}
166167

167-
export function supportsExecCommand(command:string): boolean {
168+
export function supportsExecCommand(command: string): boolean {
168169
return (
169170
(isIE11orEarlier || Platform.isNative)
170171
&& document.queryCommandSupported(command)

src/vs/base/browser/browserService.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7-
import Browser = require('vs/base/browser/browser');
7+
import {isInWebWorker} from 'vs/base/browser/browser';
88

99
export interface IBrowserServiceData {
10-
document:Document;
11-
window:Window;
12-
isHTMLElement: (o:any)=>boolean;
10+
document: Document;
11+
window: Window;
12+
isHTMLElement: (o: any) => boolean;
1313
}
1414

1515
export interface IBrowserService extends IBrowserServiceData {
1616
/**
1717
* Mock the DOM with dummy objects
1818
*/
19-
mock(source:IBrowserServiceData):void;
19+
mock(source: IBrowserServiceData): void;
2020

2121
/**
2222
* Restore the normal DOM
2323
*/
24-
restore():void;
24+
restore(): void;
2525
}
2626

27-
export function regularIsHTMLElement(o:any): boolean {
27+
export function regularIsHTMLElement(o: any): boolean {
2828
if (typeof HTMLElement === 'object') {
2929
return o instanceof HTMLElement;
3030
}
@@ -33,23 +33,23 @@ export function regularIsHTMLElement(o:any): boolean {
3333

3434
class BrowserService implements IBrowserService {
3535

36-
public document:Document;
37-
public window:Window;
38-
public isHTMLElement: (o:any)=>boolean;
36+
public document: Document;
37+
public window: Window;
38+
public isHTMLElement: (o: any) => boolean;
3939

4040
constructor() {
4141
this.restore();
4242
}
4343

44-
public mock(source:IBrowserServiceData):void {
44+
public mock(source: IBrowserServiceData): void {
4545
this.document = source.document;
4646
this.window = source.window;
4747
this.isHTMLElement = source.isHTMLElement;
4848
}
4949

50-
public restore():void {
50+
public restore(): void {
5151
this.isHTMLElement = regularIsHTMLElement;
52-
if(Browser.isInWebWorker()) {
52+
if (isInWebWorker()) {
5353
this.document = null;
5454
this.window = null;
5555
} else {
@@ -59,8 +59,8 @@ class BrowserService implements IBrowserService {
5959
}
6060
}
6161

62-
var browserService = new BrowserService();
62+
const browserService = new BrowserService();
6363

64-
export function getService():IBrowserService {
64+
export function getService(): IBrowserService {
6565
return browserService;
6666
}

src/vs/base/browser/dnd.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
'use strict';
77

8-
import Builder = require('vs/base/browser/builder');
9-
10-
var $ = Builder.$;
8+
import {$} from 'vs/base/browser/builder';
119

1210
/**
1311
* A helper that will execute a provided function when the provided HTMLElement receives
@@ -17,7 +15,7 @@ export class DelayedDragHandler {
1715

1816
private timeout: number;
1917

20-
constructor(container:HTMLElement, callback: () => void) {
18+
constructor(container: HTMLElement, callback: () => void) {
2119
$(container).on('dragover', () => {
2220
if (!this.timeout) {
2321
this.timeout = setTimeout(() => {

0 commit comments

Comments
 (0)