Skip to content

Commit 8513c0c

Browse files
author
Gareth Emslie
committed
commit lint fixes
1 parent 2783532 commit 8513c0c

3 files changed

Lines changed: 451 additions & 419 deletions

File tree

src/file-upload-dialog.ts

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,69 @@
1-
import * as SDK from "azure-devops-extension-sdk";
1+
import * as SDK from 'azure-devops-extension-sdk';
22

33
SDK.init();
44

5-
SDK.register("file-upload", () => {
6-
let callbacks : any = [];
5+
SDK.register('file-upload', () => {
6+
const callbacks: any = [];
77

8-
let input : HTMLInputElement = document.getElementById('file-input') as HTMLInputElement;
8+
const input: HTMLInputElement = document.getElementById(
9+
'file-input'
10+
) as HTMLInputElement;
911

10-
function isValid() : boolean{
11-
// HAs the user selected a file?
12-
return input.files.length == 1;
13-
}
12+
function isValid(): boolean {
13+
// HAs the user selected a file?
14+
return input.files.length == 1;
15+
}
1416

15-
input.addEventListener("change", () =>{
16-
// Execute registered callbacks
17-
for(var i = 0; i < callbacks.length; i++) {
18-
callbacks[i](isValid());
19-
}
20-
}, false);
17+
input.addEventListener(
18+
'change',
19+
() => {
20+
// Execute registered callbacks
21+
for (let i = 0; i < callbacks.length; i++) {
22+
callbacks[i](isValid());
23+
}
24+
},
25+
false
26+
);
2127

22-
return {
23-
getFileContents : async () => {
24-
return new Promise((res,rej)=>{
25-
const fileList : FileList = input.files;
28+
return {
29+
getFileContents: async () => {
30+
return new Promise((res, rej) => {
31+
const fileList: FileList = input.files;
2632

27-
console.log(fileList.length + " files selected.");
33+
console.log(fileList.length + ' files selected.');
2834

29-
// If we have a file lets read the contents
30-
if(fileList.length == 1)
31-
{
32-
let file = fileList[0];
35+
// If we have a file lets read the contents
36+
if (fileList.length == 1) {
37+
const file = fileList[0];
3338

34-
console.log("Selected File Name : " + file.name);
39+
console.log('Selected File Name : ' + file.name);
3540

36-
// new FileReader object
37-
let reader = new FileReader();
41+
// new FileReader object
42+
const reader = new FileReader();
3843

39-
// event fired when file reading finished
40-
reader.addEventListener('loadend', function(e) {
41-
// contents of the file
42-
res(e.target.result.toString());
43-
});
44+
// event fired when file reading finished
45+
reader.addEventListener('loadend', function (e) {
46+
// contents of the file
47+
res(e.target.result.toString());
48+
});
4449

45-
// event fired when file reading failed
46-
reader.addEventListener('error', function() {
47-
rej('Error : Failed to read file.');
48-
});
50+
// event fired when file reading failed
51+
reader.addEventListener('error', function () {
52+
rej('Error : Failed to read file.');
53+
});
4954

50-
// read file as text file
51-
reader.readAsText(file);
52-
}
53-
else
54-
{
55-
rej('Error : No File Selected.');
56-
}
57-
});
58-
},
59-
attachFileChanged: (cb : any) => {
60-
callbacks.push(cb);
61-
},
62-
isFileValid: () => {
63-
return isValid();
55+
// read file as text file
56+
reader.readAsText(file);
57+
} else {
58+
rej('Error : No File Selected.');
6459
}
65-
};
66-
});
60+
});
61+
},
62+
attachFileChanged: (cb: any) => {
63+
callbacks.push(cb);
64+
},
65+
isFileValid: () => {
66+
return isValid();
67+
},
68+
};
69+
});

0 commit comments

Comments
 (0)