@sap/eslint-plugin-cds 2.1.0 → 2.3.0

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.
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @typedef { import("eslint").Rule.RuleContext.options } ContextOptions
3
+ */
4
+
5
+ module.exports = {
6
+ /**
7
+ * Checks whether the rule name is valid (i.e. is contained within
8
+ * the plugin's or user's *custom* rules).
9
+ * @param context
10
+ * @param pluginRules
11
+ * @param customRules
12
+ * @returns
13
+ */
14
+ isValidRule: function (context, rules) {
15
+ if (rules.includes(context.ruleID.replace("@sap/cds/", ""))) {
16
+ return true;
17
+ }
18
+ return false;
19
+ },
20
+
21
+ /**
22
+ * Checks whether a cds model is error-free
23
+ * @param context cds context object
24
+ * @returns
25
+ */
26
+ isValidModel: function (context) {
27
+ const cds = context.cds;
28
+ if (cds) {
29
+ if (cds.model) {
30
+ return !cds.model.err;
31
+ }
32
+ return true; // allow no model
33
+ }
34
+ return false;
35
+ },
36
+
37
+ /**
38
+ * Checks whether a well-defined cds environment exists
39
+ * @param context cds context object
40
+ * @returns
41
+ */
42
+ isValidEnv: function (context) {
43
+ if (
44
+ context.options &&
45
+ context.options[0] &&
46
+ context.options[0].environment
47
+ ) {
48
+ return true;
49
+ }
50
+ return false;
51
+ },
52
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/eslint-plugin-cds",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
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,7 +20,7 @@
20
20
  "README.md"
21
21
  ],
22
22
  "dependencies": {
23
- "@sap/cds": "^5.0.0",
23
+ "@sap/cds": "^5.6.0",
24
24
  "semver": "^7.3.4"
25
25
  },
26
26
  "peerDependencies": {
@@ -1,5 +0,0 @@
1
- const { getRules } = require("../utils/rules");
2
-
3
- const rules = getRules(__dirname);
4
-
5
- module.exports = { rules };
@@ -1,10 +0,0 @@
1
- const path = require("path");
2
- const { runRuleTester } = require("../../../lib/api");
3
-
4
- runRuleTester({
5
- root: path.resolve(__dirname),
6
- rule: require(`../../../lib/rules/${path.basename(__dirname)}`),
7
- filename: "{{filename}}",
8
- parser: path.resolve(path.join(__dirname, '../../../lib/impl/parser')),
9
- errors: "{{errors}}",
10
- });