no-escaped-anno-brackets
Rule Details
The escaped annotation syntax ![@...] is unnecessary in modern CAP CDS. Inline annotations can be written as @... directly. This rule reports usages of the old escaped syntax and provides an autofix to replace them.
Examples
✅ Correct example
In the following example, inline annotations use the modern @... syntax without escaping:
cds
namespace sap.capire.bookshop;
@UI.LineItem: [{
Value : title,
@UI.Importance : #High,
}]
entity Books {
key ID : Integer;
@mandatory title : localized String(111);
@mandatory author : Association to Authors;
}1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
❌ Incorrect example
This example shows the old escaped annotation syntax ![@UI.Importance] which is unnecessary and should be replaced with @UI.Importance:
cds
namespace sap.capire.bookshop;
@UI.LineItem: [{
Value : title,
![@UI.Importance] : #High, // escaped annotation syntax is unnecessary
}]
entity Books {
key ID : Integer;
@mandatory title : localized String(111);
@mandatory author : Association to Authors;
}1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Version
This rule was introduced in @sap/eslint-plugin-cds 4.2.3.