From 86f2d6681c9715cc5646bfd92f7412711fdb0347 Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 21 Aug 2025 15:36:04 +0200 Subject: [PATCH 1/2] Migrate to eslint9 --- .eslintrc | 16 ---------------- eslint.config.mjs | 36 ++++++++++++++++++++++++++++++++++++ lib/compile/csdl2openapi.js | 18 +++++++++--------- package.json | 4 ++-- 4 files changed, 47 insertions(+), 27 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index faca7bc..0000000 --- a/.eslintrc +++ /dev/null @@ -1,16 +0,0 @@ - -{ - "env": { - "jest": true, - "es6": true, - "node": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": "latest" - }, - "rules": { - "no-unused-vars": ["warn", { "argsIgnorePattern": "lazy" }], - "no-extra-semi": 1 - } -} \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..482c923 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,36 @@ +import js from '@eslint/js'; +import globals from 'globals' +/* +export default [ + js.config({ + env: { + jest: true, + es6: true, + node: true, + }, + parserOptions: { + ecmaVersion: 'latest', + }, + rules: { + 'no-unused-vars': ['warn', { argsIgnorePattern: 'lazy' }], + 'no-extra-semi': 1, + }, + }), +]; +*/ + +export default [ + js.configs.recommended, + { + languageOptions: { + globals: { + ...globals.node, + ...globals.jest + } + }, + rules: { + 'no-unused-vars': ['warn', { argsIgnorePattern: 'lazy' }], + 'no-extra-semi': 1, + }, + } +] \ No newline at end of file diff --git a/lib/compile/csdl2openapi.js b/lib/compile/csdl2openapi.js index d09d545..a688f2b 100644 --- a/lib/compile/csdl2openapi.js +++ b/lib/compile/csdl2openapi.js @@ -3,7 +3,7 @@ */ const cds = require('@sap/cds'); var pluralize = require('pluralize') -const DEBUG = cds.debug('openapi'); // Initialize cds.debug with the 'openapi' +const DEBUG = cds.debug('openapi'); // Initialize cds.debug with the 'openapi' //TODO @@ -171,14 +171,14 @@ module.exports.csdl2openapi = function ( } let extensionEnums = { "x-sap-compliance-level": {allowedValues: ["sap:base:v1", "sap:core:v1", "sap:core:v2" ] } , - "x-sap-api-type": {allowedValues: [ "ODATA", "ODATAV4", "REST" , "SOAP"] }, + "x-sap-api-type": {allowedValues: [ "ODATA", "ODATAV4", "REST" , "SOAP"] }, "x-sap-direction": {allowedValues: ["inbound", "outbound", "mixed"] , default : "inbound" }, "x-sap-dpp-entity-semantics": {allowedValues: ["sap:DataSubject", "sap:DataSubjectDetails", "sap:Other"] }, "x-sap-dpp-field-semantics": {allowedValues: ["sap:DataSubjectID", "sap:ConsentID", "sap:PurposeID", "sap:ContractRelatedID", "sap:LegalEntityID", "sap:DataControllerID", "sap:UserID", "sap:EndOfBusinessDate", "sap:BlockingDate", "sap:EndOfRetentionDate"] }, }; checkForExtentionEnums(extensionObj, extensionEnums); - let extenstionSchema = { + let extenstionSchema = { "x-sap-stateInfo": ['state', 'deprecationDate', 'decomissionedDate', 'link'], "x-sap-ext-overview": ['name', 'values'], "x-sap-deprecated-operation" : ['deprecationDate', 'successorOperationRef', "successorOperationId"], @@ -223,9 +223,9 @@ module.exports.csdl2openapi = function ( if (resObj[openapiProperty] === undefined) { resObj[openapiProperty] = {}; } - + let node = resObj[openapiProperty]; - + // traverse the annotation property and define the objects if they're not defined for (let nestedIndex = 1; nestedIndex < keys.length - 1; nestedIndex++) { const nestedElement = keys[nestedIndex]; @@ -234,11 +234,11 @@ module.exports.csdl2openapi = function ( } node = node[nestedElement]; } - + // set value annotation property node[keys[keys.length - 1]] = value; } - + if (!csdl.$EntityContainer) { delete openapi.servers; delete openapi.tags; @@ -601,7 +601,7 @@ module.exports.csdl2openapi = function ( if (serversObject) { try { servers = JSON.parse(serversObject); - } catch (err) { + } catch { throw new Error(`The input server object is invalid.`); } @@ -2664,5 +2664,5 @@ see [Expand](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-prot function isIdentifier(name) { return !name.startsWith('$') && !name.includes('@'); } - + }; diff --git a/package.json b/package.json index 327d5be..657475b 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@sap/cds": ">=7.6" }, "devDependencies": { - "jest": ">=29", - "eslint": "^8.56.0" + "eslint": "^9.33.0", + "jest": ">=29" } } From 22b338c51d9cd6940f9b4f97d451155f2dd26a7c Mon Sep 17 00:00:00 2001 From: Daniel O'Grady Date: Thu, 21 Aug 2025 15:38:00 +0200 Subject: [PATCH 2/2] Remove comments --- eslint.config.mjs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 482c923..6b07733 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,23 +1,5 @@ import js from '@eslint/js'; import globals from 'globals' -/* -export default [ - js.config({ - env: { - jest: true, - es6: true, - node: true, - }, - parserOptions: { - ecmaVersion: 'latest', - }, - rules: { - 'no-unused-vars': ['warn', { argsIgnorePattern: 'lazy' }], - 'no-extra-semi': 1, - }, - }), -]; -*/ export default [ js.configs.recommended,