npm install - install deps
npm run start:dev or npm run start:dev:vite - server start + frontend project in dev mode
login admin; password: 123
login user; password: 123
login testuser; password: 123
npm run start
- Launch the frontend project on webpack dev servernpm run start:vite
- Launch the frontend project on vitenpm run start:dev
- Launch the frontend project on webpack dev server + backendnpm run start:dev:vite
- Launch the frontend project on vite + backendnpm run start:dev:server
- Launch the backend servernpm run build:prod
- Build in prod modenpm run build:dev
- Build in dev mode (not minimized)npm run lint:ts
- Check ts files with linternpm run lint:ts:fix
- Fix ts files with linternpm run lint:scss
- Check scss files with style linternpm run lint:scss:fix
- Fix scss files with style linternpm run test:unit
- Run unit tests with jestnpm run test:ui
- Run screenshot tests with lokinpm run test:ui:ok
- Confirm new screenshotsnpm run test:ui:ci
- Run screenshot tests in CInpm run test:ui:report
- Generate a full report for screenshot testsnpm run test:ui:json
- Generate a JSON report for screenshot testsnpm run test:ui:html
- Generate an HTML report for screenshot testsnpm run storybook
- Run Storybooknpm run storybook:build
- Build Storybooknpm run prepare
- Pre-commit hooksnpm run generate:slice
-Script for generating FSD slices
The project is written according to the Feature Sliced Design methodology
Link to the documentation - feature sliced design
The project uses the i18next library for working with translations. Translation files are stored in public/locales.
For comfortable work, it is recommended to install a plugin for webstorm/vscode
documentation i18next - https://react.i18next.com/
Project uses 4 types of tests:
- Regular unit tests with jest -
npm run test:unit
- Component tests with React Testing Library -
npm run test:unit
- Screenshot testing with loki
npm run test:ui
- End-to-end testing with Cypress
npm run test:e2e
More about tests- документация тестирование
The project uses eslint to check TypeScript code and stylelint to check style files.
Also, for strict control of major architectural principles, a custom eslint plugin eslint-plugin-ulbi-tv-plugin is used, which contains 3 rules
- path-checker - prohibits the use of absolute imports within the same module
- layer-imports - checks the correctness of using layers from the FSD perspective (for example, widgets cannot be used in features and entities)
- public-api-imports - allows importing from other modules only from the public API. Has auto fix
npm run lint:ts
- Check ts files with linternpm run lint:ts:fix
- Fix ts files with linternpm run lint:scss
- Check scss files with style linternpm run lint:scss:fix
- Fix scss files with style linter
For each component in the project, story cases are described. Server requests are mocked using storybook-addon-mock.
The file with story cases is created next to the component with the extension .stories.tsx
You can run Storybook with the command:
npm run storybook
More abou Storybook
Example:
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { ThemeDecorator } from '@/shared/config/storybook/ThemeDecorator/ThemeDecorator';
import { Button, ButtonSize, ButtonTheme } from './Button';
import { Theme } from '@/shared/const/theme';
export default {
title: 'shared/Button',
component: Button,
argTypes: {
backgroundColor: { control: 'color' },
},
} as ComponentMeta<typeof Button>;
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
export const Primary = Template.bind({});
Primary.args = {
children: 'Text',
};
export const Clear = Template.bind({});
Clear.args = {
children: 'Text',
theme: ButtonTheme.CLEAR,
};
For development, the project contains 2 configs:
- Webpack - ./config/build
- vite - vite.config.ts
Both builders are adapted for the main features of the application.
All configuration is stored in /config
- /config/babel - babel
- /config/build - webpack configuration
- /config/jest - test environment configuration
- /config/storybook - Storybook configuration
Various scripts
for refactoring, simplifying code writing, generating reports, etc. are located in the scripts folder.
The GitHub Actions configuration is located in /.github/workflows. In CI, all types of tests, project and Storybook builds, linting are run.
In pre-commit hooks, the project is checked with linters, the config is in /.husky
Data interaction is done using Redux Toolkit. Reusable entities should be normalized using EntityAdapter whenever possible.
Server requests are sent using RTK query
For asynchronous connection of reducers (to avoid pulling them into the main bundle), [DynamicModuleLoader] is used (/src/shared/lib/components/DynamicModuleLoader/DynamicModuleLoader.tsx)
The use of feature flags is allowed only with the toggleFeatures helper
an object with options is passed to it
{ name: feature flag name, on: function that will run after enabling the feature of: function that will run after disabling the feature }
To automatically remove a feature, use the remove-feature.ts script, which takes 2 arguments
- Name of the feature flag to be removed
- State (on\off)