From c7ddfd685c1f358fd65b6ede880e2e186159fee7 Mon Sep 17 00:00:00 2001 From: kokororin Date: Wed, 20 Jun 2018 09:28:59 +0800 Subject: [PATCH] Remove index.js --- src/actions/gallery.js | 2 +- src/actions/illust.js | 3 ++- src/actions/index.js | 2 -- src/components/Comment.js | 2 +- src/components/List.js | 2 +- src/components/Login.js | 4 +++- src/components/TrackPageView.js | 3 ++- src/components/index.js | 12 ------------ src/containers/AppContainer.js | 14 +++++++------- src/containers/GalleryContainer.js | 11 ++++++++--- src/containers/IllustContainer.js | 22 +++++++++++----------- src/containers/LoginContainer.js | 8 ++++++-- src/containers/NotFoundContainer.js | 2 +- src/containers/RedirectContainer.js | 2 +- src/containers/index.js | 10 ---------- src/index.js | 2 +- src/locale/index.js | 1 - src/reducers/gallery.js | 2 +- src/reducers/illust.js | 2 +- src/utils/cachedFetch.js | 4 +++- src/utils/getImagesFromZip.js | 2 +- src/utils/index.js | 9 --------- test/actions/galleryTest.js | 6 ++++-- test/utils/EmojiParserTest.js | 2 +- test/utils/StorageTest.js | 2 +- test/utils/cachedFetchTest.js | 2 +- test/utils/hashStrTest.js | 2 +- test/utils/momentTest.js | 2 +- 28 files changed, 60 insertions(+), 77 deletions(-) delete mode 100644 src/actions/index.js delete mode 100644 src/components/index.js delete mode 100644 src/containers/index.js delete mode 100644 src/locale/index.js delete mode 100644 src/utils/index.js diff --git a/src/actions/gallery.js b/src/actions/gallery.js index 4e53c80..d72e268 100644 --- a/src/actions/gallery.js +++ b/src/actions/gallery.js @@ -1,7 +1,7 @@ import namespacedTypes from 'namespaced-types'; import config from '@/config'; -import { cachedFetch } from '@/utils'; +import cachedFetch from '@/utils/cachedFetch'; export const types = namespacedTypes('gallery', [ 'SET_ITEMS', diff --git a/src/actions/illust.js b/src/actions/illust.js index ab81b36..f86fbcf 100644 --- a/src/actions/illust.js +++ b/src/actions/illust.js @@ -1,7 +1,8 @@ import namespacedTypes from 'namespaced-types'; import config from '@/config'; -import { cachedFetch, getImagesFromZip } from '@/utils'; +import cachedFetch from '@/utils/cachedFetch'; +import getImagesFromZip from '@/utils/getImagesFromZip'; export const types = namespacedTypes('illust', [ 'SET_ITEM', diff --git a/src/actions/index.js b/src/actions/index.js deleted file mode 100644 index f1c0082..0000000 --- a/src/actions/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export * as GalleryActions from '@/actions/gallery'; -export * as IllustActions from '@/actions/illust'; diff --git a/src/components/Comment.js b/src/components/Comment.js index 85aa5df..7e49374 100644 --- a/src/components/Comment.js +++ b/src/components/Comment.js @@ -6,7 +6,7 @@ import CSSModules from 'react-css-modules'; import Img from 'react-image'; import ListItem from 'react-mdl/lib/List/ListItem'; import ListItemContent from 'react-mdl/lib/List/ListItemContent'; -import { EmojiParser } from '@/utils'; +import EmojiParser from '@/utils/EmojiParser'; const Comment = ({ item }) => { for (const badWord of Comment.badWords) { diff --git a/src/components/List.js b/src/components/List.js index 90ae8d3..b34d8a7 100644 --- a/src/components/List.js +++ b/src/components/List.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Masonry from 'react-masonry-component'; -import { Item } from '@/components'; +import Item from '@/components/Item'; export default class List extends React.Component { static propTypes = { diff --git a/src/components/Login.js b/src/components/Login.js index cd3192b..fa1fa2a 100644 --- a/src/components/Login.js +++ b/src/components/Login.js @@ -10,7 +10,9 @@ import Button from 'react-mdl/lib/Button'; import Textfield from 'react-mdl/lib/Textfield'; import Icon from 'react-mdl/lib/Icon'; import { FormattedMessage, injectIntl } from 'react-intl'; -import { moment, Storage, withRef } from '@/utils'; +import moment from '@/utils/moment'; +import Storage from '@/utils/Storage'; +import withRef from '@/utils/withRef'; class Login extends React.Component { static propTypes = { diff --git a/src/components/TrackPageView.js b/src/components/TrackPageView.js index ef6c1ba..a5ec842 100644 --- a/src/components/TrackPageView.js +++ b/src/components/TrackPageView.js @@ -3,7 +3,8 @@ import ReactGA from 'react-ga'; import { Route } from 'react-router-dom'; import config from '@/config'; -import { Piwik, cachedFetch } from '@/utils'; +import Piwik from '@/utils/Piwik'; +import cachedFetch from '@/utils/cachedFetch'; export default class TrackPageView extends React.Component { constructor(props) { diff --git a/src/components/index.js b/src/components/index.js deleted file mode 100644 index 7bbee24..0000000 --- a/src/components/index.js +++ /dev/null @@ -1,12 +0,0 @@ -export Alert from '@/components/Alert'; -export Comment from '@/components/Comment'; -export GifPlayer from '@/components/GifPlayer'; -export InfiniteScroll from '@/components/InfiniteScroll'; -export Item from '@/components/Item'; -export List from '@/components/List'; -export Login from '@/components/Login'; -export Loading from '@/components/Loading'; -export Message from '@/components/Message'; -export Refresh from '@/components/Refresh'; -export ScrollContext from '@/components/ScrollContext'; -export TrackPageView from '@/components/TrackPageView'; diff --git a/src/containers/AppContainer.js b/src/containers/AppContainer.js index b8eac1e..2494827 100644 --- a/src/containers/AppContainer.js +++ b/src/containers/AppContainer.js @@ -7,13 +7,13 @@ import '@/styles/Base.scss'; import '@/styles/Reset.scss'; import { history } from '@/stores'; -import { - GalleryContainer, - IllustContainer, - RedirectContainer, - NotFoundContainer -} from '@/containers'; -import { ScrollContext, TrackPageView } from '@/components'; +import GalleryContainer from '@/containers/GalleryContainer'; +import IllustContainer from '@/containers/IllustContainer'; +import RedirectContainer from '@/containers/RedirectContainer'; +import NotFoundContainer from '@/containers/NotFoundContainer'; + +import ScrollContext from '@/components/ScrollContext'; +import TrackPageView from '@/components/TrackPageView'; const AppContainer = () => ( diff --git a/src/containers/GalleryContainer.js b/src/containers/GalleryContainer.js index 30256a1..4f6a29c 100644 --- a/src/containers/GalleryContainer.js +++ b/src/containers/GalleryContainer.js @@ -15,9 +15,14 @@ import { injectIntl } from 'react-intl'; import config from '@/config'; -import { GalleryActions } from '@/actions'; -import { InfiniteScroll, List, Loading, Refresh, Message } from '@/components'; -import { scrollTo, Storage } from '@/utils'; +import * as GalleryActions from '@/actions/gallery'; +import InfiniteScroll from '@/components/InfiniteScroll'; +import List from '@/components/List'; +import Loading from '@/components/Loading'; +import Refresh from '@/components/Refresh'; +import Message from '@/components/Message'; +import scrollTo from '@/utils/scrollTo'; +import Storage from '@/utils/Storage'; @injectIntl export class GalleryContainerWithoutStore extends React.Component { diff --git a/src/containers/IllustContainer.js b/src/containers/IllustContainer.js index 7b641e9..6f6fc58 100644 --- a/src/containers/IllustContainer.js +++ b/src/containers/IllustContainer.js @@ -18,17 +18,17 @@ import { FormattedMessage, injectIntl } from 'react-intl'; import config from '@/config'; -import { IllustActions } from '@/actions'; -import { - Alert, - Comment, - GifPlayer, - InfiniteScroll, - Loading, - Message -} from '@/components'; -import { LoginContainer } from '@/containers'; -import { cachedFetch, moment, Storage } from '@/utils'; +import * as IllustActions from '@/actions/illust'; +import Alert from '@/components/Alert'; +import Comment from '@/components/Comment'; +import GifPlayer from '@/components/GifPlayer'; +import InfiniteScroll from '@/components/InfiniteScroll'; +import Loading from '@/components/Loading'; +import Message from '@/components/Message'; +import LoginContainer from '@/containers/LoginContainer'; +import cachedFetch from '@/utils/cachedFetch'; +import moment from '@/utils/moment'; +import Storage from '@/utils/Storage'; @injectIntl @CSSModules(styles, { allowMultiple: true }) diff --git a/src/containers/LoginContainer.js b/src/containers/LoginContainer.js index 576b5f8..d3b1885 100644 --- a/src/containers/LoginContainer.js +++ b/src/containers/LoginContainer.js @@ -1,8 +1,12 @@ import React from 'react'; import { injectIntl } from 'react-intl'; -import { Alert, Login } from '@/components'; -import { cachedFetch, moment, Storage, withRef } from '@/utils'; +import Alert from '@/components/Alert'; +import Login from '@/components/Login'; +import cachedFetch from '@/utils/cachedFetch'; +import moment from '@/utils/moment'; +import Storage from '@/utils/Storage'; +import withRef from '@/utils/withRef'; import config from '@/config'; diff --git a/src/containers/NotFoundContainer.js b/src/containers/NotFoundContainer.js index a1d907a..e9fceb5 100644 --- a/src/containers/NotFoundContainer.js +++ b/src/containers/NotFoundContainer.js @@ -1,6 +1,6 @@ import React from 'react'; -import { Message } from '@/components'; +import Message from '@/components/Message'; const NotFoundContainer = () => ; diff --git a/src/containers/RedirectContainer.js b/src/containers/RedirectContainer.js index eab0939..50ee595 100644 --- a/src/containers/RedirectContainer.js +++ b/src/containers/RedirectContainer.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { injectIntl } from 'react-intl'; -import { Message } from '@/components'; +import Message from '@/components/Message'; @injectIntl export default class RedirectContainer extends React.Component { diff --git a/src/containers/index.js b/src/containers/index.js deleted file mode 100644 index 2d44b3c..0000000 --- a/src/containers/index.js +++ /dev/null @@ -1,10 +0,0 @@ -export AppContainer from '@/containers/AppContainer'; -export GalleryContainer, { - GalleryContainerWithoutStore -} from '@/containers/GalleryContainer'; -export IllustContainer, { - IllustContainerWithoutStore -} from '@/containers/IllustContainer'; -export LoginContainer from '@/containers/LoginContainer'; -export NotFoundContainer from '@/containers/NotFoundContainer'; -export RedirectContainer from '@/containers/RedirectContainer'; diff --git a/src/index.js b/src/index.js index b5a3574..a877f2d 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,7 @@ import { configureStore } from '@/stores'; import AppContainer from '@/containers/AppContainer'; import { IntlProvider } from 'react-intl'; -import { chooseLocale } from '@/locale'; +import chooseLocale from '@/locale/chooseLocale'; const lang = chooseLocale(navigator.language); diff --git a/src/locale/index.js b/src/locale/index.js deleted file mode 100644 index 41ff66c..0000000 --- a/src/locale/index.js +++ /dev/null @@ -1 +0,0 @@ -export chooseLocale from '@/locale/chooseLocale'; diff --git a/src/reducers/gallery.js b/src/reducers/gallery.js index 217cb72..45c7e67 100644 --- a/src/reducers/gallery.js +++ b/src/reducers/gallery.js @@ -1,4 +1,4 @@ -import { GalleryActions } from '@/actions'; +import * as GalleryActions from '@/actions/gallery'; const types = GalleryActions.types; diff --git a/src/reducers/illust.js b/src/reducers/illust.js index c228a81..30bde94 100644 --- a/src/reducers/illust.js +++ b/src/reducers/illust.js @@ -1,4 +1,4 @@ -import { IllustActions } from '@/actions'; +import * as IllustActions from '@/actions/illust'; const types = IllustActions.types; diff --git a/src/utils/cachedFetch.js b/src/utils/cachedFetch.js index 3333e15..68a9400 100644 --- a/src/utils/cachedFetch.js +++ b/src/utils/cachedFetch.js @@ -1,5 +1,7 @@ // modify from https://www.sitepoint.com/cache-fetched-ajax-requests/ -import { hashStr, moment, Storage } from '@/utils'; +import hashStr from '@/utils/hashStr'; +import moment from '@/utils/moment'; +import Storage from '@/utils/Storage'; function buildURL(url, params) { if (!params) { diff --git a/src/utils/getImagesFromZip.js b/src/utils/getImagesFromZip.js index c8a46bd..93d0957 100644 --- a/src/utils/getImagesFromZip.js +++ b/src/utils/getImagesFromZip.js @@ -1,5 +1,5 @@ import JSZip from 'jszip'; -import { cachedFetch } from '@/utils'; +import cachedFetch from '@/utils/cachedFetch'; export default function getImagesFromZip(zipURL) { return new Promise(resolve => { diff --git a/src/utils/index.js b/src/utils/index.js deleted file mode 100644 index 478ab43..0000000 --- a/src/utils/index.js +++ /dev/null @@ -1,9 +0,0 @@ -export cachedFetch from '@/utils/cachedFetch'; -export hashStr from '@/utils/hashStr'; -export EmojiParser from '@/utils/EmojiParser'; -export getImagesFromZip from '@/utils/getImagesFromZip'; -export moment from '@/utils/moment'; -export Piwik from '@/utils/Piwik'; -export scrollTo from '@/utils/scrollTo'; -export Storage from '@/utils/Storage'; -export withRef from '@/utils/withRef'; diff --git a/test/actions/galleryTest.js b/test/actions/galleryTest.js index e9f8f36..78fdcfc 100644 --- a/test/actions/galleryTest.js +++ b/test/actions/galleryTest.js @@ -2,7 +2,7 @@ import nock from 'nock'; import mockStore from '../helpers/mockStoreHelper'; import config from '@/config'; -import { GalleryActions } from '@/actions'; +import * as GalleryActions from '@/actions/gallery'; describe('GalleryActions', () => { afterEach(() => { @@ -10,7 +10,9 @@ describe('GalleryActions', () => { }); it('fire SET_FETCH_ERROR when fetching sources has been done', done => { - nock(config.baseURL).get(`${config.galleryURI}?tag=nico`).reply(200); + nock(config.baseURL) + .get(`${config.galleryURI}?tag=nico`) + .reply(200); const expectedActions = [ { diff --git a/test/utils/EmojiParserTest.js b/test/utils/EmojiParserTest.js index 447b7be..6badba9 100644 --- a/test/utils/EmojiParserTest.js +++ b/test/utils/EmojiParserTest.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { EmojiParser } from '@/utils'; +import EmojiParser from '@/utils/EmojiParser'; describe('EmojiParser', () => { it('should parse out with a ', () => { diff --git a/test/utils/StorageTest.js b/test/utils/StorageTest.js index 747032a..b0b586a 100644 --- a/test/utils/StorageTest.js +++ b/test/utils/StorageTest.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { Storage } from '@/utils'; +import Storage from '@/utils/Storage'; describe('Storage', () => { it('set and get storage should work', () => { diff --git a/test/utils/cachedFetchTest.js b/test/utils/cachedFetchTest.js index 79621c6..7f7d169 100644 --- a/test/utils/cachedFetchTest.js +++ b/test/utils/cachedFetchTest.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import fetchMock from 'fetch-mock'; -import { cachedFetch } from '@/utils'; +import cachedFetch from '@/utils/cachedFetch'; describe('cachedFetch', () => { afterEach(() => { diff --git a/test/utils/hashStrTest.js b/test/utils/hashStrTest.js index a651af9..a69ce0a 100644 --- a/test/utils/hashStrTest.js +++ b/test/utils/hashStrTest.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { hashStr } from '@/utils'; +import hashStr from '@/utils/hashStr'; describe('hashStr', () => { it('hashStr of `kotori` should be -1125571242', () => { diff --git a/test/utils/momentTest.js b/test/utils/momentTest.js index e43d27f..e27ea02 100644 --- a/test/utils/momentTest.js +++ b/test/utils/momentTest.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { moment } from '@/utils'; +import moment from '@/utils/moment'; describe('moment', () => { it('convert YYYY-MM-DD H:i:s to JST', () => {