Skip to content

Commit

Permalink
Merge pull request #250 from nekochans/feature/issue222/fix-tsconfig-…
Browse files Browse the repository at this point in the history
…json

tsconfig.json の内容を create-next-app の最新版で生成される内容に変更
  • Loading branch information
keitakn committed Apr 3, 2023
2 parents cbafa55 + 3e120d4 commit 41db133
Show file tree
Hide file tree
Showing 41 changed files with 96 additions and 99 deletions.
24 changes: 11 additions & 13 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const { defaults: tsjPreset } = require('ts-jest/presets');
const nextJest = require('next/jest');

module.exports = {
preset: 'ts-jest',
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
});

/** @type {import('@jest/types').Config.InitialOptions} */
const customJestConfig = {
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
transform: {
...tsjPreset.transform,
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coveragePathIgnorePatterns: ['<rootDir>/.storybook/__mocks/'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js',
'^@/*/(.*)$': '<rootDir>/src/$1',
},
};

module.exports = createJestConfig(customJestConfig);
6 changes: 3 additions & 3 deletions src/api/fetch/lgtmImage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { httpStatusCode } from '../../constants';
import { httpStatusCode } from '@/constants';
import {
FetchLgtmImagesError,
IsAcceptableCatImageError,
Expand All @@ -20,8 +20,8 @@ import {
type UploadCatImage,
type LgtmImageUrl,
type Url,
} from '../../features';
import { mightSetRequestIdToSentry } from '../../utils';
} from '@/features';
import { mightSetRequestIdToSentry } from '@/utils';

type FetchImageResponseBody = {
lgtmImages: Array<{
Expand Down
2 changes: 1 addition & 1 deletion src/components/GoogleTagManager/GoogleTagManager.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FC } from 'react';
import Script from 'next/script';

import { type GoogleTagManagerId } from '../../utils';
import { type GoogleTagManagerId } from '@/utils';

type Props = {
googleTagManagerId: GoogleTagManagerId;
Expand Down
2 changes: 1 addition & 1 deletion src/features/metaTag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertNever } from '../utils';
import { assertNever } from '@/utils';

import type { Language } from './language';
import { appUrlList, type AppPathName, type AppUrl } from './url';
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/__tests__/useCatImageUploader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
uploadCatImageUrl,
type AcceptedTypesImageExtension,
type Language,
} from '../../features';
} from '@/features';
import { useCatImageUploader } from '@/hooks/useCatImageUploader';
import {
mockInternalServerError,
mockUploadCatImage,
mockUploadCatImagePayloadTooLarge,
mockUploadCatImageUnprocessableEntity,
} from '../../mocks';
import { useCatImageUploader } from '../useCatImageUploader';
} from '@/mocks';

const mockHandlers = [rest.post(uploadCatImageUrl(), mockUploadCatImage)];

Expand Down
6 changes: 3 additions & 3 deletions src/hooks/__tests__/useCatImageValidator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
isAcceptableCatImageUrl,
type AcceptedTypesImageExtension,
type Language,
} from '../../features';
} from '@/features';
import { useCatImageValidator } from '@/hooks/useCatImageValidator';
import {
mockInternalServerError,
mockIsAcceptableCatImage,
Expand All @@ -20,8 +21,7 @@ import {
mockIsAcceptableCatImageNotModerationImage,
mockIsAcceptableCatImagePayloadTooLargeError,
mockIsAcceptableCatImagePersonFaceInImage,
} from '../../mocks';
import { useCatImageValidator } from '../useCatImageValidator';
} from '@/mocks';

const mockHandlers = [
rest.post(isAcceptableCatImageUrl(), mockIsAcceptableCatImage),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import 'whatwg-fetch';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { fetchLgtmImagesUrl, FetchLgtmImagesError } from '../../../features';
import { fetchLgtmImagesUrl, FetchLgtmImagesError } from '@/features';
import { useCatImagesFetcher } from '@/hooks/useCatImagesFetcher';
import {
mockInternalServerError,
mockFetchLgtmImages,
fetchLgtmImagesMockBody,
} from '../../../mocks';
import { useCatImagesFetcher } from '../../useCatImagesFetcher';
} from '@/mocks';

const mockHandlers = [rest.get(fetchLgtmImagesUrl(), mockFetchLgtmImages)];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { setupServer } from 'msw/node';
import {
fetchLgtmImagesInRecentlyCreatedUrl,
FetchLgtmImagesError,
} from '../../../features';
} from '@/features';
import { useCatImagesFetcher } from '@/hooks/useCatImagesFetcher';
import {
mockInternalServerError,
mockFetchLgtmImages,
fetchLgtmImagesMockBody,
} from '../../../mocks';
import { useCatImagesFetcher } from '../../useCatImagesFetcher';
} from '@/mocks';

const mockHandlers = [
rest.get(fetchLgtmImagesInRecentlyCreatedUrl(), mockFetchLgtmImages),
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/createErrorMessages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Language } from '../features';
import { type Language } from '@/features';

export const createCatImageSizeTooLargeErrorMessages = (
language: Language
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useCatImageUploader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uploadCatImage } from '../api';
import { uploadCatImage } from '@/api';
import {
UploadCatImageSizeTooLargeError,
UploadCatImageValidationError,
Expand All @@ -7,7 +7,7 @@ import {
type Language,
type AcceptedTypesImageExtension,
type ImageUploader,
} from '../features';
} from '@/features';

