npm install - install dependencies
npm run start:dev or npm run start:dev:vite - launch server + frontend project in dev mode
npm run start- Launch frontend project on webpack dev servernpm run start:vite- Launch frontend project on vitenpm run start:dev- Launch frontend project on webpack dev server + backendnpm run start:dev:vite- Launch frontend project on vite + backendnpm run start:dev:server- Launch backend servernpm run build:prod- Build in prod modenpm run build:dev- Build in dev mode (not minified)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- Approve new screenshotsnpm run test:ui:ci- Run screenshot tests in CInpm run test:ui:report- Generate full report for screenshot testsnpm run test:ui:json- Generate json report for screenshot testsnpm run test:ui:html- Generate HTML report for screenshot testsnpm run storybook- launch Storybooknpm run storybook:build- Build storybook buildnpm run prepare- precommit hooksnpm run generate:slice- Script for generating FSD slices
The project is written in accordance with the Feature sliced design methodology
Link to documentation - feature sliced design
The project uses the i18next library for working with translations. Translation files are stored in public/locales.
For comfortable work, we recommend installing a plugin for webstorm/vscode
i18next documentation - https://react.i18next.com/
The project uses 4 types of tests:
- Regular unit tests on jest -
npm run test:unit - Component tests with React testing library -
npm run test:unit - Screenshot testing with loki
npm run test:ui - e2e testing with Cypress
npm run test:e2e
More about tests - testing documentation
The project uses eslint for checking typescript code and stylelint for checking style files.
Also, for strict control of the main 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 one module
- layer-imports - checks the correctness of layer usage from the FSD point of view (for example, widgets cannot be used in features and entities)
- public-api-imports - allows import from other modules only from 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
In the project, story cases are described for each component. 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 about 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
In the scripts folder there are various scripts for refactoring\ simplifying code writing\generating reports, etc.
GitHub actions configuration is in /.github/workflows. In ci, all types of tests, project and storybook build, linting are run.
In precommit hooks, we check the project with linters, config in /.husky
Interaction with data is carried out using redux toolkit. Where possible, reusable entities should be normalized using EntityAdapter
Requests to the server are sent using RTK query
For asynchronous connection of reducers (to not pull them into the general bundle) used DynamicModuleLoader
The use of feature flags is allowed only with the toggleFeatures helper
it is passed an object with options
{ name: feature flag name, on: function that will work after Enabling the feature off: function that will work 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)