@sap/eslint-plugin-cds
Version:
ESLint plugin including recommended SAP Cloud Application Programming model and environment rules
36 lines (32 loc) • 967 B
JavaScript
const { RULE_CATEGORIES } = require('../constants')
module.exports = {
meta: {
schema: [{/* to avoid deprecation warning for ESLint 9 */}],
docs: {
category: RULE_CATEGORIES.model,
description: 'Draft-enabled entities shall not be used in views that make use of `JOIN`.',
recommended: true,
url: 'https://cap.cloud.sap/docs/tools/cds-lint/rules/no-join-on-draft',
},
messages: {
draftJoin: 'Do not use draft-enabled entities in views that make use of `JOIN`.',
},
type: 'suggestion',
model: 'inferred'
},
create: function (context) {
return { entity: checkNojoinDraftenabled }
function checkNojoinDraftenabled (e) {
if (e['@odata.draft.enabled']) {
if (e?.query?.SELECT?.from?.join) {
context.report({
messageId: 'draftJoin',
node: context.getNode(e),
file: e.$location.file
})
}
}
}
}
}