Skip to content

Commit

Permalink
feat: add linter for public api imports, fix project imports
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Mar 9, 2024
1 parent 2fe1578 commit 8f10b89
Show file tree
Hide file tree
Showing 39 changed files with 38 additions and 75 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
'no-unused-vars': 'warn',
'react/require-default-props': 'off',
'react/react-in-jsx-scope': 'off',
'react/jsx-props-no-spreading': 'warn',
'react/jsx-props-no-spreading': 'off',
'react/function-component-definition': 'off',
'no-shadow': 'off',
'import/extensions': 'off',
Expand All @@ -53,6 +53,7 @@ module.exports = {
'react/no-array-index-key': 'off',
'react/jsx-no-useless-fragment': 'off',
'paths-fixes/path-checker': ['error', { alias: '@' }],
'paths-fixes/public-api-imports': ['error', { alias: '@' }],
},
globals: {
__IS_DEV__: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"eslint-plugin-i18next": "^5.1.2",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-paths-fixes": "^0.0.2",
"eslint-plugin-paths-fixes": "^0.0.3",
"eslint-plugin-react": "^7.29.2",
"eslint-plugin-react-hooks": "^4.3.0",
"file-loader": "^6.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/app/providers/StoreProvider/config/StateSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { UserSchema } from '@/entities/User';
import { LoginSchema } from '@/features/AuthByUsername';
import { AddCommentFormSchema } from '@/features/addCommentForm';
import { ArticlesPageSchema } from '@/pages/ArticlesPage';
import { ScrollRestorationSchema } from '@/features/scrollRestoration/model/types/scrollRestorationSchema';
import { ArticleDetailsPageSchema } from '@/pages/ArticlesDetailsPage/model/types';
import { ScrollRestorationSchema } from '@/features/scrollRestoration';
import { ArticleDetailsPageSchema } from '@/pages/ArticlesDetailsPage';
import { rtkApi } from '@/shared/api/rtkApi';
import { ProfileSchema } from '@/features/editableProfileCard';
import { ArticleDetailsSchema } from '../../../../entities/Article';
Expand Down
2 changes: 1 addition & 1 deletion src/app/providers/router/ui/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
AppRoutesProps,
routeConfig,
} from '@/shared/config/routeConfig/routeConfig';
import { PageLoader } from '@/shared/ui/PageLoader/PageLoader';
import { RequireAuth } from '@/app/providers/router/ui/RequireAuth';
import { PageLoader } from '@/widgets/PageLoader';

