@sap/eslint-plugin-cds 2.6.1 → 2.6.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,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
8
8
 
9
+ ## [2.6.3] - 2023-02-13
10
+
11
+ ### Changed
12
+
13
+ - Filter rule reports using *inferred* models on $location.
14
+
15
+ ## [2.6.2] - 2023-02-13
16
+
17
+ ### Changed
18
+
19
+ - Fixed rule reports using *inferred* models to always receive valid _file_ $locations.
20
+
9
21
  ## [2.6.1] - 2023-01-26
10
22
 
11
23
  ### Changed
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # @sap/eslint-plugin-cds
2
- [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
3
- [![Sync Files Workflow](https://github.tools.sap/cap/eslint-plugin-cds/actions/workflows/sync.yml/badge.svg)](https://github.tools.sap/cap/eslint-plugin-cds/actions/workflows/sync.yml)
2
+
4
3
 
5
4
  The [ESLint](https://eslint.org) plugin includes a set of recommended [SAP Cloud Application Programming Model (CAP)](https://cap.cloud.sap) model and environment rules. The aim of CDS linting is to catch issues with CDS models and with the environment early. To use this module we recommend to install [@sap/cds-dk](https://www.npmjs.com/package/@sap/cds-dk) globally.
6
5
 
@@ -144,8 +144,11 @@ function createReport (node, cdscontext, meta, create) {
144
144
 
145
145
  if (model) {
146
146
  model.forall((d) => {
147
+ d = (meta.model === 'inferred') ? sanitizeFileLocation(d) : d
148
+ const isValidLocation = (meta.model === 'parsed' && d.$location) ||
149
+ (meta.model === 'inferred' && d.$location?.file)
147
150
  Object.entries(handlers)
148
- .filter(([type, lazy]) => d.is(type))
151
+ .filter(([type, lazy]) => d.is(type) && isValidLocation)
149
152
  .forEach(([lazy, handler]) => {
150
153
  try {
151
154
  handler(d)
@@ -161,6 +164,13 @@ function createReport (node, cdscontext, meta, create) {
161
164
  }
162
165
  }
163
166
 
167
+ function sanitizeFileLocation (d) {
168
+ let parent = d
169
+ while (!parent.$location && parent.parent && !parent.parent.definitions) parent = d.parent
170
+ if (parent.$location) d.$location = parent.$location
171
+ return d
172
+ }
173
+
164
174
  function extendContext (node, context, meta) {
165
175
  if (!Cache.has('test')) {
166
176
  const filePath = context.getFilename()
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
- "name": "@sap/eslint-plugin-cds",
3
- "version": "2.6.1",
4
- "description": "ESLint plugin including recommended SAP Cloud Application Programming model and environment rules",
5
- "homepage": "https://cap.cloud.sap/",
6
- "keywords": [
7
- "eslint",
8
- "eslint-plugin",
9
- "cds",
10
- "cds-lint",
11
- "cds-lint-plugin"
12
- ],
13
- "author": "SAP SE (https://www.sap.com)",
14
- "license": "See LICENSE file",
15
- "main": "lib/index.js",
16
- "files": [
17
- "lib/",
18
- "CHANGELOG.md",
19
- "LICENSE",
20
- "README.md"
21
- ],
22
- "dependencies": {
23
- "@sap/cds": ">=5.6.0",
24
- "semver": "^7.3.4"
25
- },
26
- "eslintConfig": {
27
- "extends": [
28
- "eslint:recommended",
29
- "standard"
30
- ]
31
- },
32
- "peerDependencies": {
33
- "eslint": ">=7"
34
- },
35
- "engines": {
36
- "node": ">=14"
37
- }
2
+ "name": "@sap/eslint-plugin-cds",
3
+ "version": "2.6.3",
4
+ "description": "ESLint plugin including recommended SAP Cloud Application Programming model and environment rules",
5
+ "homepage": "https://cap.cloud.sap/",
6
+ "keywords": [
7
+ "eslint",
8
+ "eslint-plugin",
9
+ "cds",
10
+ "cds-lint",
11
+ "cds-lint-plugin"
12
+ ],
13
+ "author": "SAP SE (https://www.sap.com)",
14
+ "license": "See LICENSE file",
15
+ "main": "lib/index.js",
16
+ "files": [
17
+ "lib/",
18
+ "CHANGELOG.md",
19
+ "LICENSE",
20
+ "README.md"
21
+ ],
22
+ "dependencies": {
23
+ "@sap/cds": ">=5.6.0",
24
+ "semver": "^7.3.4"
25
+ },
26
+ "eslintConfig": {
27
+ "extends": [
28
+ "eslint:recommended",
29
+ "standard"
30
+ ]
31
+ },
32
+ "peerDependencies": {
33
+ "eslint": ">=7"
34
+ },
35
+ "engines": {
36
+ "node": ">=14"
37
+ }
38
38
  }