Skip to content

Commit 922d75f

Browse files
committed
fix remaining eslint error
1 parent dc84af9 commit 922d75f

File tree

15 files changed

+30
-28
lines changed

15 files changed

+30
-28
lines changed

.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ module.exports = {
4545
rules: {
4646
eqeqeq: 'error',
4747
'prettier/prettier': ['error', prettier],
48+
// TypeScript can infer this significantly better than eslint ever can.
49+
'react/prop-types': 0,
50+
'react/display-name': 0,
51+
'@typescript-eslint/no-explicit-any': 0,
52+
'@typescript-eslint/no-non-null-assertion': 0,
4853
// This setup is required to avoid a spam of errors when running eslint about React being
4954
// used before it is defined.
5055
//

resources/scripts/components/NavigationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default () => {
4040
const onTriggerLogout = () => {
4141
setIsLoggingOut(true);
4242
http.post('/auth/logout').finally(() => {
43-
// @ts-ignore
43+
// @ts-expect-error this is valid
4444
window.location = '/';
4545
});
4646
};

resources/scripts/components/auth/LoginCheckpointContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const EnhancedForm = withFormik<Props, Values>({
7777
loginCheckpoint(location.state?.token || '', code, recoveryCode)
7878
.then((response) => {
7979
if (response.complete) {
80-
// @ts-ignore
80+
// @ts-expect-error this is valid
8181
window.location = response.intended || '/';
8282
return;
8383
}

resources/scripts/components/auth/LoginContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const LoginContainer = ({ history }: RouteComponentProps) => {
4646
login({ ...values, recaptchaData: token })
4747
.then((response) => {
4848
if (response.complete) {
49-
// @ts-ignore
49+
// @ts-expect-error this is valid
5050
window.location = response.intended || '/';
5151
return;
5252
}

resources/scripts/components/auth/ResetPasswordContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default ({ match, location }: RouteComponentProps<{ token: string }>) =>
3333
clearFlashes();
3434
performPasswordReset(email, { token: match.params.token, password, passwordConfirmation })
3535
.then(() => {
36-
// @ts-ignore
36+
// @ts-expect-error this is valid
3737
window.location = '/';
3838
})
3939
.catch((error) => {
@@ -57,7 +57,7 @@ export default ({ match, location }: RouteComponentProps<{ token: string }>) =>
5757
.min(8, 'Your new password should be at least 8 characters in length.'),
5858
passwordConfirmation: string()
5959
.required('Your new password does not match.')
60-
// @ts-ignore
60+
// @ts-expect-error this is valid
6161
.oneOf([ref('password'), null], 'Your new password does not match.'),
6262
})}
6363
>

resources/scripts/components/dashboard/ServerRow.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ const StatusIndicatorBox = styled(GreyRowBox)<{ $status: ServerPowerState | unde
4747
}
4848
`;
4949

50+
type Timer = ReturnType<typeof setInterval>;
51+
5052
export default ({ server, className }: { server: Server; className?: string }) => {
51-
const interval = useRef<number>(null);
53+
const interval = useRef<Timer>(null) as React.MutableRefObject<Timer>;
5254
const [isSuspended, setIsSuspended] = useState(server.status === 'suspended');
5355
const [stats, setStats] = useState<ServerStats | null>(null);
5456

@@ -67,7 +69,6 @@ export default ({ server, className }: { server: Server; className?: string }) =
6769
if (isSuspended) return;
6870

6971
getStats().then(() => {
70-
// @ts-ignore
7172
interval.current = setInterval(() => getStats(), 30000);
7273
});
7374

resources/scripts/components/dashboard/forms/UpdatePasswordForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default () => {
4040
clearFlashes('account:password');
4141
updateAccountPassword({ ...values })
4242
.then(() => {
43-
// @ts-ignore
43+
// @ts-expect-error this is valid
4444
window.location = '/auth/login';
4545
})
4646
.catch((error) =>

resources/scripts/components/elements/CodemirrorEditor.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ export default ({ style, initialContent, filename, mode, fetchContent, onContent
169169
autocorrect: false,
170170
autocapitalize: false,
171171
lint: false,
172-
// This property is actually used, the d.ts file for CodeMirror is incorrect.
173-
// @ts-ignore
172+
// @ts-expect-error this property is actually used, the d.ts file for CodeMirror is incorrect.
174173
autoCloseBrackets: true,
175174
matchBrackets: true,
176175
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],

resources/scripts/components/elements/Icon.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ interface Props {
99
}
1010

1111
const Icon = ({ icon, className, style }: Props) => {
12-
let [width, height, , , paths] = icon.icon;
13-
14-
paths = Array.isArray(paths) ? paths : [paths];
12+
const [width, height, , , paths] = icon.icon;
1513

1614
return (
1715
<svg
@@ -21,7 +19,7 @@ const Icon = ({ icon, className, style }: Props) => {
2119
className={className}
2220
style={style}
2321
>
24-
{paths.map((path, index) => (
22+
{(Array.isArray(paths) ? paths : [paths]).map((path, index) => (
2523
<path key={`svg_path_${index}`} d={path} />
2624
))}
2725
</svg>

resources/scripts/components/elements/ProgressBar.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ const BarFill = styled.div`
1111
box-shadow: 0 -2px 10px 2px hsl(178, 78%, 57%);
1212
`;
1313

14+
type Timer = ReturnType<typeof setTimeout>;
15+
1416
export default () => {
15-
const interval = useRef<number>(null);
16-
const timeout = useRef<number>(null);
17+
const interval = useRef<Timer>(null) as React.MutableRefObject<Timer>;
18+
const timeout = useRef<Timer>(null) as React.MutableRefObject<Timer>;
1719
const [visible, setVisible] = useState(false);
1820
const progress = useStoreState((state) => state.progress.progress);
1921
const continuous = useStoreState((state) => state.progress.continuous);
@@ -30,7 +32,6 @@ export default () => {
3032
setVisible((progress || 0) > 0);
3133

3234
if (progress === 100) {
33-
// @ts-ignore
3435
timeout.current = setTimeout(() => setProgress(undefined), 500);
3536
}
3637
}, [progress]);
@@ -52,8 +53,7 @@ export default () => {
5253
if ((progress || 0) >= 90) {
5354
setProgress(90);
5455
} else {
55-
// @ts-ignore
56-
interval.current = setTimeout(() => setProgress(progress + randomInt(1, 5)), 500);
56+
interval.current = setTimeout(() => setProgress((progress || 0) + randomInt(1, 5)), 500);
5757
}
5858
}
5959
}, [progress, continuous]);

0 commit comments

Comments
 (0)