npm install - install dependencies
npm run start:dev - start the server + frontend project in dev mode
npm run start
- Starting the frontend proj with webpack dev-servernpm run start:vite
- Starting the frontend proj with vitenpm run start:dev
- Starting the frontend proj with dev server + backend (json-server)npm run start:dev:vite
- Starting the frontend proj with vite + backendnpm run start:dev:server
- Starting 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 eslintnpm run lint:ts:fix
- Fixing eslint errors in ts filesnpm run lint:scss
- Checking scss files with style-lintnpm run lint:scss:fix
- Fixing style-lint errors in scss filesnpm run test:unit
- Starting unit tests with jestnpm run test:ui
- Starting visual regression tests with lokinpm run test:ui:ok
- Approving of new snapshotsnpm run test:ui:ci
- Starting visual regression tests in CInpm run test:ui:report
- Generating full report for regression testsnpm run test:ui:json
- Generating json report for regression testsnpm run test:ui:html
- Generating HTML report for regression testsnpm run storybook
- Starting StoryBooknpm run storybook:build
- Building storybooknpm run prepare
- Pre-commit hooksnpm run generate:slice
- Generating a fsd slice
The project is written in conformity with Feature Slice Design methodology
The project utilizes i18next library for working with translations. Files with translations are in public/locales.
Installing a relevant plugin for your IDE is recommended for comfortable working process
4 types of tests are used in the project:
- Common unit tests with jest -
npm run test:unit
- Test for UI components with React Testing Library -
npm run test:unit
- Visual regression testing with loki
npm run test:ui
- e2e testing with Cypress
npm run test:e2e
More on testing - testing docs.
As for styleguide validation, ESLint is used for TypeScript files and StyleLint for checking of CSS files.
Besides, for the purpose of stricter control on abidance by architectural principles, custom eslint plugin is used (eslint-plugin-fsd-arch-validator), which has 3 following rules:
- relative-imports-within-module - prohibits usage of absolute imports within a single module
- layer-imports - validates layers usage from the FSD perspective (e.g. widgets may not be used within features и entities)
- import-from-public-api - ensures imports from other modules are only through public api
npm run lint:ts
- Checking ts files with eslintnpm run lint:ts:fix
- Fixing ts files with eslintnpm run lint:scss
- Checking scss files with stylelintnpm run lint:scss:fix
- Fixing scss files with stylelint
Every project component has to have story cases described. Server requests should be mocked with storybook-addon-mock.
File with story cases resides near its component .stories.tsx extension
StoryBook runs with:
npm run storybook
More on Storybook.
Project has 2 configs:
- Webpack - ./config/build
- Vite - vite.config.ts
Both bundlers are adjusted to project main features.
All configuration resides in /config
- /config/babel - babel
- /config/build - webpack config
- /config/jest - test environment config
- /config/storybook - storybook config
scripts
folder is meant for various scripts for refactoring/alleviation of code-writing/reports generation etc.
GitHub actions config is in /.github/workflows. CI runs all types of tests, linters, builds the project and storybook
Pre-commit hooks validates staged files with linters, config is in /.husky
Interaction with data is done with redux toolkit. When possible, reused entities should be normalized with EntityAdapter
Server requests are sent with RTK query
To connect reducers asynchronously (to not include them in main bundle) DynamicModuleLoader is used
Using feature-flags is done only with "toggleFeature" helper function.
It accepts config object with following properties:
- name: string - name of the feature
- on: function - function called after feature is turned on
- off: function - function called after feature is turned off
For automatic feature removal, use "remove-feature.ts" script, that takes following arguments:
- Name of the feature-flag to remove
- State to leave after removal (on/off)