Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter usage of any #2429

Merged
merged 3 commits into from
Sep 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
"rules": {
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
1 change: 1 addition & 0 deletions source/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,5 @@ import './features/clean-rich-text-editor';
import './features/highlight-collaborators-in-lists';

// Add global for easier debugging
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).select = select;
2 changes: 1 addition & 1 deletion source/features/release-download-count.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function getAssetsForTag(tags: string[]): Promise<Tag> {

const assets: Tag = {};
for (const [tag, release] of Object.entries(repository)) {
assets[tag] = (release as any).releaseAssets.nodes;
assets[tag] = (release as AnyObject).releaseAssets.nodes;
}

return assets;
Expand Down
6 changes: 3 additions & 3 deletions source/features/reload-failed-proxied-images.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import delay from 'delay';
import delegate from 'delegate-it';
import delegate, {DelegateEvent} from 'delegate-it';
import loadImage from 'image-promise';
import features from '../libs/features';

async function handleErroredImage({target}: any): Promise<void> {
async function handleErroredImage({delegateTarget}: DelegateEvent<ErrorEvent, HTMLImageElement>): Promise<void> {
await delay(5000);
try {
// A clone image retries downloading
// `loadImage` awaits it
// If successfully loaded, the failed image will be replaced.
target.replaceWith(await loadImage(target.cloneNode() as HTMLImageElement));
delegateTarget.replaceWith(await loadImage(delegateTarget.cloneNode() as HTMLImageElement));
} catch {}
}

Expand Down
3 changes: 1 addition & 2 deletions source/features/revert-file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ async function commitFileContent(menuItem: Element, content: string): Promise<vo
async function handleRevertFileClick(event: React.MouseEvent<HTMLButtonElement>): Promise<void> {
const menuItem = event.currentTarget;
// Allow only one click
// TODO: change JSX event types to be plain browser events
menuItem.removeEventListener('click', handleRevertFileClick as any);
menuItem.removeEventListener('click', handleRevertFileClick as unknown as EventListener);
menuItem.textContent = 'Reverting…';
event.preventDefault();
event.stopPropagation();
Expand Down
2 changes: 2 additions & 0 deletions source/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// TODO: Drop some definitions when their related bugs are resolved
// TODO: Improve JSX types for event listeners so we can use `MouseEvent` instead of `React.MouseEvent`, which is incompatible with regular `addEventListeners` calls

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyObject = Record<string, any>;
type AsyncVoidFunction = () => Promise<void>;

Expand Down
2 changes: 1 addition & 1 deletion source/resolve-conflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare namespace CodeMirror {
}
}

const editor: CodeMirrorInstance = document.querySelector<any>('.CodeMirror').CodeMirror;
const editor = document.querySelector<Element & {CodeMirror: CodeMirrorInstance}>('.CodeMirror')!.CodeMirror;

// Event fired when each file is loaded
editor.on('swapDoc', () => setTimeout(addWidget, 1));
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/globals.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {JSDOM} from 'jsdom';

const {window} = new JSDOM('...');
Expand Down