Skip to content
Open
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
22 changes: 21 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,27 @@
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"allSourceTags": ["type:app", "scope:cart"],
"onlyDependOnLibsWithTags": [
"type:no-such-type",
"scope:shared",
"type:ui"
]
},
{
"sourceTag": "scope:products",
"onlyDependOnLibsWithTags": ["*"]
},
{
"sourceTag": "type:feature",
"onlyDependOnLibsWithTags": ["*"]
},
{
"sourceTag": "scope:shared",
"onlyDependOnLibsWithTags": ["*"]
},
{
"sourceTag": "type:e2e",
"onlyDependOnLibsWithTags": ["*"]
}
]
Expand Down
7 changes: 6 additions & 1 deletion apps/cart/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { Route, Routes } from 'react-router-dom';

import '@nx-example/shared/header';

import { CartCartPage } from '@nx-example/cart/cart-page';
/**
* Should throw linting error because lib @nx-example/cart-cart-page only has tags "scope:cart" and "type:feature":
*
* A project tagged with "type:app" and "scope:cart" can only depend on libs tagged with "type:no-such-type", "scope:shared", "type:ui" @nx/enforce-module-boundaries
*/
import { CartCartPage } from '@nx-example/cart-cart-page/src/lib/cart-cart-page/cart-cart-page';

export const App = () => {
return (
Expand Down
6 changes: 6 additions & 0 deletions libs/cart/cart-page/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@nx-example/cart-cart-page",
"version": "0.0.1",
"private": true,
"description": ""
}
11 changes: 11 additions & 0 deletions libs/cart/cart-page/src/lib/cart-cart-page/cart-cart-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import styled from '@emotion/styled';

import '@nx-example/shared/product/ui';

/**
* Should throw linting error:
*
* Projects should use relative imports to import from other files within the same project.
* Use "./path/to/file" instead of import from "@nx-example/cart-cart-page/src/lib/utils/checkout" @nx/enforce-module-boundaries
*
*/
import { checkoutUtils } from '@nx-example/cart-cart-page/src/lib/utils/checkout';

console.log('Checkout Utils:', checkoutUtils());

import {
CartItem,
cartReducer,
Expand Down
2 changes: 2 additions & 0 deletions libs/cart/cart-page/src/lib/utils/checkout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const checkoutUtils = () =>
Math.random() > 0.5 ? 'Checkout Successful' : 'Checkout Failed';
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"name": "nx-example",
"version": "0.0.0",
"license": "MIT",
"workspaces": [
"apps/**/*",
"tools/**/*",
"libs/**/*"
],
"scripts": {
"start": "nx serve",
"build": "nx build",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@nx-example/cart/cart-page": ["libs/cart/cart-page/src/index.ts"],
// "@nx-example/cart/cart-page": ["libs/cart/cart-page/src/index.ts"],
"@nx-example/products/home-page": [
"libs/products/home-page/src/index.ts"
],
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5715,6 +5715,12 @@ __metadata:
languageName: node
linkType: hard

"@nx-example/cart-cart-page@workspace:libs/cart/cart-page":
version: 0.0.0-use.local
resolution: "@nx-example/cart-cart-page@workspace:libs/cart/cart-page"
languageName: unknown
linkType: soft

"@nx/angular@npm:22.4.0-beta.0":
version: 22.4.0-beta.0
resolution: "@nx/angular@npm:22.4.0-beta.0"
Expand Down