Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"extends": [
"next",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:storybook/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"root": true,
"rules": {
"prettier/prettier": [
"error",
{
"tabWidth": 2,
"semi": true,
"endOfLine": "auto",
"singleQuote": false,
"trailingComma": "es5"
}
],
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-namespace": "off",
"array-callback-return": "error",
"eqeqeq": "error",
"no-alert": "error",
"no-return-assign": "error",
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.name=watch], MemberExpression[object.name=methods][property.name=watch]",
"message": "\"watch\" re-render the whole form component. Use hook \"useWatch\" instead."
},
{
"selector": "VariableDeclarator > ObjectPattern > Property[key.name=formState]",
"message": "\"formState\" re-render the whole form component. Use hook \"useFormState\" instead."
},
{
"selector": "VariableDeclarator[init.callee.name=useFormState][id.type=Identifier]",
"message": "Use destructuring assignment for \"useFormState\". Example: \"const { isDirty } = useFormState()\". Returned formState is wrapped with Proxy to improve render performance and skip extra computation if specific state is not subscribed, so make sure you deconstruct or read it before render in order to enable the subscription. More info here https://react-hook-form.com/docs/useformstate#rules"
},
{
"selector": "MemberExpression[object.name=control]",
"message": "Do not access any of the properties inside this object directly. It's for internal usage only. More info here: https://react-hook-form.com/docs/useform/control"
},
{
"selector": "VariableDeclaration[declarations.0.init.callee.name=useForm] ~ VariableDeclaration[declarations.0.init.callee.name=useWatch]",
"message": "\"useWatch\" in main form component (which use \"useForm\") will re-render the whole form component. Move your useWatch's logic to separate component."
},
{
"selector": "VariableDeclaration[declarations.0.init.callee.name=useForm] ~ VariableDeclaration[declarations.0.init.callee.name=useFieldArray]",
"message": "\"useFieldArray\" in main form component (which use \"useForm\") will re-render the whole form component. Move your useFieldArray's logic to separate component."
},
{
"selector": "VariableDeclaration[declarations.0.init.callee.name=useForm] ~ VariableDeclaration[declarations.0.init.callee.name=useController]",
"message": "\"useController\" in main form component (which use \"useForm\") will re-render the whole form component. Move your useController's logic to separate component."
},
{
"selector": "VariableDeclaration[declarations.0.init.callee.name=useForm] ~ VariableDeclaration[declarations.0.init.callee.name=useFormContext]",
"message": "\"useFormContext\" in main form component (which use \"useForm\") will re-render the whole form component. Move your useFormContext's logic to separate component."
},
{
"selector": "VariableDeclaration[declarations.0.init.callee.name=useForm] ~ VariableDeclaration[declarations.0.init.callee.name=useFormState]",
"message": "\"useFormState\" in main form component (which use \"useForm\") will re-render the whole form component. Move your useFormState's logic to separate component."
},
{
"selector": "CallExpression[callee.name=useForm][arguments.length=0], CallExpression[callee.name=useForm][arguments.length=1]:not(:has(Property[key.name=defaultValues]))",
"message": "Pass object with \"defaultValues\" for correct \"formState\" behavior. More info here: https://react-hook-form.com/api/useform/formstate#main"
},
{
"selector": "VariableDeclaration[declarations.0.init.callee.name=useState] ~ ReturnStatement JSXIdentifier[name=Controller]",
"message": "Don't use \"Controller\" with \"useState\". Move you \"useState\" and another logic to separate component and wrap this component via Controller. Reason: This approach will rise wrong logic for handle input field. Example: \"src/components/form/text-input/form-text-input.tsx\""
},
{
"selector": "VariableDeclaration[declarations.0.init.callee.name=useState] ~ VariableDeclaration[declarations.0.init.callee.name=useController], VariableDeclaration[declarations.0.init.callee.name=useController] ~ VariableDeclaration[declarations.0.init.callee.name=useState]",
"message": "Don't use \"useController\" with \"useState\". Move you \"useState\" and another logic to separate component and wrap this component into another component with useController. Reason: This approach will rise wrong logic for handle input filed"
},
{
"selector": "CallExpression[callee.name=useForm][arguments.length=1] Property[key.name=defaultValues][value.properties.length=0]",
"message": "\"defaultValues\" can not be empty object for correct \"formState\" behavior. More info here: https://react-hook-form.com/api/useform/formstate#main"
},
{
"selector": "MemberExpression[object.name=React][property.name=/^use/]",
"message": "Use hooks without \"React\" prefix. For avoid using both import styles. Example: \"useEffect\" instead of \"React.useEffect\"."
},
{
"selector": "CallExpression[callee.type=MemberExpression][callee.property.name=forEach]:has(AwaitExpression)",
"message": "Do not use in forEach \"async\" code, because logic will not be awaited. use \"map\" with \"Promise.all\", for example \"await Promise.all(ARRAY_OF_ITEM.map(...))\" or use regular \"for\" loop."
},
{
"selector": "ConditionalExpression[consequent.type=Literal][consequent.value=true][alternate.type=Literal][alternate.value=false]",
"message": "Do not use \"condition ? true : false\". Simplify \"someVariable === 42 ? true : false \" to \"someVariable === 42\""
},
{
"selector": "JSXElement[openingElement.name.property.name=Provider] JSXElement[openingElement.name.name]",
"message": "Do not put your regular components inside Context \".Provider\". Create new component, for example ComponentProvider. Put Provider's logic to ComponentProvider. Render \"{children} instead of regular component. Wrap regular component via new ComponentProvider \". Example: \"src/services/auth/auth-provider\""
},
{
"selector": "Property[key.name=/^(padding|margin|paddingLeft|paddingRight|paddingTop|paddingBottom|paddingVertical|marginLeft|marginRight|marginTop|marginBottom|marginVertical)$/][value.type=/^(Literal|UnaryExpression)$/]:not([value.value=\"0 !important\"]):not([value.value=\"0\"]):not([value.value=\"0 auto\"]):not([value.value=\"auto\"])",
"message": "Use theme.spacing() instead of literal."
},
{
"selector": "CallExpression[callee.name=/^(useQuery|useInfiniteQuery)$/] Property[key.name=queryKey]:not(:has(Identifier[name=key]))",
"message": "Use key created via createQueryKeys function instead of your solution"
},
{
"selector": "CallExpression[callee.name=refresh]",
"message": "Do not use refresh() function for update or change result in react-query. Use \"queryClient.resetQueries\" or pass new filter data to queryKey."
},
{
"selector": "ExpressionStatement[expression.callee.object.name=JSON][expression.callee.property.name=parse][expression.arguments.0.callee.object.name=JSON][expression.arguments.0.callee.property.name=stringify]",
"message": "Do not use JSON.parse(JSON.stringify(...)) for deep copy. Use structuredClone instead."
},
{
"selector": "CallExpression[callee.name=test][arguments.0.value!=/^should/]",
"message": "\"test\" should start with \"should\""
}
],
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "@mui/material",
"message": "Please use \"import ComponentName from '@mui/material/ComponentName'\" instead."
},
{
"name": "@mui/icons-material",
"message": "Please use \"import IconName from '@mui/icons-material/IconName'\" instead."
},
{
"name": "next/link",
"message": "Please use \"import Link from \"@/components/link\"\" instead. This is need for \"leave page\" logic"
}
]
}
]
}
}
27 changes: 27 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: E2E tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
59 changes: 38 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
# Logs
logs
*.log
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

