Skip to content

Commit 043549b

Browse files
committedJun 18, 2021
Refine eslint rules
1 parent 9325384 commit 043549b

File tree

13 files changed

+21
-32
lines changed

13 files changed

+21
-32
lines changed
 

‎.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"ignorePatterns": [".cache/**", "dist/**", "node_modules/**"],
1111
"rules": {
1212
"@typescript-eslint/explicit-module-boundary-types": 0,
13+
"@typescript-eslint/no-explicit-any": 0,
1314
"@typescript-eslint/no-non-null-assertion": 0
1415
}
1516
}

‎src/0-dom/isMobile.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const FIRST_MATCH =
33
const SECOND_MATCH =
44
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i;
55

6-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
76
const ua = navigator.userAgent || navigator.vendor || (window as any).opera;
87

9-
export const isMobile = FIRST_MATCH.test(ua) || SECOND_MATCH.test(ua.substr(0, 4));
8+
export const isMobile =
9+
FIRST_MATCH.test(ua) || SECOND_MATCH.test(ua.substr(0, 4));

‎src/0-dom/page-visibility.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
31
import { emitter } from '@amatiasq/emitter';
42

53
const { isHidden, eventName } = getKeyNames();
64
const emitVisibilityChange = emitter<boolean>();
75

8-
type VisibilityChangeListener = Parameters<typeof emitVisibilityChange.subscribe>[0];
6+
type VisibilityChangeListener = Parameters<
7+
typeof emitVisibilityChange.subscribe
8+
>[0];
99

1010
document.addEventListener(
1111
eventName,
12-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
13-
// @ts-ignore
1412
() => emitVisibilityChange(!document[isHidden]),
1513
false,
1614
);
@@ -29,21 +27,21 @@ function getKeyNames() {
2927
return {
3028
isHidden: 'hidden',
3129
eventName: 'visibilitychange',
32-
};
30+
} as const;
3331
}
3432

3533
if ((document as any).msHidden != null) {
3634
return {
37-
isHidden: 'msHidden',
38-
eventName: 'msvisibilitychange',
39-
};
35+
isHidden: 'msHidden' as 'hidden',
36+
eventName: 'msvisibilitychange' as 'visibilitychange',
37+
} as const;
4038
}
4139

4240
if ((document as any).webkitHidden != null) {
4341
return {
44-
isHidden: 'webkitHidden',
45-
eventName: 'webkitvisibilitychange',
46-
};
42+
isHidden: 'webkitHidden' as 'hidden',
43+
eventName: 'webkitvisibilitychange' as 'visibilitychange',
44+
} as const;
4745
}
4846

4947
throw unsupportedBrowser();

‎src/1-core/messageBus.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
31
import { v4 as uuid } from 'uuid';
42

53
import { Emitter, emitter } from '@amatiasq/emitter';

‎src/3-github/GHRepositoryApi.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const CREATE_REPO_CONFIG = {
2323
is_template: false,
2424
};
2525

26-
// This is necessary because of https://github.com/microsoft/TypeScript/issues/14174#issuecomment-856812565
27-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
26+
// any is necessary here because of https://github.com/microsoft/TypeScript/issues/14174#issuecomment-856812565
2827
export type StagedFiles = Record<string, any>;
2928

3029
export interface GHRepoNode {

‎src/4-storage/middleware/GHGistStore.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { AsyncStore } from '../AsyncStore';
22

3-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3+
// THIS IS JUST PLACEHOLDER
4+
// CODE NOT IN USE
45
export type GithubGists = any;
56

6-
// THIS IS JUST PLACEHOLDER
77
export class GHGistStore implements AsyncStore {
88
constructor(private readonly gists: GithubGists) {}
99

‎src/4-storage/middleware/ResilientOnlineStore.ts

-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export class ResilientOnlineStore<ReadOptions, WriteOptions>
7676
}
7777

7878
// TS doesn't recognize params as valid parameters for method
79-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8079
const promise: Promise<void> = (this.remote[method] as any)(...params);
8180

8281
return promise.catch(reason => {
@@ -96,7 +95,6 @@ export class ResilientOnlineStore<ReadOptions, WriteOptions>
9695
this.pending.length = 0;
9796

9897
for (const { method, params } of copy) {
99-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10098
(this[method] as any)(params);
10199
}
102100
}

‎src/6-hooks/useNavigator.ts

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export function useNavigator() {
4343
return new Navigator(history, history.location.pathname);
4444
}
4545

46-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4746
function acceptNoteOrId(op: (id: NoteId) => any) {
4847
return (noteOrId: Note | NoteId) =>
4948
op(typeof noteOrId === 'string' ? noteOrId : noteOrId.id);

‎src/7-components/Editor/MonacoExtensions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function defineSemanticTokens(monaco: Monaco) {
101101

102102
return {
103103
data: new Uint32Array(data),
104-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
104+
// null is valid but type definition complains
105105
resultId: null as any,
106106
};
107107
},

‎src/7-components/NotesList/NoteGroup.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ export function NoteGroup({ group, notes }: { group: string; notes: Note[] }) {
3838

3939
return (
4040
<details className={cn.join(' ')} data-group={group} open={isOpen}>
41-
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
42-
<summary className="group-title" onClick={onGroupClicked as any}>
41+
<summary className="group-title" onClick={onGroupClicked}>
4342
<Icon name="angle-right" className="icon-button group-caret" />
4443
<span className="group-name">{group}</span>
4544
<i className="counter">{notes.length}</i>
@@ -54,7 +53,7 @@ export function NoteGroup({ group, notes }: { group: string; notes: Note[] }) {
5453
);
5554
}
5655

57-
function onGroupClicked(event: MouseEvent) {
56+
function onGroupClicked(event: React.MouseEvent<HTMLElement, MouseEvent>) {
5857
const target = (event.currentTarget as HTMLElement)
5958
.parentElement as HTMLDetailsElement;
6059

‎src/7-components/atoms/InputField.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ export function InputField({
9595
}
9696

9797
function resetContent() {
98-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9998
ref.current!.innerText = value;
10099
}
101100
}

‎src/util/debugMethods.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
let indent = 0;
22

33
export function debugMethods<Key extends string>(
4-
// eslint-disable-next-line @typescript-eslint/ban-types
5-
self: Record<Key, Function>,
4+
self: Record<Key, (...args: any[]) => any>,
65
methods: Key[],
76
label?: string,
87
) {
98
const className = self.constructor.name;
109
methods.forEach(method => {
1110
const original = self[method];
1211

13-
self[method] = (...args: any[]) => {
12+
self[method] = (...args: unknown[]) => {
1413
const x = ' '.repeat(indent++);
1514
const y = label ? ` [${label}]` : '';
1615

‎src/util/serialization.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
21
export function serialize(x: any) {
32
return JSON.stringify(x, null, 2);
43
}

0 commit comments

Comments
 (0)
Please sign in to comment.