case-sensitive-well-known-events
Rule Details
This rule identifies registrations to events that are likely well-known event names that must be written in all caps.
Version
This rule was introduced in @sap/eslint-plugin-cds 4.0.2.
Examples
✅ Correct example
The following example shows the correctly capitalized event name READ:
js
const cds = require('@sap/cds')
module.exports = class AdminService extends cds.ApplicationService { async init() {
this.on('READ', 'Books', () => {})
}}1
2
3
4
5
2
3
4
5
❌ Incorrect example
This example shows a registration to an event Read, which should likely be READ. This can lead to unexpected behavior because event names in CAP are case sensitive:
js
const cds = require('@sap/cds')
module.exports = class AdminService extends cds.ApplicationService { async init() {
this.on('Read', 'Books', () => {})
}}1
2
3
4
5
2
3
4
5