diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index fc2dd0bd..46c6e9d0 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -41,6 +41,7 @@ jobs: - name: Run CI run: | npm run lint + npm run lint:playwright npm test - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} diff --git a/.vscode/settings.json b/.vscode/settings.json index 6de2fcff..a4782cac 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,30 @@ ".pytest_cache/": true }, "typescript.tsdk": "rsconcept/frontend/node_modules/typescript/lib", - "eslint.workingDirectories": ["rsconcept/frontend"], + "eslint.probe": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + "eslint.workingDirectories": [ + { + "directory": "./", + "overrideConfigFile": "eslint.config.js", + "changeProcessCWD": true + }, + { + "directory": "./", + "pattern": "tests/**", + "overrideConfigFile": "eslint.playwright.config.js" + } + ], "isort.args": [ "--line-length", "100", diff --git a/rsconcept/frontend/README.md b/rsconcept/frontend/README.md deleted file mode 100644 index 58e2556c..00000000 --- a/rsconcept/frontend/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Frontend Developer guidelines - -Styling conventions - -- static > conditional static > props. All dynamic styling should go in styles props -- dimensions = rectangle + outer layout - -
-clsx className grouping and order -
-  - layer: z-position
-  - outer layout: fixed bottom-1/2 left-0 -translate-x-1/2
-  - rectangle: mt-3 min-w-fit min-w-10 flex-grow shrink-0
-  - inner layout: px-3 py-2 flex flex-col gap-3 justify-between items-center
-  - overflow behavior: overflow-scroll overscroll-contain
-  - border: borer-2 outline-none shadow-md
-  - text: text-start text-sm font-semibold whitespace-nowrap bg-prim-200 fg-app-100
-  - behavior modifiers: select-none disabled:cursor-auto
-  - transitions: 
-  
-
diff --git a/rsconcept/frontend/eslint.config.js b/rsconcept/frontend/eslint.config.js index 8cb311aa..7e58f2b8 100644 --- a/rsconcept/frontend/eslint.config.js +++ b/rsconcept/frontend/eslint.config.js @@ -6,13 +6,21 @@ import reactCompilerPlugin from 'eslint-plugin-react-compiler'; import reactHooksPlugin from 'eslint-plugin-react-hooks'; import importPlugin from 'eslint-plugin-import'; import simpleImportSort from 'eslint-plugin-simple-import-sort'; -import playwright from 'eslint-plugin-playwright'; export default [ ...typescriptPlugin.configs.recommendedTypeChecked, ...typescriptPlugin.configs.stylisticTypeChecked, { - ignores: ['**/parser.ts', '**/node_modules/**', '**/public/**', '**/dist/**', 'eslint.config.js'] + ignores: [ + '**/parser.ts', + '**/node_modules/**', + '**/public/**', + '**/dist/**', + 'eslint.config.js', + 'playwright.config.ts', + 'eslint.playwright.config.js', + 'tests/**' + ] }, { languageOptions: { @@ -21,16 +29,11 @@ export default [ ecmaVersion: 'latest', sourceType: 'module', globals: { ...globals.browser, ...globals.es2020, ...globals.jest }, - project: ['./tsconfig.json', './tsconfig.vite.json', './tsconfig.test.json'], + project: ['./tsconfig.json', './tsconfig.vite.json'], projectService: true } } }, - { - ...playwright.configs['flat/recommended'], - files: ['tests/**'], - rules: { ...playwright.configs['flat/recommended'].rules } - }, { plugins: { 'react': reactPlugin, @@ -42,6 +45,8 @@ export default [ settings: { react: { version: 'detect' } }, rules: { 'react-compiler/react-compiler': 'error', + 'react-refresh/only-export-components': ['off', { allowConstantExport: true }], + '@typescript-eslint/consistent-type-imports': [ 'warn', { @@ -61,8 +66,8 @@ export default [ } ], - 'react-refresh/only-export-components': ['off', { allowConstantExport: true }], - + 'simple-import-sort/exports': 'error', + 'import/no-duplicates': 'warn', 'simple-import-sort/imports': [ 'warn', { @@ -88,8 +93,6 @@ export default [ ] } ], - 'simple-import-sort/exports': 'error', - 'import/no-duplicates': 'warn', ...reactHooksPlugin.configs.recommended.rules } diff --git a/rsconcept/frontend/eslint.playwright.config.js b/rsconcept/frontend/eslint.playwright.config.js new file mode 100644 index 00000000..cca609a2 --- /dev/null +++ b/rsconcept/frontend/eslint.playwright.config.js @@ -0,0 +1,40 @@ +import globals from 'globals'; +import typescriptParser from '@typescript-eslint/parser'; +import playwright from 'eslint-plugin-playwright'; +import importPlugin from 'eslint-plugin-import'; +import simpleImportSort from 'eslint-plugin-simple-import-sort'; + +export default [ + { + ...playwright.configs['flat/recommended'], + + languageOptions: { + parser: typescriptParser, + + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + globals: { + ...globals.browser, + ...globals.es2020 + } + } + }, + + plugins: { + 'playwright': playwright, + 'simple-import-sort': simpleImportSort, + 'import': importPlugin + }, + + rules: { + ...playwright.configs['flat/recommended'].rules, + + 'simple-import-sort/exports': 'error', + 'import/no-duplicates': 'warn', + 'simple-import-sort/imports': 'warn' + }, + + files: ['tests/**/*.ts'] + } +]; diff --git a/rsconcept/frontend/package.json b/rsconcept/frontend/package.json index 9c438a7c..2ac0b33b 100644 --- a/rsconcept/frontend/package.json +++ b/rsconcept/frontend/package.json @@ -9,7 +9,8 @@ "teste2e": "playwright test", "dev": "vite --host", "build": "tsc && vite build", - "lint": "eslint . --report-unused-disable-directives --max-warnings 0", + "lint": "eslint . --config eslint.config.js --report-unused-disable-directives --max-warnings 0", + "lint:playwright": "eslint . --config eslint.playwright.config.js --report-unused-disable-directives --max-warnings 0", "lintFix": "eslint . --report-unused-disable-directives --max-warnings 0 --fix", "preview": "vite preview --port 3000" }, diff --git a/rsconcept/frontend/tsconfig.playwright.json b/rsconcept/frontend/tsconfig.playwright.json new file mode 100644 index 00000000..4adfd0dd --- /dev/null +++ b/rsconcept/frontend/tsconfig.playwright.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022", "dom"], + "module": "ESNext", + "moduleResolution": "bundler", + + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "isolatedModules": false, + + "baseUrl": "./", + "paths": { + "@/*": ["src/*"] + }, + "types": ["playwright"] + }, + "include": ["playwright.config.ts", "tests/**/*.ts"] +} diff --git a/rsconcept/frontend/tsconfig.test.json b/rsconcept/frontend/tsconfig.test.json deleted file mode 100644 index a236604b..00000000 --- a/rsconcept/frontend/tsconfig.test.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "types": ["playwright/test"], - "isolatedModules": false - }, - "include": ["src", "tests"] -} diff --git a/rsconcept/frontend/tsconfig.vite.json b/rsconcept/frontend/tsconfig.vite.json index 3fe47bf3..e718abca 100644 --- a/rsconcept/frontend/tsconfig.vite.json +++ b/rsconcept/frontend/tsconfig.vite.json @@ -11,5 +11,5 @@ "@/*": ["*"] } }, - "include": ["vite.config.ts", "package.json", "playwright.config.ts"] + "include": ["vite.config.ts", "package.json"] } diff --git a/scripts/dev/RunLint.ps1 b/scripts/dev/RunLint.ps1 index 567e5252..fbd619bf 100644 --- a/scripts/dev/RunLint.ps1 +++ b/scripts/dev/RunLint.ps1 @@ -21,6 +21,7 @@ function LintBackend() { function LintFrontend() { Set-Location $frontend & npm run lint + & npm run lint:playwright } RunLinters \ No newline at end of file