diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 74d6149..0000000 --- a/.eslintrc +++ /dev/null @@ -1,26 +0,0 @@ -{ - "extends": "eslint:recommended", - "env": { - "es2022": true, - "node": true, - "jest": true, - "mocha": true - }, - "globals": { - "SELECT": true, - "INSERT": true, - "UPSERT": true, - "UPDATE": true, - "DELETE": true, - "CREATE": true, - "DROP": true, - "CDL": true, - "CQL": true, - "CXL": true, - "cds": true - }, - "rules": { - "no-console": "off", - "require-atomic-updates": "off" - } -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d21adb..74d56bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,12 @@ on: branches: [ main ] jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: npm i + - run: npm run lint test: runs-on: ubuntu-latest strategy: @@ -25,7 +31,6 @@ jobs: - run: npm i - run: npm i @sap/cds@${{ matrix.cds-version }} - run: cds v - - run: npm run lint - run: npm run test env: ALS_CREDS_OAUTH2: ${{ secrets.ALS_CREDS_OAUTH2 }} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..0d250b2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,2 @@ +import cds from '@sap/cds/eslint.config.mjs' +export default [...cds.recommended] diff --git a/lib/utils.js b/lib/utils.js index 1929982..207dfd2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,3 +1,5 @@ +const cds = require('@sap/cds') + const WRITE = { CREATE: 1, UPDATE: 1, DELETE: 1 } const $hasPersonalData = Symbol('@cap-js/audit-logging:hasPersonalData') diff --git a/package.json b/package.json index a0a23f3..5480289 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint": "npx eslint .", "test": "npm run test-new-db && npm run test-old-db", "test-new-db": "CDS_ENV='better-sqlite' npx jest --silent", - "test-old-db": "npx jest --silent" + "test-old-db": "CDS_ENV='legacy-sqlite' npx jest --silent" }, "peerDependencies": { "@sap/cds": ">=7" @@ -25,7 +25,7 @@ "@cap-js/audit-logging": "file:.", "@cap-js/sqlite": "^1", "axios": "^1", - "eslint": "^8", + "eslint": "^9", "express": "^4", "jest": "^29", "sqlite3": "^5.1.6" diff --git a/srv/log2console.js b/srv/log2console.js index f024736..c340a9a 100644 --- a/srv/log2console.js +++ b/srv/log2console.js @@ -5,6 +5,7 @@ module.exports = class AuditLog2Console extends AuditLogService { this.on('*', function (req) { const { event, data } = req + // eslint-disable-next-line no-console console.log(`[audit-log] - ${event}:`, data) }) diff --git a/test/api/MyAuditLogService.js b/test/api/MyAuditLogService.js index b16e4f1..fcf1376 100644 --- a/test/api/MyAuditLogService.js +++ b/test/api/MyAuditLogService.js @@ -5,6 +5,7 @@ class MyAuditLogService extends AuditLogService { this.on('*', function (req) { const { event, data } = req + // eslint-disable-next-line no-console console.log(`[my-audit-log] - ${event}:`, data) }) diff --git a/test/api/srv/api-service.js b/test/api/srv/api-service.js index d9a11f7..aa8aaa2 100644 --- a/test/api/srv/api-service.js +++ b/test/api/srv/api-service.js @@ -1,3 +1,5 @@ +const cds = require('@sap/cds') + module.exports = async function () { const audit = await cds.connect.to('audit-log') diff --git a/test/integration/srv/integration-service.js b/test/integration/srv/integration-service.js index 98c799e..ca96d8b 100644 --- a/test/integration/srv/integration-service.js +++ b/test/integration/srv/integration-service.js @@ -1,3 +1,5 @@ +const cds = require('@sap/cds') + module.exports = async function () { const audit = await cds.connect.to('audit-log') diff --git a/test/jest.setup.js b/test/jest.setup.js index 43905f3..7b6066d 100644 --- a/test/jest.setup.js +++ b/test/jest.setup.js @@ -4,7 +4,7 @@ function toContainMatchObject(received, expected) { try { expect(each).toMatchObject(expected) pass = true - } catch (e) { + } catch { // ignore }