@sap/eslint-plugin-cds 2.0.5 → 2.2.2
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 +111 -1
- package/README.md +2 -3
- package/lib/api/formatter.js +182 -132
- package/lib/api/index.js +27 -9
- package/lib/impl/constants.js +38 -44
- package/lib/impl/index.js +57 -34
- package/lib/impl/parser.js +37 -25
- package/lib/impl/processor.js +23 -0
- package/lib/impl/ruleFactory.js +301 -149
- package/lib/impl/rules/assoc2many-ambiguous-key.js +171 -0
- package/lib/impl/rules/cds-compile-error.js +35 -0
- package/lib/impl/rules/latest-cds-version.js +39 -33
- package/lib/impl/rules/min-node-version.js +36 -36
- package/lib/impl/rules/no-db-keywords.js +35 -0
- package/lib/impl/rules/no-join-on-draft-enabled-entities.js +35 -0
- package/lib/impl/rules/require-2many-oncond.js +29 -0
- package/lib/impl/rules/rule.hbs +20 -0
- package/lib/impl/rules/sql-cast-suggestion.js +45 -39
- package/lib/impl/rules/start-elements-lowercase.js +74 -0
- package/lib/impl/rules/start-entities-uppercase.js +65 -0
- package/lib/impl/types.d.ts +48 -0
- package/lib/impl/utils/helpers.js +68 -0
- package/lib/impl/utils/jsonc.js +1 -0
- package/lib/impl/utils/model.js +528 -0
- package/lib/impl/utils/rules.js +550 -0
- package/lib/impl/utils/validate.js +49 -0
- package/package.json +3 -3
- package/lib/impl/rules/assocs-card-flaw.js +0 -215
- package/lib/impl/rules/csn-compile-error.js +0 -37
- package/lib/impl/rules/lower-camelcase-elements.js +0 -42
- package/lib/impl/rules/upper-camelcase-entities.js +0 -50
- package/lib/impl/utils.js +0 -395
package/CHANGELOG.md
CHANGED
|
@@ -6,9 +6,119 @@ 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.1.2] - 2021-10-05
|
|
10
|
+
|
|
11
|
+
## Changed
|
|
12
|
+
|
|
13
|
+
- Allow not only *.js but also other file types (i.e. *.ts, etc) to bypass plugin rules
|
|
14
|
+
|
|
15
|
+
## [2.1.1] - 2021-10-04
|
|
16
|
+
|
|
17
|
+
## Changed
|
|
18
|
+
|
|
19
|
+
- Added preprocessor to avoid (other plugins) parsing errors on cds files
|
|
20
|
+
|
|
21
|
+
## [2.2.0] - 2021-10-29
|
|
22
|
+
|
|
23
|
+
## Added
|
|
24
|
+
|
|
25
|
+
- Added typings to javascript for all exposed apis
|
|
26
|
+
|
|
27
|
+
## Changed
|
|
28
|
+
|
|
29
|
+
- Aligned rule creation and tester api with ESLint
|
|
30
|
+
|
|
31
|
+
## [2.1.2] - 2021-10-05
|
|
32
|
+
|
|
33
|
+
## Changed
|
|
34
|
+
|
|
35
|
+
- Allow not only *.js but also other file types (i.e. *.ts, etc) to bypass plugin rules
|
|
36
|
+
|
|
37
|
+
## [2.1.1] - 2021-10-04
|
|
38
|
+
|
|
39
|
+
## Changed
|
|
40
|
+
|
|
41
|
+
- Added preprocessor to avoid (other plugins) parsing errors on cds files
|
|
42
|
+
|
|
43
|
+
## [2.2.1] - 2021-10-29
|
|
44
|
+
|
|
45
|
+
## Changed
|
|
46
|
+
|
|
47
|
+
- Optimized model loading and fixed bug in loading of 'outsider' files
|
|
48
|
+
|
|
49
|
+
## [2.2.0] - 2021-10-29
|
|
50
|
+
|
|
51
|
+
## Added
|
|
52
|
+
|
|
53
|
+
- Added typings to javascript for all exposed apis
|
|
54
|
+
|
|
55
|
+
## Changed
|
|
56
|
+
|
|
57
|
+
- Aligned rule creation and tester api with ESLint
|
|
58
|
+
|
|
59
|
+
## [2.1.2] - 2021-10-05
|
|
60
|
+
|
|
61
|
+
## Changed
|
|
62
|
+
|
|
63
|
+
- Allow not only *.js but also other file types (i.e. *.ts, etc) to bypass plugin rules
|
|
64
|
+
|
|
65
|
+
## [2.1.1] - 2021-10-04
|
|
66
|
+
|
|
67
|
+
## Changed
|
|
68
|
+
|
|
69
|
+
- Added preprocessor to avoid (other plugins) parsing errors on cds files
|
|
70
|
+
|
|
71
|
+
## [2.2.2] - 2021-11-08
|
|
72
|
+
|
|
73
|
+
## Added
|
|
74
|
+
|
|
75
|
+
- Added new rule 'no-join-on-draft-enabled-entities'
|
|
76
|
+
|
|
77
|
+
## Changed
|
|
78
|
+
|
|
79
|
+
- Compile 'model' files based on CSN flavor 'inferred'
|
|
80
|
+
- Compile 'outsider' files based on CSN flavor 'parsed'
|
|
81
|
+
|
|
82
|
+
## [2.2.1] - 2021-11-01
|
|
83
|
+
|
|
84
|
+
## Changed
|
|
85
|
+
|
|
86
|
+
- Optimized model loading and fixed bug in loading of 'outsider' files
|
|
87
|
+
|
|
88
|
+
## [2.2.0] - 2021-10-29
|
|
89
|
+
|
|
90
|
+
## Added
|
|
91
|
+
|
|
92
|
+
- Added typings to javascript for all exposed apis
|
|
93
|
+
|
|
94
|
+
## Changed
|
|
95
|
+
|
|
96
|
+
- Aligned rule creation and tester api with ESLint
|
|
97
|
+
|
|
98
|
+
## [2.1.2] - 2021-10-05
|
|
99
|
+
|
|
100
|
+
## Changed
|
|
101
|
+
|
|
102
|
+
- Allow not only *.js but also other file types (i.e. *.ts, etc) to bypass plugin rules
|
|
103
|
+
|
|
104
|
+
## [2.1.1] - 2021-10-04
|
|
105
|
+
|
|
106
|
+
## Changed
|
|
107
|
+
|
|
108
|
+
- Added preprocessor to avoid (other plugins) parsing errors on cds files
|
|
109
|
+
|
|
110
|
+
## [2.1.0] - 2021-09-23
|
|
111
|
+
|
|
112
|
+
## Changed
|
|
113
|
+
|
|
114
|
+
- Source code is now Javascript only
|
|
115
|
+
- Rule API simplified to only include report and cds
|
|
116
|
+
- Added new rules `no-db-keywords` and `require-2many-oncond`
|
|
117
|
+
- Filter out lint messages when run from command line with custom formatter
|
|
9
118
|
|
|
10
119
|
## [2.0.5] - 2021-07-18
|
|
11
120
|
|
|
121
|
+
|
|
12
122
|
### Added
|
|
13
123
|
|
|
14
124
|
- When used from within VS Code ESLint exnteion, do not show environment rules
|
|
@@ -201,4 +311,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
201
311
|
|
|
202
312
|
## [1.0.0] - 2020-12-07
|
|
203
313
|
|
|
204
|
-
- Initial release 1.0.0
|
|
314
|
+
- Initial release 1.0.0
|
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# @sap/eslint-plugin-cds
|
|
2
2
|
|
|
3
3
|
|
|
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.
|
|
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.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
<!-- See the [CDS Linting documentation](https://cap.cloud.sap/docs/get-started/tools/lint) for more details, or jump directly to a complete [list of rules](https://cap.cloud.sap/docs/get-started/tools/lint#rules). CAP provides a set of recommended rules. On top, you can create your own, application-specific rules. -->
|
|
6
|
+
See the [CDS Linting documentation](https://cap.cloud.sap/docs/tools/#cds-lint) for more details, or jump directly to a complete [list of rules](https://cap.cloud.sap/docs/tools/#cds-lint-rules). CAP provides a set of recommended rules. On top, you can create your own, application-specific rules.
|
package/lib/api/formatter.js
CHANGED
|
@@ -1,132 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Custom ESLint formatter:
|
|
3
|
+
* https://eslint.org/docs/developer-guide/working-with-custom-formatters
|
|
4
|
+
* Here, we take the ESLint.LintResult[] and format it into ESLint's standard (stylish) error report.
|
|
5
|
+
* Then, we adapt it to report environment errors:
|
|
6
|
+
* - Separately from model errors
|
|
7
|
+
* - Report them within a project scope but independent of a specific file within that scope
|
|
8
|
+
*/
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const formatter = require("eslint/lib/cli-engine/formatters/stylish");
|
|
12
|
+
|
|
13
|
+
const { Cache } = require("../impl/utils/model");
|
|
14
|
+
const { styleText, isEditor } = require("../impl/utils/helpers");
|
|
15
|
+
|
|
16
|
+
const CONSTANTS = require("../impl/constants");
|
|
17
|
+
/* eslint-disable-next-line no-control-regex */
|
|
18
|
+
const REGEX_STRIP_ANSI = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
19
|
+
const REGEX_NEWLINE = /\r?\n/g;
|
|
20
|
+
|
|
21
|
+
let projects = Cache.get('configpaths') || [];
|
|
22
|
+
|
|
23
|
+
module.exports = function (results, data) {
|
|
24
|
+
let output = "";
|
|
25
|
+
// Get plugin ruleIDs
|
|
26
|
+
const rules = getPluginRules(data);
|
|
27
|
+
// Get ruleIDs from custom rules
|
|
28
|
+
const customRules = [];
|
|
29
|
+
projects.forEach((project) => {
|
|
30
|
+
const customRulesPath = path.resolve(project, CONSTANTS.customRulesDir, "rules");
|
|
31
|
+
if (fs.existsSync(customRulesPath)) {
|
|
32
|
+
fs.readdirSync(customRulesPath).forEach((customRule) => {
|
|
33
|
+
const ruleID = path.basename(customRule, ".js");
|
|
34
|
+
if (!customRules.includes(ruleID)) {
|
|
35
|
+
customRules.push(ruleID);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (!Cache.has("err")) {
|
|
41
|
+
// Filter out error messages not from plugin or custom rules
|
|
42
|
+
if (!isEditor()) {
|
|
43
|
+
results.forEach((result) => {
|
|
44
|
+
result.messages = result.messages.filter(
|
|
45
|
+
(msg) =>
|
|
46
|
+
rules.model.includes(msg.ruleId) ||
|
|
47
|
+
rules.environment.includes(msg.ruleId) ||
|
|
48
|
+
customRules.includes(msg.ruleId)
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Get standard ESLint 'stylish' output
|
|
53
|
+
const outputStylish = formatter(results);
|
|
54
|
+
|
|
55
|
+
// Split according to category
|
|
56
|
+
const msgs = splitOutput(outputStylish, rules);
|
|
57
|
+
|
|
58
|
+
// Format new CDSLint output
|
|
59
|
+
output = formatOutput(output, msgs);
|
|
60
|
+
}
|
|
61
|
+
return output;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Splits rules by config and category
|
|
66
|
+
* @param data Rules meta data
|
|
67
|
+
* @returns rules object based on category
|
|
68
|
+
*/
|
|
69
|
+
function getPluginRules(data) {
|
|
70
|
+
const rules = { environment: [], model: [], recommended: [] };
|
|
71
|
+
Object.keys(data.rulesMeta).forEach((rule) => {
|
|
72
|
+
if (data.rulesMeta[rule]) {
|
|
73
|
+
const category = data.rulesMeta[rule].docs.category;
|
|
74
|
+
if (category === CONSTANTS.categories.model) {
|
|
75
|
+
rules.model.push(rule);
|
|
76
|
+
rules.recommended.push(rule);
|
|
77
|
+
} else if (category === CONSTANTS.categories.env) {
|
|
78
|
+
rules.environment.push(rule);
|
|
79
|
+
rules.recommended.push(rule);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return rules;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Obtains ESLint's standard (*stylish*) output, then splits and reccollects error messages
|
|
88
|
+
* based on rule category and content type (msg vs. error count/report)
|
|
89
|
+
* @param outputStylish ESLint's standard output
|
|
90
|
+
* @param rules Plugin rules based on category
|
|
91
|
+
* @returns Collected msgs
|
|
92
|
+
*/
|
|
93
|
+
function splitOutput(outputStylish, rules) {
|
|
94
|
+
const msgs = { environment: {}, model: {}, report: [] };
|
|
95
|
+
let file = "";
|
|
96
|
+
outputStylish.split(REGEX_NEWLINE).forEach((line) => {
|
|
97
|
+
const lineStripped = line.replace(REGEX_STRIP_ANSI, "");
|
|
98
|
+
// Collect model file (default)
|
|
99
|
+
const lineStrippedSplit = lineStripped.split(" ");
|
|
100
|
+
const rule = lineStrippedSplit[lineStrippedSplit.length - 1];
|
|
101
|
+
if (
|
|
102
|
+
!lineStripped.startsWith(" ") &&
|
|
103
|
+
!rules.recommended.includes(rule) &&
|
|
104
|
+
!lineStripped.startsWith("✖")
|
|
105
|
+
) {
|
|
106
|
+
file = line;
|
|
107
|
+
if (process.argv[1].includes("jest") || process.argv[1].includes("mocha")) {
|
|
108
|
+
projects = [path.dirname(lineStripped)];
|
|
109
|
+
}
|
|
110
|
+
} else if (rules.environment.includes(rule)) {
|
|
111
|
+
// Collect error/warning messages from @sap/cds/ rules
|
|
112
|
+
const delimiter = line.split(/ +/, 2)[1];
|
|
113
|
+
const lineWithoutLocation = line.split(delimiter)[1];
|
|
114
|
+
let project = "";
|
|
115
|
+
for (let i = 0; i < projects.length; i++) {
|
|
116
|
+
project = projects[i];
|
|
117
|
+
if (file.includes(project)) {
|
|
118
|
+
project = styleText(project, ["link"]);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (project) {
|
|
123
|
+
if (!Object.keys(msgs.environment).includes(project)) {
|
|
124
|
+
msgs.environment[project] = [lineWithoutLocation];
|
|
125
|
+
} else if (!msgs.environment[project].includes(lineWithoutLocation)) {
|
|
126
|
+
msgs.environment[project].push(lineWithoutLocation);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else if (
|
|
130
|
+
lineStripped &&
|
|
131
|
+
!rules.environment.includes(rule) &&
|
|
132
|
+
!lineStripped.includes("potentially fixable") &&
|
|
133
|
+
!lineStripped.startsWith("✖")
|
|
134
|
+
) {
|
|
135
|
+
if (lineStripped) {
|
|
136
|
+
if (!msgs.model[file]) {
|
|
137
|
+
msgs.model[file] = [line];
|
|
138
|
+
} else {
|
|
139
|
+
msgs.model[file].push(line);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
} else if (lineStripped.startsWith("✖") || lineStripped.includes("potentially fixable")) {
|
|
143
|
+
msgs.report.push(line);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return msgs;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Takes the collected error messages and collects them
|
|
151
|
+
* in a final string for ESLint to output
|
|
152
|
+
* @param output final string to output
|
|
153
|
+
* @param msgs error messages based on category
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
function formatOutput(output, msgs) {
|
|
157
|
+
// First, output model msgs per file (from ESLint 'stylish' output)
|
|
158
|
+
for (const fileModel in msgs.model) {
|
|
159
|
+
if (msgs.model[fileModel].length > 0) {
|
|
160
|
+
output += `${fileModel}\n`;
|
|
161
|
+
output += `${msgs.model[fileModel].join("\n")}\n\n`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Next, output env msgs (file-independent but associated to project)
|
|
165
|
+
for (const fileModel in msgs.environment) {
|
|
166
|
+
if (msgs.environment[fileModel].length > 0) {
|
|
167
|
+
output += `${fileModel}\n`;
|
|
168
|
+
output += `${msgs.environment[fileModel].join("\n")}\n\n`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Finally output error/warning report count
|
|
172
|
+
if (output && msgs.report) {
|
|
173
|
+
output += `${msgs.report.join("\n")}`;
|
|
174
|
+
}
|
|
175
|
+
if (output) {
|
|
176
|
+
output = `\n${output}`;
|
|
177
|
+
if (Cache.has('linted')) {
|
|
178
|
+
output += `\n\nTotal files linted: ${Cache.get('linted').files.length}\n`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return output;
|
|
182
|
+
}
|
package/lib/api/index.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Our custom ESLint plugin API should:
|
|
3
|
+
* - Expose 'createRule', 'defineRule' (experimental) and 'runRuleTester' to
|
|
4
|
+
* support the addition of *custom* CDS Lint rules
|
|
5
|
+
* - Expose 'getConfigPath', 'getFileExtensions', and 'genDocs' for usage in CDS Lint (@sap/cds-dk)
|
|
6
|
+
* - Expose 'parserPath' for CDS Lint rule unit tests with ESLint's ruleTester
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
createRule,
|
|
11
|
+
defineRule,
|
|
12
|
+
runRuleTester,
|
|
13
|
+
} = require("../impl/ruleFactory");
|
|
14
|
+
const { getConfigPath } = require("../impl/utils/model");
|
|
15
|
+
const { getFileExtensions } = require("../impl/utils/helpers");
|
|
16
|
+
const { genDocs } = require("../impl/utils/rules");
|
|
17
|
+
const parserPath = require.resolve("../impl/parser");
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
createRule,
|
|
21
|
+
defineRule,
|
|
22
|
+
runRuleTester,
|
|
23
|
+
getConfigPath,
|
|
24
|
+
getFileExtensions,
|
|
25
|
+
genDocs,
|
|
26
|
+
parserPath,
|
|
27
|
+
};
|
package/lib/impl/constants.js
CHANGED
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"@sap/cds/
|
|
20
|
-
"@sap/cds/assocs-card-flaw": 1,
|
|
1
|
+
/**
|
|
2
|
+
* This file contains all constants for:
|
|
3
|
+
* - categories: The category labels we use to for model and environment rules
|
|
4
|
+
* - customRulesDir: The custom rules directory name in the user's project home
|
|
5
|
+
* which contains the subdirs 'docs', 'rules' and 'tests'
|
|
6
|
+
* - recommended: The set of this plugin's recommended rules and their severities
|
|
7
|
+
* - globals: The globals which should be exposed to ESLint by this plugin
|
|
8
|
+
* - files: Any additional file extensions which ESLint should lint
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
categories: {
|
|
13
|
+
env: "Environment",
|
|
14
|
+
model: "Model Validation",
|
|
15
|
+
},
|
|
16
|
+
customRulesDir: ".eslint",
|
|
17
|
+
recommended: {
|
|
18
|
+
"@sap/cds/assoc2many-ambiguous-key": 1,
|
|
19
|
+
"@sap/cds/cds-compile-error": 2,
|
|
21
20
|
"@sap/cds/min-node-version": 2,
|
|
22
|
-
"@sap/cds/
|
|
21
|
+
"@sap/cds/no-join-on-draft-enabled-entities": 1,
|
|
22
|
+
"@sap/cds/no-db-keywords": 2,
|
|
23
|
+
"@sap/cds/require-2many-oncond": 2,
|
|
24
|
+
"@sap/cds/sql-cast-suggestion": 1,
|
|
25
|
+
},
|
|
26
|
+
globals: {
|
|
27
|
+
SELECT: true,
|
|
28
|
+
INSERT: true,
|
|
29
|
+
UPDATE: true,
|
|
30
|
+
DELETE: true,
|
|
31
|
+
CREATE: true,
|
|
32
|
+
DROP: true,
|
|
33
|
+
CDL: true,
|
|
34
|
+
CQL: true,
|
|
35
|
+
CXL: true,
|
|
36
|
+
cds: true,
|
|
37
|
+
},
|
|
38
|
+
files: ["*.cds", "*.csn"],
|
|
39
|
+
modelFiles: ["*.cds", "*.csn"],
|
|
23
40
|
};
|
|
24
|
-
Constants.globals = {
|
|
25
|
-
"SELECT": true,
|
|
26
|
-
"INSERT": true,
|
|
27
|
-
"UPDATE": true,
|
|
28
|
-
"DELETE": true,
|
|
29
|
-
"CREATE": true,
|
|
30
|
-
"DROP": true,
|
|
31
|
-
"CDL": true,
|
|
32
|
-
"CQL": true,
|
|
33
|
-
"CXL": true,
|
|
34
|
-
"cds": true
|
|
35
|
-
};
|
|
36
|
-
Constants.overrides = [
|
|
37
|
-
{
|
|
38
|
-
"files": ["*.cds", "*.csn"],
|
|
39
|
-
"parser": "./parser",
|
|
40
|
-
"parserOptions": {
|
|
41
|
-
"ecmaVersion": 2019,
|
|
42
|
-
"sourceType": "module"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
//# sourceMappingURL=constants.js.map
|