Skip to content

Commit 654ffde

Browse files
committed
Fix name
1 parent 3c68f52 commit 654ffde

File tree

6 files changed

+60
-5
lines changed

6 files changed

+60
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const cds = require('@sap/cds')
2+
const { Books } = require('#cds-models/sap/capire/bookshop/AdminService') // [!code error]
3+
4+
module.exports = class AdminService extends cds.ApplicationService {
5+
// …
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const cds = require('@sap/cds')
2+
const { Books } = require('#cds-models/sap/capire/bookshop/CatalogService') // [!code highlight]
3+
4+
module.exports = class AdminService extends cds.ApplicationService {
5+
// …
6+
}

tools/cds-lint/examples/no-shared-handler-variables/correct/srv/admin-service.js renamed to tools/cds-lint/examples/no-shared-handler-variable/correct/srv/admin-service.js

File renamed without changes.

tools/cds-lint/examples/no-shared-handler-variables/incorrect/srv/admin-service.js renamed to tools/cds-lint/examples/no-shared-handler-variable/incorrect/srv/admin-service.js

File renamed without changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
status: released
3+
---
4+
5+
<script setup>
6+
import PlaygroundBadge from '../components/PlaygroundBadge.vue'
7+
</script>
8+
9+
# no-cross-service-import
10+
11+
## Rule Details
12+
13+
This rule helps you avoid importing artifacts generated for one service (e.g., service X) into the implementation of another service (e.g., service Y) when using cds-typer. Keeping service boundaries clear makes your codebase easier to maintain and understand.
14+
15+
#### Version
16+
This rule was introduced in `@sap/eslint-plugin-cds 4.0.2`.
17+
18+
## Examples
19+
20+
### &nbsp; Correct example
21+
22+
Here, the imported entity belongs to `AdminService` and is used within the implementation of `AdminService` itself—this is the recommended approach:
23+
::: code-group
24+
<<< ../examples/no-cross-service-import/correct/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
25+
:::
26+
<PlaygroundBadge
27+
name="no-cross-service-import"
28+
kind="correct"
29+
:files="['srv/admin-service.js']"
30+
/>
31+
32+
### &nbsp; Incorrect example
33+
34+
In this case, an entity from `CatalogService` is imported into the implementation of `AdminService`. This cross-service import is discouraged, as it can lead to confusion and maintenance issues:
35+
36+
::: code-group
37+
<<< ../examples/no-cross-service-import/incorrect/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
38+
:::
39+
<PlaygroundBadge
40+
name="no-cross-service-import"
41+
kind="incorrect"
42+
:files="['srv/admin-service.js']"
43+
/>

tools/cds-lint/rules/no-shared-handler-variables.md renamed to tools/cds-lint/rules/no-shared-handler-variable.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ status: released
66
import PlaygroundBadge from '../components/PlaygroundBadge.vue'
77
</script>
88

9-
# no-shared-handler-variables
9+
# no-shared-handler-variable
1010

1111
## Rule Details
1212

@@ -25,10 +25,10 @@ This rule was introduced in `@sap/eslint-plugin-cds 4.0.2`.
2525
In the following example, only locally defined variables are used within handler implementation:
2626

2727
::: code-group
28-
<<< ../examples/no-shared-handler-variables/correct/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
28+
<<< ../examples/no-shared-handler-variable/correct/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
2929
:::
3030
<PlaygroundBadge
31-
name="no-shared-handler-variables"
31+
name="no-shared-handler-variable"
3232
kind="correct"
3333
:files="['srv/admin-service.js']"
3434
/>
@@ -38,10 +38,10 @@ In the following example, only locally defined variables are used within handler
3838
In the following example, the variables `newBook` and `readBooks` are declared in scopes surrounding the handler function, making their value available to subsequent calls of that handler. While this may seem advantageous, it can cause issues in a multitenant scenario, where the handler function can be invoked by multiple tenants.
3939

4040
::: code-group
41-
<<< ../examples/no-shared-handler-variables/incorrect/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
41+
<<< ../examples/no-shared-handler-variable/incorrect/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
4242
:::
4343
<PlaygroundBadge
44-
name="no-shared-handler-variables"
44+
name="no-shared-handler-variable"
4545
kind="incorrect"
4646
:files="['srv/admin-service.js']"
4747
/>

0 commit comments

Comments
 (0)