From 5f83fbc43d7157a52548e9226bbfd941b1423230 Mon Sep 17 00:00:00 2001 From: Clint Checketts Date: Mon, 22 Feb 2021 22:20:10 -0700 Subject: [PATCH] chore: Add eslint rules and fix strings to pass rules --- .eslintrc | 11 +++++++++-- src/lib/addons/jira-comment.js | 2 +- src/lib/options.js | 2 +- src/lib/routes/admin-api/metrics.test.js | 2 +- src/lib/routes/admin-api/strategy.test.js | 2 +- src/lib/services/state-service.js | 4 ++-- .../20190123204125-add-variants-to-features.js | 2 +- src/migrations/20210119084617-add-addon-table.js | 2 +- ...10121115438-add-deprecated-column-to-strategies.js | 2 +- src/test/e2e/api/admin/addon.e2e.test.js | 6 +++--- .../e2e/api/admin/feature.custom-auth.e2e.test.js | 2 +- 11 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.eslintrc b/.eslintrc index f01bda98b1..1d12ab0bf5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,12 +9,16 @@ ], "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": 2019 + "ecmaVersion": 2019, + "project": "./tsconfig.json" }, "plugins": ["prettier","@typescript-eslint"], "root": true, "rules": { "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/indent": 0, + "@typescript-eslint/naming-convention": 0, + "@typescript-eslint/space-before-function-paren": 0, "import/no-unresolved": 0, "class-methods-use-this": [0], "prettier/prettier": ["error"], @@ -40,7 +44,10 @@ // enable the rule specifically for TypeScript files "files": ["*.ts", "*.tsx"], "rules": { - "@typescript-eslint/explicit-module-boundary-types": ["error"] + "@typescript-eslint/explicit-module-boundary-types": ["error"], + "@typescript-eslint/indent": ["error"], + "@typescript-eslint/naming-convention": ["error"], + "@typescript-eslint/space-before-function-paren": ["error"] } } ], diff --git a/src/lib/addons/jira-comment.js b/src/lib/addons/jira-comment.js index c20d0f733f..4ae4ad6ce2 100644 --- a/src/lib/addons/jira-comment.js +++ b/src/lib/addons/jira-comment.js @@ -86,7 +86,7 @@ class JiraAddon extends Addon { content: [ { type: 'text', - text: `To see what happened visit Unleash`, + text: 'To see what happened visit Unleash', marks: [ { type: 'link', diff --git a/src/lib/options.js b/src/lib/options.js index 0d311367b4..12cd6c45aa 100644 --- a/src/lib/options.js +++ b/src/lib/options.js @@ -113,7 +113,7 @@ module.exports = { if (!options.db.host) { throw new Error( - `Unleash requires database details to start. See https://unleash.github.io/docs/getting_started`, + 'Unleash requires database details to start. See https://unleash.github.io/docs/getting_started', ); } diff --git a/src/lib/routes/admin-api/metrics.test.js b/src/lib/routes/admin-api/metrics.test.js index 7291f8ac30..47f1a311b1 100644 --- a/src/lib/routes/admin-api/metrics.test.js +++ b/src/lib/routes/admin-api/metrics.test.js @@ -124,7 +124,7 @@ test('should return applications', t => { stores.clientApplicationsStore.upsert({ appName }); return request - .get(`/api/admin/metrics/applications/`) + .get('/api/admin/metrics/applications/') .expect(200) .expect(res => { const metrics = res.body; diff --git a/src/lib/routes/admin-api/strategy.test.js b/src/lib/routes/admin-api/strategy.test.js index 1a9d9b2a62..39bb9eb46c 100644 --- a/src/lib/routes/admin-api/strategy.test.js +++ b/src/lib/routes/admin-api/strategy.test.js @@ -252,7 +252,7 @@ test('reactivating a non-existent strategy yields 404', t => { .set('Content-Type', 'application/json') .expect(404); }); -test(`deprecating 'default' strategy will yield 403`, t => { +test("deprecating 'default' strategy will yield 403", t => { t.plan(0); const { request, base, perms } = getSetup(); perms.withPermissions(UPDATE_STRATEGY); diff --git a/src/lib/services/state-service.js b/src/lib/services/state-service.js index df26e0c3fe..bdf6589557 100644 --- a/src/lib/services/state-service.js +++ b/src/lib/services/state-service.js @@ -63,7 +63,7 @@ class StateService { : await this.toggleStore.getFeatures(); if (dropBeforeImport) { - this.logger.info(`Dropping existing feature toggles`); + this.logger.info('Dropping existing feature toggles'); await this.toggleStore.dropFeatures(); await this.eventStore.store({ type: DROP_FEATURES, @@ -100,7 +100,7 @@ class StateService { : await this.strategyStore.getStrategies(); if (dropBeforeImport) { - this.logger.info(`Dropping existing strategies`); + this.logger.info('Dropping existing strategies'); await this.strategyStore.dropStrategies(); await this.eventStore.store({ type: DROP_STRATEGIES, diff --git a/src/migrations/20190123204125-add-variants-to-features.js b/src/migrations/20190123204125-add-variants-to-features.js index 594bdc258e..f55ac57cc7 100644 --- a/src/migrations/20190123204125-add-variants-to-features.js +++ b/src/migrations/20190123204125-add-variants-to-features.js @@ -11,5 +11,5 @@ exports.up = function(db, callback) { }; exports.down = function(db, callback) { - db.runSql(`ALTER TABLE features DROP COLUMN "variants";`, callback); + db.runSql('ALTER TABLE features DROP COLUMN "variants";', callback); }; diff --git a/src/migrations/20210119084617-add-addon-table.js b/src/migrations/20210119084617-add-addon-table.js index 0b149b9760..d802d61202 100644 --- a/src/migrations/20210119084617-add-addon-table.js +++ b/src/migrations/20210119084617-add-addon-table.js @@ -16,5 +16,5 @@ exports.up = function(db, cb) { }; exports.down = function(db, cb) { - db.runSql(`DROP TABLE addons;`, cb); + db.runSql('DROP TABLE addons;', cb); }; diff --git a/src/migrations/20210121115438-add-deprecated-column-to-strategies.js b/src/migrations/20210121115438-add-deprecated-column-to-strategies.js index 313a5fc279..3f22836e74 100644 --- a/src/migrations/20210121115438-add-deprecated-column-to-strategies.js +++ b/src/migrations/20210121115438-add-deprecated-column-to-strategies.js @@ -10,7 +10,7 @@ exports.up = function(db, cb) { }; exports.down = function(db, cb) { - db.runSql(`ALTER TABLE strategies DROP COLUMN deprecated`, cb); + db.runSql('ALTER TABLE strategies DROP COLUMN deprecated', cb); }; exports._meta = { diff --git a/src/test/e2e/api/admin/addon.e2e.test.js b/src/test/e2e/api/admin/addon.e2e.test.js index ebab5d14d7..4aa10d45bc 100644 --- a/src/test/e2e/api/admin/addon.e2e.test.js +++ b/src/test/e2e/api/admin/addon.e2e.test.js @@ -146,7 +146,7 @@ test.serial('should not update with invalid addon configuration', async t => { }; await request - .put(`/api/admin/addons/1`) + .put('/api/admin/addons/1') .send(config) .expect(400); }); @@ -166,7 +166,7 @@ test.serial('should not update unknown addon configuration', async t => { }; await request - .put(`/api/admin/addons/123123`) + .put('/api/admin/addons/123123') .send(config) .expect(404); }); @@ -209,7 +209,7 @@ test.serial('should not get unknown addon configuration', async t => { t.plan(0); const request = await setupApp(stores); - await request.get(`/api/admin/addons/445`).expect(404); + await request.get('/api/admin/addons/445').expect(404); }); test.serial('should not delete unknown addon configuration', async t => { diff --git a/src/test/e2e/api/admin/feature.custom-auth.e2e.test.js b/src/test/e2e/api/admin/feature.custom-auth.e2e.test.js index e67b7b43f1..e45232de1f 100644 --- a/src/test/e2e/api/admin/feature.custom-auth.e2e.test.js +++ b/src/test/e2e/api/admin/feature.custom-auth.e2e.test.js @@ -29,7 +29,7 @@ test.serial('should require authenticated user', async t => { new AuthenticationRequired({ path: '/api/admin/login', type: 'custom', - message: `You have to identify yourself.`, + message: 'You have to identify yourself.', }), ) .end(),