import {
createCatImageSizeTooLargeErrorMessages,
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useCatImageValidator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { isAcceptableCatImage } from '../api';
import { isAcceptableCatImage } from '@/api';
import {
createSuccessResult,
isFailureResult,
type Language,
type AcceptedTypesImageExtension,
type IsAcceptableCatImageNotAcceptableReason,
type ImageValidator,
} from '../features';
import { assertNever } from '../utils';
} from '@/features';
import { assertNever } from '@/utils';

import {
createCatImageSizeTooLargeErrorMessages,
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useCatImagesFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import throttle from 'lodash/throttle';
import {
fetchLgtmImagesInRandom,
fetchLgtmImagesInRecentlyCreated,
} from '../api';
} from '@/api';

import type { CatImagesFetcher, LgtmImage } from '../features';
import type { CatImagesFetcher, LgtmImage } from '@/features';

const randomCatImagesFetcher = async (): Promise<LgtmImage[]> => {
return await fetchLgtmImagesInRandom();
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/DefaultLayout/DefaultLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FC, ReactNode } from 'react';
import Head from 'next/head';

import type { Language, MetaTag, Url } from '../../features';
import type { Language, MetaTag, Url } from '@/features';

type Props = {
metaTag: MetaTag;
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/ErrorLayout/ErrorLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FC, ReactNode } from 'react';
import Head from 'next/head';

import type { MetaTag } from '../../features';
import type { MetaTag } from '@/features';

type Props = {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
NextResponse,
} from 'next/server';

import { isBanCountry, isInMaintenance } from './edge';
import { isBanCountry, isInMaintenance } from '@/edge';

export const config = {
matcher: ['/', '/upload', '/terms', '/privacy', '/maintenance'],
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/api/error/mockInternalServerError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../constants';
import { httpStatusCode } from '@/constants';

export const mockInternalServerError: ResponseResolver<
MockedRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/api/error/mockUnauthorizedError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../constants';
import { httpStatusCode } from '@/constants';

export const mockUnauthorizedError: ResponseResolver<
MockedRequest,
Expand Down
4 changes: 2 additions & 2 deletions src/mocks/api/external/lgtmeow/mockFetchLgtmImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { fetchLgtmImagesMockBody } from '../../fetchLgtmImagesMockBody';
import { httpStatusCode } from '@/constants';
import { fetchLgtmImagesMockBody } from '@/mocks';

export const mockFetchLgtmImages: ResponseResolver<
MockedRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/api/external/lgtmeow/mockUploadCatImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockUploadCatImage: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockUploadCatImagePayloadTooLarge: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockUploadCatImageUnprocessableEntity: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockIsAcceptableCatImage: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockIsAcceptableCatImageError: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockIsAcceptableCatImageNotAllowedImageExtension: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockIsAcceptableCatImageNotCatImage: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockIsAcceptableCatImageNotModerationImage: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockIsAcceptableCatImagePayloadTooLargeError: ResponseResolver<
MockedRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type restContext,
} from 'msw';

import { httpStatusCode } from '../../../../constants';
import { httpStatusCode } from '@/constants';

export const mockIsAcceptableCatImagePersonFaceInImage: ResponseResolver<
MockedRequest,
Expand Down
6 changes: 3 additions & 3 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GetStaticProps, NextPage } from 'next';
import { httpStatusCode } from '../constants';
import { convertLocaleToLanguage, type Language } from '../features';
import { ErrorTemplate } from '../templates';
import { httpStatusCode } from '@/constants';
import { convertLocaleToLanguage, type Language } from '@/features';
import { ErrorTemplate } from '@/templates';

type Props = {
language: Language;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GetStaticProps, NextPage } from 'next';
import { httpStatusCode } from '../constants';
import { convertLocaleToLanguage, type Language } from '../features';
import { ErrorTemplate } from '../templates';
import { httpStatusCode } from '@/constants';
import { convertLocaleToLanguage, type Language } from '@/features';
import { ErrorTemplate } from '@/templates';

type Props = {
language: Language;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AppProps } from 'next/app';
import { GoogleTagManager } from '../components';
import { googleTagManagerId } from '../utils';
import { GoogleTagManager } from '@/components';
import { googleTagManagerId } from '@/utils';

import 'ress/ress.css';
import '../styles/markdown.css';
Expand Down
6 changes: 3 additions & 3 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { GetStaticProps, NextPage } from 'next';
import { fetchLgtmImagesInRandom } from '../api';
import { fetchLgtmImagesInRandom } from '@/api';
import {
convertLocaleToLanguage,
extractRandomImages,
type Language,
type LgtmImage,
} from '../features';
import { TopTemplate } from '../templates';
} from '@/features';
import { TopTemplate } from '@/templates';

type Props = {
language: Language;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/maintenance.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GetStaticProps, NextPage } from 'next';
import { httpStatusCode } from '../constants';
import { convertLocaleToLanguage, type Language } from '../features';
import { ErrorTemplate } from '../templates';
import { httpStatusCode } from '@/constants';
import { convertLocaleToLanguage, type Language } from '@/features';
import { ErrorTemplate } from '@/templates';

type Props = {
language: Language;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/privacy.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs';

import type { GetStaticProps, NextPage } from 'next';
import { convertLocaleToLanguage, type Language } from '../features';
import { TermsOrPrivacyTemplate } from '../templates';
import { convertLocaleToLanguage, type Language } from '@/features';
import { TermsOrPrivacyTemplate } from '@/templates';

type Props = {
language: Language;
Expand Down

1 comment on commit 41db133

@vercel
Copy link

@vercel vercel bot commented on 41db133 Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.