*storybook.log
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx commitlint --edit
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint
3 changes: 3 additions & 0 deletions .hygen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
templates: `${__dirname}/.hygen`,
};
14 changes: 14 additions & 0 deletions .hygen/generate/resource/admin-panel-create.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
to: src/services/i18n/locales/en/admin-panel-<%= h.inflection.transform(name, ['pluralize', 'underscore', 'dasherize']) %>-create.json
---
{
"title": "Create",
"actions": { "submit": "Save", "cancel": "Cancel" },
"inputs": {
"description": {
"label": "Description",
"validation": { "required": "Description is required" }
}
},
"alerts": { "success": "<%= name %> has been created successfully" }
}
14 changes: 14 additions & 0 deletions .hygen/generate/resource/admin-panel-edit.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
to: src/services/i18n/locales/en/admin-panel-<%= h.inflection.transform(name, ['pluralize', 'underscore', 'dasherize']) %>-edit.json
---
{
"title": "Edit",
"actions": { "submit": "Save", "cancel": "Cancel" },
"inputs": {
"description": {
"label": "Description",
"validation": { "required": "Description is required" }
}
},
"alerts": { "success": "<%= name %> has been updated successfully" }
}
21 changes: 21 additions & 0 deletions .hygen/generate/resource/admin-panel.ejs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
to: src/services/i18n/locales/en/admin-panel-<%= h.inflection.transform(name, ['pluralize', 'underscore', 'dasherize']) %>.json
---
{
"title": "<%= h.inflection.transform(name, ['pluralize']) %>",
"table": {
"column1": "ID"
},
"actions": {
"add": "Add <%= name %>",
"edit": "Edit",
"delete": "Delete",
"create": "Create <%= name %>"
},
"confirm": {
"delete": {
"title": "Delete <%= name %>",
"message": "Are you sure you want to delete this <%= name %>?"
}
}
}
Loading
Loading