Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #322 from nekochans/feature/issue270/add-prettier-…
Browse files Browse the repository at this point in the history
…plugin-sort-imports

prettier-plugin-sort-imports を導入
  • Loading branch information
keitakn committed Dec 31, 2023
2 parents 680c47e + 570892c commit 3c99239
Show file tree
Hide file tree
Showing 30 changed files with 98 additions and 93 deletions.
45 changes: 0 additions & 45 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,51 +72,6 @@
}
}
],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"object",
"index"
],
"pathGroups": [
{
"pattern": "{react,react-dom/**,react-router*}",
"group": "builtin",
"position": "before"
},
{
"pattern": "{routes/**,stores/**,utils/**,hooks/**,domains/**}",
"group": "internal",
"position": "after"
},
{
"pattern": "{A-Z]*,**/[A-Z]*}",
"group": "internal",
"position": "after"
},
{
"pattern": "assets/**}",
"group": "internal",
"position": "after"
},
{
"pattern": "./*.{css,scss,sass,less}",
"group": "index",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["builtin"],
"alphabetize": {
"order": "asc"
}
}
],
"react/display-name": "off"
},
"overrides": [
Expand Down
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"singleQuote": true,
"endOfLine": "auto"
"endOfLine": "auto",
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"importOrderTypeScriptVersion": "5.3.3"
}
66 changes: 65 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"homepage": "https://github.com/nekochans/lgtm-cat-ui#readme",
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@storybook/addon-a11y": "^7.6.6",
"@storybook/addon-essentials": "^7.6.6",
"@storybook/addon-interactions": "^7.6.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FC, ComponentProps } from 'react';
import type { ComponentProps, FC } from 'react';
import { FaRandom } from 'react-icons/fa';
import { defaultAppUrl, type AppUrl } from '../../../constants';
import { useClipboardMarkdown, useCopySuccess } from '../../../hooks';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/UploadCatButton/UploadCatButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import Link from 'next/link';
import type { FC } from 'react';
import { FaCloudUploadAlt } from 'react-icons/fa';
import type { CustomDataAttrGtmClick } from '../../../types';
import styles from './UploadCatButton.module.css';
Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorContent/BackToTopButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import Link from 'next/link';
import type { FC } from 'react';
import type { Language } from '../../types';
import { assertNever } from '../../utils';
import styles from './BackToTopButton.module.css';
Expand Down
2 changes: 0 additions & 2 deletions src/components/ErrorContent/ErrorContent.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { Meta, StoryObj } from '@storybook/react';
import Image from 'next/image';

import internalServerError from '../../images/internal_server_error.webp';
import notFound from '../../images/not_found.webp';
import serviceUnavailable from '../../images/service_unavailable.webp';

import { ErrorContent } from './';

const meta: Meta<typeof ErrorContent> = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import Link from 'next/link';
import type { FC } from 'react';
import {
createPrivacyPolicyLinksFromLanguages,
createTermsOfUseLinksFromLanguages,
Expand Down
5 changes: 2 additions & 3 deletions src/components/GlobalMenu/GlobalMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { FC } from 'react';
import Link from 'next/link';
import { FaTimes, FaCloudUploadAlt } from 'react-icons/fa';
import type { FC } from 'react';
import { FaCloudUploadAlt, FaTimes } from 'react-icons/fa';
import {
createPrivacyPolicyLinksFromLanguages,
createTermsOfUseLinksFromLanguages,
} from '../../features';

import type { Language } from '../../types';
import styles from './GlobalMenu.module.css';

Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useState, type FC, type MouseEvent } from 'react';
import Link from 'next/link';
import { useState, type FC, type MouseEvent } from 'react';
import { FaBars } from 'react-icons/fa';
import Modal from 'react-modal';
import { GlobalMenu } from '../GlobalMenu';
import styles from './Header.module.css';
import { LanguageButton } from './LanguageButton';
import { LanguageMenu, type Props as LanguageMenuProps } from './LanguageMenu';
import styles from './Header.module.css';

export type Props = LanguageMenuProps & {
isLanguageMenuDisplayed: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/LanguageMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import Link from 'next/link';
import type { FC } from 'react';
import { FaAngleRight } from 'react-icons/fa';
import type { Language } from '../../types';
import styles from './LanguageMenu.module.css';
Expand Down
4 changes: 2 additions & 2 deletions src/components/LgtmImages/LgtmImageContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC } from 'react';
import Image from 'next/image';
import { type AppUrl, defaultAppUrl } from '../../constants';
import type { FC } from 'react';
import { defaultAppUrl, type AppUrl } from '../../constants';
import { useClipboardMarkdown, useCopySuccess } from '../../hooks';
import type { LgtmImage } from '../../types';
import { CopiedGithubMarkdownMessage } from './CopiedGithubMarkdownMessage';
Expand Down
1 change: 0 additions & 1 deletion src/components/LgtmImages/LgtmImages.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react';
import { type LgtmImage } from '../../types';

