@sap/eslint-plugin-cds 4.2.1 → 4.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ This project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/).
8
8
 
9
+ ## [4.2.3] - 2026-05-12
10
+ ### Fixed
11
+ - Don't fail if the `tree-sitter` dependency cannot be installed. This might happen in WebContainer environments where native modules cannot be loaded.
12
+
13
+ ## [4.2.2] - 2026-05-04
14
+ ### Fixed
15
+ - `auth-valid-restrict-grant` now also considers inherited actions.
16
+
9
17
  ## [4.2.1] - 2026-02-26
10
18
  ### Fixed
11
19
  - Removed usage of deprecated API in `lib/utils/rules.js`
package/lib/index.js CHANGED
@@ -19,7 +19,6 @@
19
19
  const api = require('./api')
20
20
  const getConfigs = require('./conf')
21
21
  const { allRules, initialiseRules } = require('./rules')
22
- const { javaLanguage } = require('./languages/java/java-language')
23
22
  const packageJson = require('../package.json')
24
23
 
25
24
  const rules = initialiseRules(allRules)
@@ -30,7 +29,7 @@ const plugin = {
30
29
  version: packageJson.version
31
30
  },
32
31
  languages: {
33
- java: javaLanguage
32
+ get java() { return require('./languages/java/java-language').javaLanguage }
34
33
  },
35
34
  configs: {},
36
35
  rules,
@@ -8,6 +8,38 @@ const SAME_AS_WRITE_EVENT = [ 'CREATE', 'DELETE', 'UPDATE', 'UPSERT' ]
8
8
  // Note that 'INSERT' is not meant to be used by users. They should use 'CREATE' instead.
9
9
  const VALID_EVENTS = [ ...SAME_AS_WRITE_EVENT, 'READ', 'INSERT', '*', 'WRITE']
10
10
 
11
+ const isJoin = e => Boolean(e.query?.SELECT?.from.join)
12
+ const isProjection = e => Boolean(e.query?.SELECT?.from.ref)
13
+ const isSetUnion = e => Boolean(e.query?.SET?.op === 'union')
14
+ const projectionTarget = e => e.query.SELECT.from.ref[0]
15
+
16
+ function extractActions (e, csn) {
17
+ const getActions = e => Object.keys(e.actions ?? {})
18
+ const queue = [e]
19
+ const actions = []
20
+ while (queue.length) {
21
+ const entity = queue.pop()
22
+ actions.push(...getActions(entity))
23
+ if (isJoin(entity)) {
24
+ for (const { ref } of entity.query.SELECT.from.args[0].args) {
25
+ const ancestor = csn.definitions[ref[0]]
26
+ if (ancestor) {
27
+ queue.push(ancestor)
28
+ }
29
+ }
30
+ } else if (isProjection(entity)) {
31
+ const ancestor = csn.definitions[projectionTarget(entity)]
32
+ if (ancestor) {
33
+ queue.push(ancestor)
34
+ }
35
+ } else if (isSetUnion(entity)) {
36
+ // these are entities/ queries themselves. Just queue those.
37
+ queue.push(...entity.query.SET.args.map(e => ({query: e}) ))
38
+ }
39
+ }
40
+ return actions
41
+ }
42
+
11
43
  const TYPICAL_ISSUES = {
12
44
  __proto__: null,
13
45
  any: '*'
@@ -45,7 +77,7 @@ module.exports = {
45
77
 
46
78
  const node = context.getNode(e)
47
79
  const file = e.$location.file
48
- const actionNames = e.actions ? Object.keys(e.actions) : []
80
+ const actionNames = extractActions(e, context.getModel())
49
81
  const validEventsAndActions = [ ...VALID_EVENTS, ...actionNames ]
50
82
 
51
83
  for (const entry of e['@restrict']) {
@@ -72,7 +72,7 @@ class CsnTraversal {
72
72
  if (!node || typeof node !== 'object')
73
73
  return
74
74
 
75
- for (const name of Object.getOwnPropertyNames( dict ))
75
+ for (const name of Object.getOwnPropertyNames( dict ?? {} ))
76
76
  this.standard( dict, name, dict[name] )
77
77
  }
78
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/eslint-plugin-cds",
3
- "version": "4.2.1",
3
+ "version": "4.2.3",
4
4
  "description": "ESLint plugin including recommended SAP Cloud Application Programming model and environment rules",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [
@@ -20,8 +20,10 @@
20
20
  "README.md"
21
21
  ],
22
22
  "dependencies": {
23
- "@eslint/plugin-kit": "^0.6.0",
24
- "semver": "^7.7.1",
23
+ "@eslint/plugin-kit": "^0.7.0",
24
+ "semver": "^7.7.1"
25
+ },
26
+ "optionalDependencies": {
25
27
  "tree-sitter": "^0.21.1",
26
28
  "tree-sitter-java": "^0.23.5"
27
29
  },