npm install - install the dependencies
npm run start:dev or npm run start:dev:vitt - launch the server + frontend of the project in dev mode
npm run start
- Launch frontend project on webpack dev servernpm run start:vite
- Launching a 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
- Start the backend servernpm run build:prod
- Build in prod modenpm run build:dev
- Build in dev mode (not minimized)npm run lint:ts
- Checking ts files with linternpm run lint:ts:fix
- Fix ts files with linternpm run lint:scss
- Checking scss files with a linternpm run lint:scss:fix
- Fixing scss files with a style linternpm run test:unit
- Running unit tests with jestnpm run test:ui
- Running screenshot tests with lokinpm run test:ui:ok
- Confirmation of new screenshotsnpm run test:ui:ci
- Running screenshot tests in CInpm run test:ui:report
- Generating a complete report for screenshot testsnpm run test:ui:json
- Generation of a json report for screenshot testsnpm run test:ui:html
- Generating HTML report for screenshot testsnpm run storybook
- launch Storybooknpm run storybook:build
- Building a 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 the documentation - feature sliced design
The project uses the i18next library to work with translations. Files with translations are stored in public/locales.
For comfortable work, we recommend installing the plugin for webstorm/vscode
i18next documentation - https://react.i18next.com /
The project uses 4 types of tests:
- Regular unit tests for just -
npm run test:unit
- Component tests with React testing library -
mpm run test:unit
- Screenshot testing with loki
npm run test:ui
- e2e testing with Cypress
npm run test:e2e
Learn more about tests - testing documentation
The project uses eslint to check typescript code and styleline to check files with styles.
Also, for strict control of the main architectural principles , the proprietary eslint plugin eclipse-plugin-multi-tv-plugin is used, which contains 3 rules
- path-checker - prohibits the use of absolute imports within a single module
- layer-imports - checks the correctness of using layers from the FSD point of view ((for example, widgets cannot be used in features and entities)
- public-api-imports - allows imports from other modules only from the public api. It has an auto fix
npm run lint:ts
- Checking ts files with a linternpm run lint:ts:fix
- Correction of ts files by linternpm run lint:scss
- Checking css files with a style linternpm run lint:scss:fix
- Fix css files with style linter
The project describes story cases for each component. Requests to the server are mocked using storybook-addon-mock.
The storycase file is created next to the component with the .stories.tsx extension
You can run storybrooke with the command:
npm run storybook
Learn 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 collectors are adapted to the main features of the application.
The entire configuration is stored in /config
- /config/babel - babel
- /config/build - webpack configuration
- /config/jest - configuration of the test environment
- /config/storybook - storybook configuration
The scripts
folder contains various scripts for refactoring\simplifying code writing\generating reports, etc.
The github actions configuration is located in /.github/workflows. ci runs all kinds of tests, builds the project and Storybook, linting.
In the pre-commit hooks, we check the project with linters, config in /.husky
Interaction with these users is carried out using a set of redux toolkit. Opportunities reused opportunities do not necessarily need to be normalized using EntityAdapter
Try to find the answer using RTK query
To asynchronously connect the editors (so as not to pull them into a common bundle), use [Dynamicmoduleloader
It is allowed to use feature flags only with the help of the toggleFeatures helper
an object with options is passed to it
{ name: name of the flag feature, on: function that will work after the feature is turned on of: function that will work after the feature is turned off }
To automatically remove a feature, use the remove-feature.ts script, which takes 2 arguments
- The name of the flag feature to be deleted
- Status (on\off)