Skip to content

Commit

Permalink
[SUGGESTION]: Use src/ folder on frontend (#219)
Browse files Browse the repository at this point in the history
* feat: suggestion of src folder structure

* fix: update tsconfig

* fix: eslint config and require

* fix: eslint config and require

* fix: jest tests

* fix: solve merge conflits

* fix: package.json versions
  • Loading branch information
dsousa12 authored Jun 6, 2022
1 parent f2e03d1 commit 27cc37d
Show file tree
Hide file tree
Showing 267 changed files with 6,373 additions and 2,141 deletions.
1,511 changes: 744 additions & 767 deletions backend/package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"@nestjs/testing": "^8.4.4",
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"@types/mongodb": "^4.0.7",
"@types/node": "^17.0.23",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.18.0",
Expand Down
4 changes: 2 additions & 2 deletions backend/src/modules/users/dto/create.user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export default class CreateUserDto {

@IsString()
@IsNotEmpty()
@MinLength(2)
@MinLength(3)
@Transform(({ value }: TransformFnParams) => value.trim())
firstName!: string;

@IsString()
@IsNotEmpty()
@MinLength(2)
@MinLength(3)
@Transform(({ value }: TransformFnParams) => value.trim())
lastName!: string;

Expand Down
2 changes: 2 additions & 0 deletions frontend/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# .eslintrc.js

# dependencies
/node_modules
/.pnp
Expand Down
101 changes: 101 additions & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');

const folders = fs
.readdirSync('src', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => !['styles'].includes(dirent.name) && dirent.name);

module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'plugin:react/recommended',
'airbnb',
'airbnb-typescript',
'prettier',
'airbnb-typescript-prettier'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 12,
sourceType: 'module',
extraFileExtensions: ['.css'],
project: './tsconfig.json'
},
plugins: [
'react',
'@typescript-eslint',
'simple-import-sort',
'import',
'unused-imports',
'prettier'
],
rules: {
'react/react-in-jsx-scope': 'off',
'react/jsx-filename-extension': [
1,
{
extensions: ['.ts', '.tsx']
}
],
'react/jsx-props-no-spreading': 'off',
'no-underscore-dangle': 'off',
'no-param-reassign': 'off',
'react/function-component-definition': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'import/prefer-default-export': 'off',
'import/no-cycle': 'off',
'no-plusplus': 'off',
'no-useless-escape': 'off',
'no-restricted-exports': 'off',
'jsx-a11y/anchor-is-valid': [
'error',
{
components: ['Link'],
specialLink: ['hrefLeft', 'hrefRight'],
aspects: ['invalidHref', 'preferButton']
}
],
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'unused-imports/no-unused-imports': 'error',
'prettier/prettier': ['error', { usePrettierrc: true }]
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
moduleDirectory: ['node_modules', 'src/']
}
}
},
overrides: [
{
files: ['**/*.ts?(x)'],
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// Packages. `react` related packages come first.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^react', '^next', '^recoil', '^@?\\w'], // Absolute imports and Relative imports.
['^styles'],
[`^(${folders.join('|')})(/.*|$)`, '^\\.'], // for scss imports.
['^[^.]']
]
}
]
}
}
]
};
54 changes: 0 additions & 54 deletions frontend/.eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ yarn-error.log*
.vercel

#cypress
/cypress/screenshots/
/cypress/videos/
/src/cypress/screenshots/
/src/cypress/videos/
40 changes: 20 additions & 20 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"tabWidth": 4,
"useTabs": true,
"singleQuote": true,
"printWidth": 100,
"semi": true,
"trailingComma": "none",
"overrides": [
{
"files": [
"*.yml",
"*.yaml",
"**/*.yml",
"**/*.yaml"
],
"options": {
"tabWidth": 2,
"useTabs": false
}
}
]
"tabWidth": 4,
"useTabs": true,
"singleQuote": true,
"printWidth": 100,
"semi": true,
"trailingComma": "none",
"overrides": [
{
"files": [
"*.yml",
"*.yaml",
"**/*.yml",
"**/*.yaml"
],
"options": {
"tabWidth": 2,
"useTabs": false
}
}
]
}
73 changes: 0 additions & 73 deletions frontend/components/CardBoard/CardBody/CardTitle.tsx

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/components/Primitives/Svg.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions frontend/components/Sidebar/partials/Header/styles.tsx

This file was deleted.

22 changes: 11 additions & 11 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// jest.config.js
// eslint-disable-next-line @typescript-eslint/no-var-requires
const nextJest = require("next/jest");
const nextJest = require('next/jest');

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './'
});

// Add any custom config to be passed to Jest
const customJestConfig = {
// Add more setup options before each test is run
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ["node_modules", "<rootDir>/"],
testEnvironment: "jest-environment-jsdom",
moduleNameMapper: {
"\\.svg$": "<rootDir>/public/icons/",
},
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/src'],
testEnvironment: 'jest-environment-jsdom',
moduleNameMapper: {
'\\.svg$': '<rootDir>/public/icons/'
}
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
Expand Down
2 changes: 1 addition & 1 deletion frontend/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import "@testing-library/jest-dom/extend-expect";
import '@testing-library/jest-dom/extend-expect';
Loading

0 comments on commit 27cc37d

Please sign in to comment.