Skip to content

Commit

Permalink
👕 #335 アップグレードでFormatterの仕様が変わったので修正
Browse files Browse the repository at this point in the history
  • Loading branch information
keitakn committed Aug 16, 2024
1 parent 7396d99 commit f26b706
Show file tree
Hide file tree
Showing 23 changed files with 14 additions and 45 deletions.
2 changes: 1 addition & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* - Please do NOT serve this file on production.
*/

const PACKAGE_VERSION = '2.2.14'
const PACKAGE_VERSION = '2.3.5'
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down
3 changes: 1 addition & 2 deletions src/api/cognito/openIdConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IssueClientCredentialsAccessTokenError } from './IssueClientCredentials

type CognitoTokenResponseBody = {
access_token: string;
// eslint-disable-next-line no-magic-numbers

expires_in: 3600;
token_type: 'Bearer';
};
Expand Down Expand Up @@ -95,7 +95,6 @@ export const issueClientCredentialsAccessToken: IssueClientCredentialsAccessToke
);
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const responseBody = (await response.json()) as unknown;

if (isCognitoTokenResponseBody(responseBody)) {
Expand Down
2 changes: 0 additions & 2 deletions src/api/lgtmeow/lgtmImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from '@/features';
import { mightSetRequestIdToSentry } from '@/utils';

// eslint-disable-next-line require-await
export const fetchLgtmImagesInRandom: FetchLgtmImages = async (
appBaseUrl,
revalidate,
Expand All @@ -41,7 +40,6 @@ export const fetchLgtmImagesInRandom: FetchLgtmImages = async (
return (await response.json()) as LgtmImage[];
};

// eslint-disable-next-line require-await
export const fetchLgtmImagesInRecentlyCreated: FetchLgtmImages = async (
appBaseUrl,
revalidate,
Expand Down
1 change: 0 additions & 1 deletion src/app/api/lgtm-images/recently-created/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const GET = async (request: NextRequest): Promise<Response> => {
options,
);

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const responseBody = (await response.json()) as unknown;
if (isFetchLgtmImagesResponseBody(responseBody)) {
const lgtmImages = responseBody.lgtmImages.map((value) => {
Expand Down
1 change: 0 additions & 1 deletion src/app/api/lgtm-images/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const GET = async (request: NextRequest): Promise<Response> => {

const response = await fetch(`${lgtmeowApiUrl()}/lgtm-images`, options);

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const responseBody = (await response.json()) as unknown;
if (isFetchLgtmImagesResponseBody(responseBody)) {
const lgtmImages = responseBody.lgtmImages.map((value) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/en/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const metadata: Metadata = {

const InternationalizationLayout = ({ children }: Props): JSX.Element => {
return (
<html lang={language} prefix="og: https://ogp.me/ns#">
<html lang={language}>

Check warning on line 53 in src/app/en/layout.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/en/layout.tsx#L53

Added line #L53 was not covered by tests
<head>
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Roboto&family=Zen+Kaku+Gothic+New&display=swap"
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const metadata: Metadata = {

const RootLayout = ({ children }: Props): JSX.Element => {
return (
<html lang={language} prefix="og: https://ogp.me/ns#">
<html lang={language}>

Check warning on line 53 in src/app/layout.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/layout.tsx#L53

Added line #L53 was not covered by tests
<head>
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Roboto&family=Zen+Kaku+Gothic+New&display=swap"
Expand Down
2 changes: 1 addition & 1 deletion src/components/LgtmImages/LgtmImages.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const WithAppUrl: Story = {
export const WithCallbackFunc: Story = {
args: {
images,
// eslint-disable-next-line no-alert

callback: () => {
alert('run callback func!');
},
Expand Down
15 changes: 3 additions & 12 deletions src/components/Upload/UploadForm/UploadForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-lines */
'use client';

import type { AppUrl } from '@/constants';
Expand Down Expand Up @@ -83,7 +82,6 @@ export type Props = {
appUrl?: AppUrl;
};

// eslint-disable-next-line max-lines-per-function, max-statements
export const UploadForm: FC<Props> = ({
language,
imageValidator,
Expand Down Expand Up @@ -143,7 +141,6 @@ export const UploadForm: FC<Props> = ({
setBase64Image(window.btoa(binaryString));
};

// eslint-disable-next-line max-statements
const mightConvertImageToBase64 = (file: File) => {
setUploaded(false);
const fileType = file.type;
Expand Down Expand Up @@ -175,10 +172,9 @@ export const UploadForm: FC<Props> = ({
openModal();
};

// eslint-disable-next-line max-statements
const handleFileUpload = (event: ChangeEvent<HTMLInputElement>) => {
event.preventDefault();
// eslint-disable-next-line no-magic-numbers

if (event.target.files && event.target.files.length > 0) {
const targetIndex = 0;
const file = event.target.files[targetIndex];
Expand All @@ -187,7 +183,6 @@ export const UploadForm: FC<Props> = ({
};

const shouldDisableButton = (): boolean => {
// eslint-disable-next-line no-magic-numbers
if (displayErrorMessages.length !== 0) {
return true;
}
Expand All @@ -201,7 +196,6 @@ export const UploadForm: FC<Props> = ({
openModal();
};

// eslint-disable-next-line max-statements, max-lines-per-function
const executeUpload = async () => {
setIsLoading(true);

Expand All @@ -213,7 +207,6 @@ export const UploadForm: FC<Props> = ({

if (
!imageValidationResult.value.isAcceptableCatImage ||
// eslint-disable-next-line no-magic-numbers
imageValidationResult.value.notAcceptableReason.length !== 0
) {
setDisplayErrorMessages(
Expand Down Expand Up @@ -242,7 +235,6 @@ export const UploadForm: FC<Props> = ({
}
}

// eslint-disable-next-line no-magic-numbers
if (imageUploadResult.value.displayErrorMessages.length !== 0) {
setDisplayErrorMessages(imageUploadResult.value.displayErrorMessages);
stateInitAtError();
Expand All @@ -264,7 +256,6 @@ export const UploadForm: FC<Props> = ({
};

const onDrop = useCallback((acceptedFiles: File[]) => {
// eslint-disable-next-line no-magic-numbers
if (acceptedFiles.length > 0) {
const targetIndex = 0;
const file = acceptedFiles[targetIndex];
Expand All @@ -278,15 +269,15 @@ export const UploadForm: FC<Props> = ({

return (
<div className={styles.wrapper}>
{/* eslint-disable no-magic-numbers */}
{}
{displayErrorMessages.length === 0 ? (
''
) : (
<UploadErrorMessageArea messages={displayErrorMessages} />
)}
<UploadTitleArea language={language} />
<form className={styles.form}>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
{}
<div {...getRootProps()} className={styles['input-file-area']}>
<FaCloudUploadAlt className={styles['fa-cloud-upload-alt']} />
<div className={styles.text}>{imageDropAreaText(language)}</div>
Expand Down
1 change: 0 additions & 1 deletion src/components/Upload/UploadModal/UploadModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const modalStyle = {
},
};

// eslint-disable-next-line max-lines-per-function
export const UploadModal: FC<Props> = ({
isOpen,
language,
Expand Down
1 change: 0 additions & 1 deletion src/features/imageData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-lines */
import type { LgtmImage } from './lgtmImage';

export const imageData: LgtmImage[] = [
Expand Down
9 changes: 2 additions & 7 deletions src/features/lgtmImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ export const isLgtmImageUrl = (value: unknown): value is LgtmImageUrl => {

export const isLgtmImages = (value: unknown): value is LgtmImage[] => {
if (Array.isArray(value)) {
// eslint-disable-next-line no-magic-numbers
if (Object.prototype.toString.call(value[0]) !== '[object Object]') {
return false;
}

// eslint-disable-next-line no-magic-numbers
const lgtmImage = value[0] as LgtmImage;

return (
Expand All @@ -120,11 +118,9 @@ export const extractRandomImages = (numberToExtract: number): LgtmImage[] => {
const copiedLgtmImages = [...imageData];
const result = [];

// eslint-disable-next-line id-length, no-magic-numbers
for (let i = numberToExtract; i > 0; i -= 1) {
// eslint-disable-next-line no-magic-numbers
const rand = Math.floor(Math.random() * (copiedLgtmImages.length + 1)) - 1;
// eslint-disable-next-line no-magic-numbers

result.push(...copiedLgtmImages.splice(rand, 1));
}

Expand All @@ -150,10 +146,9 @@ export const extractImageExtFromValidFileType = (

const calculateFileSize = (file: File): number => {
const kb = 1024;
// eslint-disable-next-line no-magic-numbers

const mb = kb ** 2;

// eslint-disable-next-line no-magic-numbers
return Math.round((file.size / mb) * 100.0) / 100.0;
};

Expand Down
4 changes: 2 additions & 2 deletions src/features/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export type Result<T, E> = SuccessResult<T> | FailureResult<E>;

export const createSuccessResult = <T>(value: T): SuccessResult<T> => ({
value,
// eslint-disable-next-line id-length

_: SuccessMarker,
});

export const createFailureResult = <E>(value: E): FailureResult<E> => ({
value,
// eslint-disable-next-line id-length

_: FailureMarker,
});

Expand Down
2 changes: 0 additions & 2 deletions src/features/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export const isUrl = (value: unknown): value is Url => {
}

return (
// eslint-disable-next-line no-magic-numbers
value.substring(0, 8) === 'https://' ||
// eslint-disable-next-line no-magic-numbers
value.substring(0, 16) === 'http://localhost'
);
};
Expand Down
3 changes: 0 additions & 3 deletions src/features/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ export type ValidationResult = {
invalidParams?: InvalidParams;
};

// eslint-disable-next-line max-statements
const isInvalidParams = (value: unknown): value is InvalidParams => {
if (Array.isArray(value)) {
// eslint-disable-next-line no-magic-numbers
if (value.length === 0) {
return false;
}
Expand Down Expand Up @@ -72,7 +70,6 @@ export const validation = (
} catch (error) {
if (isZodError(error)) {
const invalidParams = error.errors.map((value) => ({
// eslint-disable-next-line no-magic-numbers
name: value.path[0],
reason: value.message,
}));
Expand Down
1 change: 0 additions & 1 deletion src/hooks/__tests__/useCatImageUploader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const mockHandlers = [http.post(uploadCatImageUrl(), mockUploadCatImage)];

const server = setupServer(...mockHandlers);

// eslint-disable-next-line max-lines-per-function, max-statements
describe('useCatImageUploader TestCases', () => {
beforeAll(() => {
server.listen();
Expand Down
1 change: 0 additions & 1 deletion src/hooks/__tests__/useCatImageValidator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const mockHandlers = [

const server = setupServer(...mockHandlers);

// eslint-disable-next-line max-lines-per-function, max-statements
describe('useCatImageValidator TestCases', () => {
beforeAll(() => {
server.listen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const mockHandlers = [http.get(fetchLgtmImagesUrl(), mockFetchLgtmImages)];

const server = setupServer(...mockHandlers);

// eslint-disable-next-line max-lines-per-function
describe('useCatImagesFetcher.ts randomCatImagesFetcher TestCases', () => {
beforeAll(() => {
server.listen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const mockHandlers = [

const server = setupServer(...mockHandlers);

// eslint-disable-next-line max-lines-per-function
describe('useCatImagesFetcher.ts newArrivalCatImagesFetcher TestCases', () => {
beforeAll(() => {
server.listen();
Expand Down
2 changes: 2 additions & 0 deletions src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export async function register(): Promise<void> {
if (process.env.NEXT_RUNTIME === 'nodejs') {
// eslint-disable-next-line import/extensions

Check warning on line 3 in src/instrumentation.ts

View check run for this annotation

Codecov / codecov/patch

src/instrumentation.ts#L3

Added line #L3 was not covered by tests
await import('../sentry.server.config');
}

if (process.env.NEXT_RUNTIME === 'edge') {
// eslint-disable-next-line import/extensions

Check warning on line 8 in src/instrumentation.ts

View check run for this annotation

Codecov / codecov/patch

src/instrumentation.ts#L8

Added line #L8 was not covered by tests
await import('../sentry.edge.config');
}
}
1 change: 0 additions & 1 deletion src/layouts/DefaultLayout/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type Props = {
}>;
};

// eslint-disable-next-line max-lines-per-function
export const DefaultLayout: FC<Props> = ({
metaTag,
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Props = {
children: ReactNode;
};

// eslint-disable-next-line max-lines-per-function
export const ExternalTransmissionTemplate: FC<Props> = ({
language,
currentUrlPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Props = {
children: ReactNode;
};

// eslint-disable-next-line max-lines-per-function
export const TermsOrPrivacyTemplate: FC<Props> = ({
language,
currentUrlPath,
Expand Down

0 comments on commit f26b706

Please sign in to comment.