no-dollar-prefixed-names
Rule Details
Names must not start with $ to avoid possible shadowing of reserved variables.
Examples
✅ Correct example
In the following example, all elements names are well defined and do not start with $
:
cds
namespace sap.capire.bookshop;
entity Books {
key ID : Integer;
@mandatory title : localized String(111);
@mandatory author : Association to Authors;
pages: Integer;
}
entity Authors {
key ID : Integer;
@mandatory name : String(111);
books : Association to many Books on books.author = $self;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
❌ Incorrect example
In the next example, the element $pages
starts with $
and so the rule will raise an error for this element:
cds
namespace sap.capire.bookshop;
entity Books {
key ID : Integer;
@mandatory title : localized String(111);
@mandatory author : Association to Authors;
$pages: Integer; // [!code error] // elements should not start with a dollar sign ($)
}
entity Authors {
key ID : Integer;
@mandatory name : String(111);
books : Association to many Books on books.author = $self;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Version
This rule was introduced in @sap/eslint-plugin-cds 2.3.3
.