Skip to content

Commit

Permalink
feat: add eslint-plugin-import for ordering imports
Browse files Browse the repository at this point in the history
  • Loading branch information
sashtje committed Sep 27, 2023
1 parent d33bffb commit d546891
Show file tree
Hide file tree
Showing 32 changed files with 128 additions and 57 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
'react-hooks',
'eslint-plugin-fsd-checker',
'eslint-plugin-unused-imports',
'eslint-plugin-import',
],
rules: {
indent: [2, 2],
Expand Down Expand Up @@ -70,6 +71,17 @@ module.exports = {
ignoreImport: ['**/StoreProvider', '**/testing'],
}],
'unused-imports/no-unused-imports': 'error',
'import/order': ['error', {
groups: ['builtin', 'external', 'internal'],
pathGroups: [
{
pattern: '@/**',
group: 'external',
position: 'after',
},
],
'newlines-between': 'always',
}],
},
globals: {
__IS_DEV__: true,
Expand Down
1 change: 1 addition & 0 deletions config/build/buildResolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ResolveOptions } from 'webpack';

import { BuildOptions } from './types/config';

export function buildResolvers(options: BuildOptions): ResolveOptions {
Expand Down
3 changes: 2 additions & 1 deletion config/storybook/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import webpack, { DefinePlugin, RuleSetRule } from 'webpack';
import path from 'path';

import webpack, { DefinePlugin, RuleSetRule } from 'webpack';

import { BuildPaths } from '../build/types/config';
import { buildCssLoader } from '../build/loaders/buildCssLoader';

Expand Down
106 changes: 83 additions & 23 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"eslint": "^8.10.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-i18next": "^5.1.2",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-react": "^7.29.2",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-unused-imports": "^2.0.0",
Expand Down
3 changes: 2 additions & 1 deletion scripts/refactoring/createPublicApiForSharedUI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Project } from 'ts-morph';
import path from 'path';

import { Project } from 'ts-morph';

const project = new Project({});

project.addSourceFilesAtPaths('src/**/*.ts');
Expand Down
1 change: 0 additions & 1 deletion src/app/providers/router/config/routerConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ArticleEditPage } from '@/pages/ArticleEditPage';
import { AdminPanelPage } from '@/pages/AdminPanelPage';
import { ForbiddenPage } from '@/pages/ForbiddenPage';
import { UserRole } from '@/entities/User';

import { AppRoutes, RoutePath } from '@/shared/const/router';

import { AppRoutesProps } from './types';
Expand Down
1 change: 0 additions & 1 deletion src/app/providers/router/ui/RequireAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useSelector } from 'react-redux';
import { Navigate, useLocation } from 'react-router-dom';

import { getUserAuthData, getUserRoles, UserRole } from '@/entities/User';

import { AppRoutes, RoutePath } from '@/shared/const/router';

interface RequireAuthProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { Button } from '@/shared/ui/Button';
import { Icon } from '@/shared/ui/Icon';
import EyeIcon from '@/shared/assets/icons/eye-20-20.svg';
import { AppLink } from '@/shared/ui/AppLink';
import { RoutePath } from '@/shared/const/router';

import { ArticleBlockType, ArticleView } from '../../model/consts/consts';
import {
Article, ArticleTextBlock,
} from '../../model/types/article';
import cls from './ArticleListItem.module.scss';
import { ArticleTextBlockComponent } from '../../ui/ArticleTextBlockComponent/ArticleTextBlockComponent';
import { RoutePath } from '@/shared/const/router';

interface ArticleListItemProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Comment/ui/CommentItem/CommentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { Text } from '@/shared/ui/Text';
import { Skeleton } from '@/shared/ui/Skeleton';
import { AppLink } from '@/shared/ui/AppLink';
import { VStack } from '@/shared/ui/Stack';
import { AppRoutes, RoutePath } from '@/shared/const/router';

import cls from './CommentItem.module.scss';
import { Comment } from '../../model/types/comment';
import { AppRoutes, RoutePath } from '@/shared/const/router';

interface CommentItemProps {
className?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ComponentMeta, ComponentStory } from '@storybook/react';

import withMock from 'storybook-addon-mock';
import { NotificationsList } from './NotificationsList';

import { StoreDecorator } from '@/shared/config/storybook/StoreDecorator/StoreDecorator';

import { NotificationsList } from './NotificationsList';

export default {
title: 'entities/Notification/NotificationsList',
component: NotificationsList,
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Profile/ui/ProfileCard/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Avatar } from '@/shared/ui/Avatar';
import { Currency, CurrencySelect } from '@/entities/Currency';
import { Country, CountrySelect } from '@/entities/Country';
import { HStack, VStack } from '@/shared/ui/Stack';
import { AppRoutes } from '@/shared/const/router';

import { Profile } from '../../model/types/profile';
import cls from './ProfileCard.module.scss';
import { AppRoutes } from '@/shared/const/router';

interface ProfileCardProps {
className?: string;
Expand Down
1 change: 1 addition & 0 deletions src/entities/User/model/slice/userSlice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';

import { USER_LOCALSTORAGE_KEY } from '@/shared/const/localStorage';

import { User, UserSchema } from '../types/user';

const initialState: UserSchema = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ComponentMeta, ComponentStory } from '@storybook/react';
import withMock from 'storybook-addon-mock';

import { ArticleRating } from './ArticleRating';
import { StoreDecorator } from '@/shared/config/storybook/StoreDecorator/StoreDecorator';

import { ArticleRating } from './ArticleRating';

export default {
title: 'features/ArticleRating',
component: ArticleRating,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StateSchema } from '@/app/providers/StoreProvider';

import { getLoginError } from './getLoginError';

describe('getLoginError.test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StateSchema } from '@/app/providers/StoreProvider';

import { getLoginIsLoading } from './getLoginIsLoading';

describe('getLoginIsLoading.test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StateSchema } from '@/app/providers/StoreProvider';

import { getLoginPassword } from './getLoginPassword';

describe('getLoginPassword.test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StateSchema } from '@/app/providers/StoreProvider';

import { getLoginUsername } from './getLoginUsername';

describe('getLoginUsername.test', () => {
Expand Down
7 changes: 2 additions & 5 deletions src/features/authByUsername/ui/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import { classNames } from '@/shared/lib/classNames';
import { Button } from '@/shared/ui';
import { Input } from '@/shared/ui/Input';
import { ButtonTheme } from '@/shared/ui/Button';
import { Button, ButtonTheme } from '@/shared/ui/Button';
import { Text, TextTheme } from '@/shared/ui/Text';

import {
DynamicModuleLoader, ReducersList,
} from '@/shared/lib/components/DynamicModuleLoader/DynamicModuleLoader';
import { useAppDispatch } from '@/shared/lib/hooks/useAppDispatch/useAppDispatch';

import { getLoginUsername } from '../../model/selectors/getLoginUsername/getLoginUsername';
import { getLoginPassword } from '../../model/selectors/getLoginPassword/getLoginPassword';
import { getLoginIsLoading } from '../../model/selectors/getLoginIsLoading/getLoginIsLoading';
import { getLoginError } from '../../model/selectors/getLoginError/getLoginError';

import { loginByUsername } from '../../model/services/loginByUsername/loginByUsername';
import { loginActions, loginReducer } from '../../model/slices/loginSlice';

import cls from './LoginForm.module.scss';

export interface LoginFormProps {
Expand Down
Loading

0 comments on commit d546891

Please sign in to comment.