Skip to content

Commit

Permalink
Merge pull request #1550 from mchangrh/stricter-ts
Browse files Browse the repository at this point in the history
add noFallThrough, inplicitReturn, update packages
  • Loading branch information
ajayyy authored Nov 4, 2022
2 parents 4596f3a + 44d4dd5 commit b407497
Show file tree
Hide file tree
Showing 12 changed files with 1,322 additions and 1,756 deletions.
3,020 changes: 1,283 additions & 1,737 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/chrome": "^0.0.197",
"@types/chrome": "^0.0.199",
"@types/firefox-webext-browser": "^94.0.1",
"@types/jest": "^29.1.2",
"@types/jest": "^29.2.0",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"@types/selenium-webdriver": "^4.1.5",
"@types/selenium-webdriver": "^4.1.6",
"@types/wicg-mediasession": "^1.1.4",
"@typescript-eslint/eslint-plugin": "^5.39.0",
"@typescript-eslint/parser": "^5.39.0",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"chromedriver": "^106.0.1",
"concurrently": "^7.4.0",
"copy-webpack-plugin": "^11.0.0",
"eslint": "^8.24.0",
"eslint-plugin-react": "^7.31.8",
"eslint": "^8.25.0",
"eslint-plugin-react": "^7.31.10",
"fork-ts-checker-webpack-plugin": "^7.2.13",
"jest": "^29.1.2",
"jest-environment-jsdom": "^29.1.2",
"jest": "^29.2.1",
"jest-environment-jsdom": "^29.2.1",
"rimraf": "^3.0.2",
"schema-utils": "^4.0.0",
"selenium-webdriver": "^4.5.0",
Expand All @@ -33,7 +33,7 @@
"ts-loader": "^9.4.1",
"ts-node": "^10.9.1",
"typescript": "4.8",
"web-ext": "^7.2.0",
"web-ext": "^7.3.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-merge": "^5.8.0"
Expand Down
10 changes: 6 additions & 4 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
switch(request.message) {
case "openConfig":
chrome.tabs.create({url: chrome.runtime.getURL('options/options.html' + (request.hash ? '#' + request.hash : ''))});
return;
return false;
case "openHelp":
chrome.tabs.create({url: chrome.runtime.getURL('help/index.html')});
return;
return false;
case "openUpsell":
chrome.tabs.create({url: chrome.runtime.getURL('upsell/index.html')});
return;
return false;
case "openPage":
chrome.tabs.create({url: chrome.runtime.getURL(request.url)});
return;
return false;
case "sendRequest":
sendRequestToCustomServer(request.type, request.url, request.data).then(async (response) => {
callback({
Expand Down Expand Up @@ -112,6 +112,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
popupPort[sender.tab.id]?.postMessage(request);
}
return false;
default:
return false;
}
});

Expand Down
1 change: 1 addition & 0 deletions src/components/SkipNoticeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
</span>
);
}
return null;
}

getSubmissionChooser(): JSX.Element[] {
Expand Down
4 changes: 2 additions & 2 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2112,11 +2112,11 @@ async function vote(type: number, UUID: SegmentUUID, category?: Category, skipNo
return response;
}

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

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

// See if the local time saved count and skip count should be saved
if (type === 0 && sponsorSkipped[sponsorIndex] || type === 1 && !sponsorSkipped[sponsorIndex]) {
Expand Down
2 changes: 1 addition & 1 deletion src/js-components/previewBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ class PreviewBar {
chaptersContainer.style.display = "none";
}

return;
return [];
}

segments ??= [];
Expand Down
6 changes: 4 additions & 2 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ class MessageHandler {

// To prevent clickjacking
let allowPopup = window === window.top;
window.addEventListener("message", async (e) => {
window.addEventListener("message", async (e): Promise<void> => {
if (e.source !== window.parent) return;
if (e.origin.endsWith('.youtube.com')) return allowPopup = true;
if (e.origin.endsWith('.youtube.com')) {
allowPopup = true;
}
});

//make this a function to allow this to run on the content page
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ export default class Utils {
return selection;
}
}
return { name: "None", option: 0} as CategorySelection;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,13 @@ export function getGuidelineInfo(category: Category): TextBox[] {
icon: "icons/check-smaller.svg",
text: chrome.i18n.getMessage(`category_${category}_guideline3`)
}];
default:
return [{
icon: "icons/segway.png",
text: chrome.i18n.getMessage(`generic_guideline1`)
}, {
icon: "icons/right-arrow.svg",
text: chrome.i18n.getMessage(`generic_guideline2`)
}];
}
}
2 changes: 2 additions & 0 deletions src/utils/urlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ export function urlTimeToSeconds(time: string): number {
return hours * 3600 + minutes * 60 + seconds;
} else if (/\d+/.test(time)) {
return parseInt(time, 10);
} else {
return 0;
}
}
2 changes: 2 additions & 0 deletions tsconfig-production.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": false,
"outDir": "dist/js",
"noEmitOnError": false,
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"outDir": "dist/js",
"noEmitOnError": false,
Expand Down

0 comments on commit b407497

Please sign in to comment.