Skip to content

Commit

Permalink
added basic libs structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Courtcircuits committed Jan 25, 2024
1 parent cfa07ee commit 4f5f84c
Show file tree
Hide file tree
Showing 49 changed files with 1,617 additions and 126 deletions.
35 changes: 35 additions & 0 deletions .eslintrc.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
}
6 changes: 1 addition & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"root": true,
"ignorePatterns": ["!**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
],
"extends": ["plugin:@nx/react"]
"extends": ["plugin:@nx/react", "./.eslintrc.base.json"]
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ npm start
}
```
Basically, it will format your code according to the `.prettierrc` file ! Btw, you are free to tweak your settings but don't edit the `.prettierrc` file without preventing the other members of the team :)
## How to use nx ??
We are using nx to build a modular front-end. The idea is that you'll be able to import our components anywhere and it should work !
To do that :
```bash
npx nx g @nx/react:library --name=voice --unitTestRunner=vitest --directory=libs
```
5 changes: 1 addition & 4 deletions e2e/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
],
"plugins": ["@nx"],
"extends": ["plugin:cypress/recommended"]
"extends": ["plugin:cypress/recommended", "../.eslintrc.base.json"]
}
8 changes: 4 additions & 4 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"outDir": "../dist/out-tsc",
"module": "commonjs",
"types": ["cypress", "node"],
"sourceMap": false
"sourceMap": false,
},
"include": [
"**/*.ts",
Expand All @@ -15,6 +15,6 @@
"**/*.cy.tsx",
"**/*.cy.js",
"**/*.cy.jsx",
"**/*.d.ts"
]
"**/*.d.ts",
],
}
12 changes: 12 additions & 0 deletions libs/pages/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
34 changes: 34 additions & 0 deletions libs/pages/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"extends": [
"plugin:@nx/react",
"../../.eslintrc.base.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {}
},
{
"files": [
"*.ts",
"*.tsx"
],
"rules": {}
},
{
"files": [
"*.js",
"*.jsx"
],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/pages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# pages

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test pages` to execute the unit tests via [Vitest](https://vitest.dev/).
12 changes: 12 additions & 0 deletions libs/pages/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@beep-front/pages",
"version": "0.0.1",
"main": "./index.js",
"types": "./index.d.ts",
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.js"
}
}
}
42 changes: 42 additions & 0 deletions libs/pages/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "pages",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/pages/src",
"projectType": "library",
"tags": [],
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
},
"build": {
"executor": "@nx/vite:build",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/libs/pages"
},
"configurations": {
"development": {
"mode": "development"
},
"production": {
"mode": "production"
}
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": [
"{options.reportsDirectory}"
],
"options": {
"reportsDirectory": "../../coverage/libs/pages"
}
}
}
}
2 changes: 2 additions & 0 deletions libs/pages/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export * from './lib/pages';
7 changes: 7 additions & 0 deletions libs/pages/src/lib/pages.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Replace this with your own classes
*
* e.g.
* .container {
* }
*/
12 changes: 12 additions & 0 deletions libs/pages/src/lib/pages.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { render } from '@testing-library/react';

import Pages from './pages';

describe('Pages', () => {

it('should render successfully', () => {
const { baseElement } = render(<Pages />);
expect(baseElement).toBeTruthy();
});

});
30 changes: 30 additions & 0 deletions libs/pages/src/lib/pages.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@





import styles from './pages.module.scss';


/* eslint-disable-next-line */
export interface PagesProps {
}




export function Pages(props: PagesProps) {
return (
<div className={styles['container']}>

<h1>Welcome to Pages!</h1>

</div>
);
};


export default Pages;



24 changes: 24 additions & 0 deletions libs/pages/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"types": [
"vite/client",
"vitest"
]
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json"
}
28 changes: 28 additions & 0 deletions libs/pages/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts",
"vite/client"
]
},
"exclude": [
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
],
"include": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.ts",
"src/**/*.tsx"
]
}
26 changes: 26 additions & 0 deletions libs/pages/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"vitest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
Loading

0 comments on commit 4f5f84c

Please sign in to comment.