diff --git a/.eslintrc.js b/.eslintrc similarity index 78% rename from .eslintrc.js rename to .eslintrc index 8df4201d..754a9f38 100644 --- a/.eslintrc.js +++ b/.eslintrc @@ -1,16 +1,16 @@ -module.exports = { +{ "env": { "browser": true, "commonjs": true, "es2021": true, - "node": true + "node": true, + "mocha": true }, "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended" ], "ignorePatterns": [ - "test/**/*.js" ], "overrides": [ { @@ -33,5 +33,12 @@ module.exports = { "@typescript-eslint" ], "rules": { + "quotes": [ + "error", + "double", + { + "avoidEscape": true + } + ], }, -} +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24198077..613b189e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,5 +23,6 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci + - run: npm run lint - run: npm run build - run: npm test diff --git a/package.json b/package.json index f19d377a..ee5ed2a9 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "build-esm": "tsc -p ./", "clean": "rimraf dist dist-esm", "dev": "rollup --config --watch", - "lint": "eslint", + "lint": "eslint src/ test/", + "fix-lint": "eslint src/ test/ --fix", "test": "mocha --timeout 10000" }, "repository": { diff --git a/src/Load.ts b/src/Load.ts index a4758c5c..e60417f0 100644 --- a/src/Load.ts +++ b/src/Load.ts @@ -28,7 +28,7 @@ export async function load( try { endpoint = new URL(endpoint); } catch (error) { - if (error.code === 'ERR_INVALID_URL') { + if (error.code === "ERR_INVALID_URL") { throw new Error("Invalid Endpoint URL.", { cause: error }); } else { throw error; diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000..a9331162 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/no-var-requires": "off" + } +} \ No newline at end of file diff --git a/test/clientOptions.test.js b/test/clientOptions.test.js index e2aa5fc9..ebd615b2 100644 --- a/test/clientOptions.test.js +++ b/test/clientOptions.test.js @@ -7,7 +7,7 @@ chai.use(chaiAsPromised); const expect = chai.expect; const { load } = require("../dist/index"); const { createMockedConnectionString } = require("./utils/testHelper"); -const nock = require('nock'); +const nock = require("nock"); class HttpRequestCountPolicy { constructor() { @@ -21,7 +21,7 @@ class HttpRequestCountPolicy { resetCount() { this.count = 0; } -}; +} describe("custom client options", function () { const fakeEndpoint = "https://azure.azconfig.io"; diff --git a/test/keyvault.test.js b/test/keyvault.test.js index 3332512a..02d676d7 100644 --- a/test/keyvault.test.js +++ b/test/keyvault.test.js @@ -20,11 +20,13 @@ const mockedData = [ ]; function mockAppConfigurationClient() { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const kvs = mockedData.map(([key, vaultUri, _value]) => createMockedKeyVaultReference(key, vaultUri)); mockAppConfigurationClientListConfigurationSettings(kvs); } function mockNewlyCreatedKeyVaultSecretClients() { + // eslint-disable-next-line @typescript-eslint/no-unused-vars mockSecretClientGetSecret(mockedData.map(([_key, secretUri, value]) => [secretUri, value])); } describe("key vault reference", function () { diff --git a/test/load.test.js b/test/load.test.js index 1ff74c3c..5a8682a9 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -15,49 +15,49 @@ const { } = require("./utils/testHelper"); const mockedKVs = [{ - value: 'red', - key: 'app.settings.fontColor', + value: "red", + key: "app.settings.fontColor", label: null, - contentType: '', - lastModified: '2023-05-04T04:34:24.000Z', + contentType: "", + lastModified: "2023-05-04T04:34:24.000Z", tags: {}, - etag: '210fjkPIWZMjFTi_qyEEmmsJjtUjj0YQl-Y3s1m6GLw', + etag: "210fjkPIWZMjFTi_qyEEmmsJjtUjj0YQl-Y3s1m6GLw", isReadOnly: false }, { - value: '40', - key: 'app.settings.fontSize', + value: "40", + key: "app.settings.fontSize", label: null, - contentType: '', - lastModified: '2023-05-04T04:32:56.000Z', + contentType: "", + lastModified: "2023-05-04T04:32:56.000Z", tags: {}, - etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk', + etag: "GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk", isReadOnly: false }, { - value: 'TestValue', - key: 'TestKey', - label: 'Test', - contentType: '', - lastModified: '2023-05-04T04:32:56.000Z', + value: "TestValue", + key: "TestKey", + label: "Test", + contentType: "", + lastModified: "2023-05-04T04:32:56.000Z", tags: {}, - etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk', + etag: "GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk", isReadOnly: false }, { value: null, - key: 'KeyForNullValue', - label: '', - contentType: '', - lastModified: '2023-05-04T04:32:56.000Z', + key: "KeyForNullValue", + label: "", + contentType: "", + lastModified: "2023-05-04T04:32:56.000Z", tags: {}, - etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk', + etag: "GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk", isReadOnly: false }, { value: "", - key: 'KeyForEmptyValue', - label: '', - contentType: '', - lastModified: '2023-05-04T04:32:56.000Z', + key: "KeyForEmptyValue", + label: "", + contentType: "", + lastModified: "2023-05-04T04:32:56.000Z", tags: {}, - etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk', + etag: "GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk", isReadOnly: false }]; diff --git a/test/utils/testHelper.js b/test/utils/testHelper.js index 8c26ccc1..4f0525ba 100644 --- a/test/utils/testHelper.js +++ b/test/utils/testHelper.js @@ -52,7 +52,7 @@ const createMockedTokenCredential = (tenantId = TEST_TENANT_ID, clientId = TEST_ const createMockedKeyVaultReference = (key, vaultUri) => ({ // https://${vaultName}.vault.azure.net/secrets/${secretName} - value: `{\"uri\":\"${vaultUri}\"}`, + value: `{"uri":"${vaultUri}"}`, key, label: null, contentType: "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",