no-deep-sap-cds-import
Rule Details
Import only from the top-level @sap/cds package. Accessing internal modules or sub-paths is unsafe because these are not part of the official public API and may change or be removed without notice. A few exceptions to this rule will not be reported as errors.
Version
This rule was introduced in @sap/eslint-plugin-cds 4.0.2.
Examples
✅ Correct example
The following example imports @sap/cds:
js
const cds = require('@sap/cds')
module.exports = class AdminService extends cds.ApplicationService {
// …
}1
2
3
4
5
2
3
4
5
❌ Incorrect example
This example incorrectly performs a deep import of a file within @sap/cds:
js
const ApplicationService = require('@sap/cds/srv/app-service') // path is no API!
module.exports = class AdminService extends ApplicationService {
// …
}1
2
3
4
5
2
3
4
5