Skip to content

Commit b407497

Browse files
authored
Merge pull request #1550 from mchangrh/stricter-ts
add noFallThrough, inplicitReturn, update packages
2 parents 4596f3a + 44d4dd5 commit b407497

12 files changed

+1322
-1756
lines changed

package-lock.json

+1,283-1,737
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
"react-dom": "^18.2.0"
99
},
1010
"devDependencies": {
11-
"@types/chrome": "^0.0.197",
11+
"@types/chrome": "^0.0.199",
1212
"@types/firefox-webext-browser": "^94.0.1",
13-
"@types/jest": "^29.1.2",
13+
"@types/jest": "^29.2.0",
1414
"@types/react": "^18.0.21",
1515
"@types/react-dom": "^18.0.6",
16-
"@types/selenium-webdriver": "^4.1.5",
16+
"@types/selenium-webdriver": "^4.1.6",
1717
"@types/wicg-mediasession": "^1.1.4",
18-
"@typescript-eslint/eslint-plugin": "^5.39.0",
19-
"@typescript-eslint/parser": "^5.39.0",
18+
"@typescript-eslint/eslint-plugin": "^5.40.1",
19+
"@typescript-eslint/parser": "^5.40.1",
2020
"chromedriver": "^106.0.1",
2121
"concurrently": "^7.4.0",
2222
"copy-webpack-plugin": "^11.0.0",
23-
"eslint": "^8.24.0",
24-
"eslint-plugin-react": "^7.31.8",
23+
"eslint": "^8.25.0",
24+
"eslint-plugin-react": "^7.31.10",
2525
"fork-ts-checker-webpack-plugin": "^7.2.13",
26-
"jest": "^29.1.2",
27-
"jest-environment-jsdom": "^29.1.2",
26+
"jest": "^29.2.1",
27+
"jest-environment-jsdom": "^29.2.1",
2828
"rimraf": "^3.0.2",
2929
"schema-utils": "^4.0.0",
3030
"selenium-webdriver": "^4.5.0",
@@ -33,7 +33,7 @@
3333
"ts-loader": "^9.4.1",
3434
"ts-node": "^10.9.1",
3535
"typescript": "4.8",
36-
"web-ext": "^7.2.0",
36+
"web-ext": "^7.3.1",
3737
"webpack": "^5.74.0",
3838
"webpack-cli": "^4.10.0",
3939
"webpack-merge": "^5.8.0"

src/background.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
5959
switch(request.message) {
6060
case "openConfig":
6161
chrome.tabs.create({url: chrome.runtime.getURL('options/options.html' + (request.hash ? '#' + request.hash : ''))});
62-
return;
62+
return false;
6363
case "openHelp":
6464
chrome.tabs.create({url: chrome.runtime.getURL('help/index.html')});
65-
return;
65+
return false;
6666
case "openUpsell":
6767
chrome.tabs.create({url: chrome.runtime.getURL('upsell/index.html')});
68-
return;
68+
return false;
6969
case "openPage":
7070
chrome.tabs.create({url: chrome.runtime.getURL(request.url)});
71-
return;
71+
return false;
7272
case "sendRequest":
7373
sendRequestToCustomServer(request.type, request.url, request.data).then(async (response) => {
7474
callback({
@@ -112,6 +112,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
112112
popupPort[sender.tab.id]?.postMessage(request);
113113
}
114114
return false;
115+
default:
116+
return false;
115117
}
116118
});
117119

src/components/SkipNoticeComponent.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
373373
</span>
374374
);
375375
}
376+
return null;
376377
}
377378

378379
getSubmissionChooser(): JSX.Element[] {

src/content.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2112,11 +2112,11 @@ async function vote(type: number, UUID: SegmentUUID, category?: Category, skipNo
21122112
return response;
21132113
}
21142114

2115-
async function voteAsync(type: number, UUID: SegmentUUID, category?: Category): Promise<VoteResponse> {
2115+
async function voteAsync(type: number, UUID: SegmentUUID, category?: Category): Promise<VoteResponse | undefined> {
21162116
const sponsorIndex = utils.getSponsorIndexFromUUID(sponsorTimes, UUID);
21172117

21182118
// Don't vote for preview sponsors
2119-
if (sponsorIndex == -1 || sponsorTimes[sponsorIndex].source !== SponsorSourceType.Server) return;
2119+
if (sponsorIndex == -1 || sponsorTimes[sponsorIndex].source !== SponsorSourceType.Server) return Promise.resolve(undefined);
21202120

21212121
// See if the local time saved count and skip count should be saved
21222122
if (type === 0 && sponsorSkipped[sponsorIndex] || type === 1 && !sponsorSkipped[sponsorIndex]) {

src/js-components/previewBar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ class PreviewBar {
744744
chaptersContainer.style.display = "none";
745745
}
746746

747-
return;
747+
return [];
748748
}
749749

750750
segments ??= [];

src/popup.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ class MessageHandler {
6767

6868
// To prevent clickjacking
6969
let allowPopup = window === window.top;
70-
window.addEventListener("message", async (e) => {
70+
window.addEventListener("message", async (e): Promise<void> => {
7171
if (e.source !== window.parent) return;
72-
if (e.origin.endsWith('.youtube.com')) return allowPopup = true;
72+
if (e.origin.endsWith('.youtube.com')) {
73+
allowPopup = true;
74+
}
7375
});
7476

7577
//make this a function to allow this to run on the content page

src/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ export default class Utils {
319319
return selection;
320320
}
321321
}
322+
return { name: "None", option: 0} as CategorySelection;
322323
}
323324

324325
/**

src/utils/constants.ts

+8
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,13 @@ export function getGuidelineInfo(category: Category): TextBox[] {
148148
icon: "icons/check-smaller.svg",
149149
text: chrome.i18n.getMessage(`category_${category}_guideline3`)
150150
}];
151+
default:
152+
return [{
153+
icon: "icons/segway.png",
154+
text: chrome.i18n.getMessage(`generic_guideline1`)
155+
}, {
156+
icon: "icons/right-arrow.svg",
157+
text: chrome.i18n.getMessage(`generic_guideline2`)
158+
}];
151159
}
152160
}

src/utils/urlParser.ts

+2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ export function urlTimeToSeconds(time: string): number {
2222
return hours * 3600 + minutes * 60 + seconds;
2323
} else if (/\d+/.test(time)) {
2424
return parseInt(time, 10);
25+
} else {
26+
return 0;
2527
}
2628
}

tsconfig-production.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"module": "commonjs",
44
"target": "es6",
55
"noImplicitAny": false,
6+
"noImplicitReturns": true,
7+
"noFallthroughCasesInSwitch": true,
68
"sourceMap": false,
79
"outDir": "dist/js",
810
"noEmitOnError": false,

tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"module": "commonjs",
44
"target": "es6",
55
"noImplicitAny": false,
6+
"noImplicitReturns": true,
7+
"noFallthroughCasesInSwitch": true,
68
"sourceMap": true,
79
"outDir": "dist/js",
810
"noEmitOnError": false,

0 commit comments

Comments
 (0)