const AppRouter = () => {
const renderWithWrapper = useCallback((route: AppRoutesProps) => {
Expand Down
6 changes: 3 additions & 3 deletions src/entities/Article/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export { ArticleList } from './ui/ArticleList/ArticleList';
export { ArticleSortSelector } from './ui/ArticleSortSelector/ArticleSortSelector';

export type { Article } from './model/types/article';
export { ArticleSortField } from './model/consts/consts';
export { ArticleType } from './model/consts/consts';
export { ArticleView } from './model/consts/consts';
export {
ArticleType, ArticleView, ArticleBlockType, ArticleSortField,
} from './model/consts/consts';
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createAsyncThunk } from '@reduxjs/toolkit';
import { ThunkConfig } from '@/app/providers/StoreProvider';
import { Page } from '@/widgets/Page/Page';
import { Article } from '../../types/article';

export const fetchArticleById = createAsyncThunk<
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Comment/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { CommentList } from './ui/CommentList/CommentList';
export { CommentCard } from './ui/CommentCard/CommentCard';
export type { Comment } from './types/comment';
export type { Comment } from '@/entities/Comment/model/types/comment';
File renamed without changes.
2 changes: 1 addition & 1 deletion src/entities/Comment/ui/CommentCard/CommentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppLink } from '@/shared/ui/AppLink/AppLink';
import { RoutePath } from '@/shared/config/routeConfig/routeConfig';
import { VStack } from '@/shared/ui/Stack';
import cls from './CommentCard.module.scss';
import { Comment } from '../../types/comment';
import { Comment } from '../../model/types/comment';
import { Avatar } from '../../../../shared/ui/Avatar/Avatar';
import { Text } from '../../../../shared/ui/Text/Text';
import { Skeleton } from '../../../../shared/ui/Skeleton/Skeleton';
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Comment/ui/CommentList/CommentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { classNames } from '@/shared/lib/classNames/classNames';
import { VStack } from '@/shared/ui/Stack';
import { Text } from '../../../../shared/ui/Text/Text';
import { CommentCard } from '../CommentCard/CommentCard';
import { Comment } from '../../types/comment';
import { Comment } from '../../model/types/comment';

interface CommentListProps {
className?: string;
Expand Down
1 change: 1 addition & 0 deletions src/entities/Notification/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { NotificationList } from './ui/NotificationList/NotificationList';
export type { Notification } from './model/types/notification';
2 changes: 1 addition & 1 deletion src/entities/Profile/model/types/profile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Currency } from '@/entities/Currency/model/types/currency';
import { Currency } from '@/entities/Currency';
import { Country } from '@/entities/Country';

export interface Profile {
Expand Down
2 changes: 1 addition & 1 deletion src/features/AuthByUsername/ui/LoginModal/LoginModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Suspense } from 'react';
import { Modal } from '@/shared/ui/Modal/Modal';
import { PageLoader } from '@/shared/ui/PageLoader/PageLoader';
import { LoginFormAsync } from '../LoginForm/LoginForm.async';
import { PageLoader } from '@/widgets/PageLoader';

interface LoginModalProps {
className?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { ComponentMeta, ComponentStory } from '@storybook/react';

import { StoreDecorator } from '@/shared/config/storybook/StoreDecorator/StoreDecorator';
import { Notification } from '@/entities/Notification/model/types/notification';
import { Notification } from '@/entities/Notification';
import { NotificationButton } from './NotificationButton';

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/features/scrollRestoration/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type { ScrollSchema } from './model/types/scrollRestorationSchema';
export type { ScrollSchema, ScrollRestorationSchema } from './model/types/scrollRestorationSchema';
export { getScrollRestorationByPath } from './model/selectors/getscrollRestoration/getScrollRestoration';
export { scrollRestorationReducer, scrollRestorationActions } from './model/slices/scrollRestorationSlice';
2 changes: 1 addition & 1 deletion src/pages/AdminPanelPage/ui/AdminPanelPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Page } from '@/widgets/Page/Page';
import { Page } from '@/widgets/Page';

const AdminPanelPage = memo((props: any) => {
const { t } = useTranslation('');
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ArticleEditPage/ui/ArticleEditPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { memo } from 'react';
import { useParams } from 'react-router-dom';
import { classNames } from '@/shared/lib/classNames/classNames';
import { Page } from '@/widgets/Page/Page';
import { Page } from '@/widgets/Page';

interface ArticleEditPageProps {
className?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntityState } from '@reduxjs/toolkit';
import { Comment } from '@/entities/Comment/types/comment';
import { Comment } from '@/entities/Comment';

export interface ArticleDetailsCommentsSchema extends EntityState<Comment> {
isLoading?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
DynamicModuleLoader,
ReducersList,
} from '@/shared/lib/components/DynamicModuleLoared/DynamicModuleLoared';
import { Page } from '@/widgets/Page/Page';
import { VStack } from '@/shared/ui/Stack';
import { ArticleRecommendationsList } from '@/features/articleRecommendationsList';
import { ArticleDetailsComments } from '../../ui/ArticleDetailsComments/ArticleDetailsComments';
Expand All @@ -13,6 +12,7 @@ import { ArticlesDetailsPageHeader } from '../../ui/ArticlesDetailsPageHeader/Ar
import { articleDetailsPageReducer } from '../../model/slices';
import { ArticleDetails } from '../../../../entities/Article';
import { ArticleRating } from '@/features/articleRating';
import { Page } from '@/widgets/Page';

const reducers: ReducersList = {
articleDetailsPage: articleDetailsPageReducer,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ArticlesPage/ui/ArticlesPage/ArticlesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
} from '@/shared/lib/components/DynamicModuleLoared/DynamicModuleLoared';
import { useInitialEffect } from '@/shared/lib/hook/useInitialEffect/useInitialEffect';
import { useAppDispatch } from '@/shared/lib/hook/useAppDispatch/useAppDispatch';
import { Page } from '@/widgets/Page/Page';
import { ArticleInfiniteList } from '../../ui/ArticleInfiniteList/ArticleInfiniteList';
import { ArticlesPageFilters } from '../../ui/ArticlesPageFilters/ArticlesPageFilters';
import { fetchNextArticlePage } from '../../model/services/fetchNextArticlePage/fetchNextArticlePage';
import { initArticlesPage } from '../../model/services/initArticlesPage/initArticlesPage';
import { articlesPageReducer } from '../../model/slices/articlesPageSlice';
import cls from './ArticlesPage.module.scss';
import { Page } from '@/widgets/Page';

interface ArticlesPageProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ForbiddenPage/ui/ForbiddenPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Page } from '@/widgets/Page/Page';
import { Page } from '@/widgets/Page';

const ForbiddenPage = memo((props: any) => {
const { t } = useTranslation('');
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProfilePage/ui/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { memo } from 'react';
import { useParams } from 'react-router-dom';
import { classNames } from '@/shared/lib/classNames/classNames';
import { Page } from '@/widgets/Page/Page';
import { VStack } from '@/shared/ui/Stack/VStack/VStack';
import { EditableProfileCard } from '@/features/editableProfileCard';
import { Page } from '@/widgets/Page';

interface ProfilePageProps {
className?: string;
Expand Down
4 changes: 4 additions & 0 deletions src/shared/config/storybook/StoreDecorator/StoreDecorator.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Story } from '@storybook/react';
import { StateSchema, StoreProvider } from '@/app/providers/StoreProvider';
import { loginReducer } from '@/features/AuthByUsername';
// TODO
import { ReducersList } from '@/shared/lib/components/DynamicModuleLoared/DynamicModuleLoared';
// eslint-disable-next-line paths-fixes/public-api-imports
import { addCommentFormReducer } from '@/features/addCommentForm/model/slices/addCommentFormSlice';
// eslint-disable-next-line paths-fixes/public-api-imports
import { articleDetailsPageReducer } from '@/pages/ArticlesDetailsPage/model/slices';
// eslint-disable-next-line paths-fixes/public-api-imports
import { profileReducer } from '@/features/editableProfileCard/model/slice/profileSlice';
import { articleDetailsReducer } from '../../../../entities/Article';

Expand Down
7 changes: 0 additions & 7 deletions src/shared/ui/PageLoader/PageLoader.module.scss

This file was deleted.

13 changes: 0 additions & 13 deletions src/shared/ui/PageLoader/PageLoader.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/widgets/LangSwitcher/LangSwitcher.tsx

This file was deleted.

1 change: 1 addition & 0 deletions src/widgets/LangSwitcher/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { LangSwitcher } from './ui/LangSwitcher/LangSwitcher';
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useTranslation } from 'react-i18next';
import React, { memo } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import { Button, ButtonTheme } from '../Button/Button';
import { Button, ButtonTheme } from '@/shared/ui/Button/Button';

interface LangSwitcherProps {
className?: string;
short?: boolean;
className?: string;
short?: boolean;
}

export const LangSwitcher = memo(({ className, short }: LangSwitcherProps) => {
Expand All @@ -21,7 +21,7 @@ export const LangSwitcher = memo(({ className, short }: LangSwitcherProps) => {
theme={ButtonTheme.CLEAR}
onClick={toggle}
>
{t(short ? 'Короткий язык' : 'Язык')}
{t(short ? 'EN' : 'English')}
</Button>
);
});
1 change: 1 addition & 0 deletions src/widgets/Page/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Page, PAGE_ID } from './ui/Page/Page';
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/widgets/PageError/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PageError } from './ui/PageError/PageError';
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/widgets/PageLoader/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PageLoader } from './ui/PageLoader/PageLoader';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PageLoader {
min-height: calc(100vh - var(--navbar-height));
display: flex;
align-items: center;
justify-content: center;
align-items: center;
flex-grow: 1;
}
File renamed without changes.
2 changes: 1 addition & 1 deletion src/widgets/Sidebar/ui/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { memo, useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
import { classNames } from '@/shared/lib/classNames/classNames';
import { ThemeSwitcher } from '@/shared/ui/ThemeSwitcher';
import { LangSwitcher } from '@/shared/ui/LangSwitcher/LangSwitcher';
import { Button, ButtonSize, ButtonTheme } from '@/shared/ui/Button/Button';
import { VStack } from '@/shared/ui/Stack/VStack/VStack';
import { getSidebarItems } from '../../model/selectors/getSidebarItems';
import { SidebarItem } from '../SidebarItem/SidebarItem';
import cls from './Sidebar.module.scss';
import { LangSwitcher } from '@/widgets/LangSwitcher';

interface SidebarProps {
className?: string;
Expand Down

0 comments on commit 8f10b89

Please sign in to comment.