npm install - packages installing
npm run start:dev or npm run start:dev:vite - starting dev server, frontend + backend, by using webpack or vite
npm run start
- starting frontend dev server on webpacknpm run start:vite
- starting frontend dev server on vitenpm run start:dev
- starting frontend dev server on webpack + backendnpm run start:dev:vite
- starting frontend dev server on vite + backendnpm run start:dev:server
- starting backend servernpm run build:prod
- building project in prod confignpm run build:dev
- building project in dev config (not minified)npm run lint:ts
- linting ts,tsx filesnpm run lint:ts:fix
- fix code style for ts,tsx filesnpm run lint:scss
- linting scss filesnpm run lint:scss:fix
- fix code style for scss filesnpm run test:unit
- star unit testing with jestnpm run test:ui
- star screenshot testing with lokinpm run test:ui:ok
- approving new screenshots from lokinpm run test:ui:ci
- star screenshot testing with loki in cinpm run test:ui:report
- generating full report for screenshot testsnpm run test:ui:json
- generating json report for screenshot testsnpm run test:ui:html
- generating html report for screenshot testsnpm run storybook
- start storybooknpm run storybook:build
- build storybooknpm run generate:slice
- generate slice template
The project was written in accordance with the Feature sliced design methodology
Link to documentation - feature sliced design
The project uses the i18next library to work with translations. Translation files 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 jest -
npm run test:unit
- Tests for components 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 information about tests - testing documentation
The project uses eslint to check typescript code and stylelint to check style files.
Also for strict control of the main architectural principles uses its own eslint plugin eslint-plugin-ulbi-tv-plugin, which contains 3 rules
- path-checker - prohibits the use of absolute imports within one module
- layer-imports - checks the correct use of layers from the point of view of FSD (for example widgets cannot be used in features and entitites)
- public-api-imports - allows imports from other modules only from public api. Has auto fix
npm run lint:ts
- Checking ts files with a linternpm run lint:ts:fix
- Fixing ts files with a linternpm run lint:scss
- Checking scss style files with a linternpm run lint:scss:fix
- Fixing scss style files with a linter
The project describes story cases for each component. Requests to the server are mocked using storybook-addon-mock.
A file with story cases is created next to the component with the extension .stories.tsx
You can start the 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/variant';
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.
All configuration is stored in /config
- /config/babel - babel
- /config/build - webpack configuration
- /config/jest - test environment configuration
- /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. All types of tests, project and storybook assembly, and linting are run in ci.
Interaction with data is carried out using the redux toolkit. If possible, reused entities should be normalized using EntityAdapter
Requests to the server are sent using RTK query
For asynchronous connection of reducers (so as not to pull them into a common bundle) it is used DynamicModuleLoader
Allow the use of feature flags only using the toggleFeatures helper
an object with options is passed into it
{ name: name of the feature flag, on: function that will work after the feature is enabled of: function that will work after turning off 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)