import { LgtmImages } from './';

const meta: Meta<typeof LgtmImages> = {
Expand Down
3 changes: 1 addition & 2 deletions src/components/Upload/UploadForm/UploadForm.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { Meta, StoryObj } from '@storybook/react';
import { UploadForm } from '.';
import { createSuccessResult } from '../../../features';
import type {
AcceptedTypesImageExtension,
Expand All @@ -8,8 +9,6 @@ import type {
} from '../../../types';
import { sleep } from '../../../utils';

import { UploadForm } from '.';

const meta: Meta<typeof UploadForm> = {
component: UploadForm,
argTypes: {
Expand Down
13 changes: 6 additions & 7 deletions src/components/Upload/UploadForm/UploadForm.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
/* eslint-disable max-lines */
import Link from 'next/link';
import {
useState,
useCallback,
useState,
type ChangeEvent,
type FC,
type FormEvent,
type ChangeEvent,
} from 'react';
import Link from 'next/link';
import { useDropzone } from 'react-dropzone';
import { FaCloudUploadAlt } from 'react-icons/fa';
import type { AppUrl } from '../../../constants';
import {
isValidFileType,
extractImageExtFromValidFileType,
createPrivacyPolicyLinksFromLanguages,
extractImageExtFromValidFileType,
isLgtmImageUrl,
isValidFileType,
} from '../../../features';
import { isAcceptableFileSize } from '../../../features/lgtmImage';
import type {
AcceptedTypesImageExtension,
ImageUploader,
ImageValidator,
LgtmImageUrl,
Language,
LgtmImageUrl,
} from '../../../types';
import { assertNever } from '../../../utils';
import { UploadButton } from '../UploadButton';
import { UploadErrorMessageArea } from '../UploadErrorMessageArea';
import { UploadModal } from '../UploadModal';
import { UploadTitleArea } from '../UploadTitleArea';

import {
cautionText,
createImageSizeTooLargeErrorMessage,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, type FC } from 'react';
import { useEffect, useState, type FC } from 'react';
import type { Language } from '../../../types';
import { assertNever } from '../../../utils';
import styles from './UploadProgressBar.module.css';
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useClipboardMarkdown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type MutableRefObject, useEffect, useRef } from 'react';
import Clipboard from 'clipboard';

import { useEffect, useRef, type MutableRefObject } from 'react';
import type { LgtmImageUrl } from '../types';

type Request = {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useCopySuccess.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useCallback } from 'react';
import { useCallback, useState } from 'react';

type Response = {
copied: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useSwitchLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { MouseEvent, MouseEventHandler } from 'react';
import { useSnapshot } from 'valtio';

import { commonStateSelector, updateIsLanguageMenuDisplayed } from '../stores';

type UseSwitchLanguageResponse = {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './styles/globals.css';

export { useSwitchLanguage } from './hooks';

export * from './templates';
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/ResponsiveLayout/ResponsiveLayout.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import type { FC } from 'react';
import { ResponsiveLayout } from './';

const meta: Meta<typeof ResponsiveLayout> = {
Expand Down
1 change: 0 additions & 1 deletion src/stores/valtio/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { proxy } from 'valtio';

import type { Language } from '../../types';

export type CommonState = {
Expand Down
1 change: 0 additions & 1 deletion src/stores/valtio/lgtmImage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { proxy } from 'valtio';

import type { LgtmImage } from '../../types';

export type LgtmImageState = {
Expand Down
2 changes: 0 additions & 2 deletions src/templates/ErrorTemplate/ErrorTemplate.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { Meta, StoryObj } from '@storybook/react';
import Image from 'next/image';

import internalServerError from '../../images/internal_server_error.webp';
import notFound from '../../images/not_found.webp';
import serviceUnavailable from '../../images/service_unavailable.webp';

import { ErrorTemplate } from './';

const meta: Meta<typeof ErrorTemplate> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { FC } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import type { FC } from 'react';
import { TermsOrPrivacyTemplate, type TemplateType } from '.';
import { MarkdownContents } from '../../components/MarkdownContents';
import { useSwitchLanguage } from '../../hooks';
import type { Language } from '../../types';
import { assertNever } from '../../utils';

import { TermsOrPrivacyTemplate, type TemplateType } from '.';

const privacyPolicyJa = `
# プライバシーポリシー
Expand Down
4 changes: 1 addition & 3 deletions src/templates/TopTemplate/TopTemplate.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react';
import Image from 'next/image';

import internalServerError from '../../images/internal_server_error.webp';

import { type LgtmImage, type CatImagesFetcher } from '../../types';
import { type CatImagesFetcher, type LgtmImage } from '../../types';
import { TopTemplate } from './.';

const meta: Meta<typeof TopTemplate> = {
Expand Down

0 comments on commit 3c99239

Please sign in to comment.