mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-18 01:18:23 +02:00
refactor: replace ts-ignore with ts-expect-error (#1675)
* refactor: replace ts-ignore with ts-expect-error * refactor: remove unused ts-expect-errors
This commit is contained in:
parent
9aa1f39add
commit
ee35c7ad74
@ -1,5 +1,5 @@
|
|||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
const pck = require('../package.json');
|
const pck = require('../package.json');
|
||||||
|
|
||||||
const newUnleashVersion = process.argv[2];
|
const newUnleashVersion = process.argv[2];
|
||||||
|
@ -185,7 +185,7 @@ class EventStore extends EventEmitter implements IEventStore {
|
|||||||
created_by: e.createdBy,
|
created_by: e.createdBy,
|
||||||
data: e.data,
|
data: e.data,
|
||||||
pre_data: e.preData,
|
pre_data: e.preData,
|
||||||
//@ts-ignore workaround for json-array
|
// @ts-expect-error workaround for json-array
|
||||||
tags: JSON.stringify(e.tags),
|
tags: JSON.stringify(e.tags),
|
||||||
feature_name: e.featureName,
|
feature_name: e.featureName,
|
||||||
project: e.project,
|
project: e.project,
|
||||||
|
@ -292,7 +292,7 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
|
|||||||
featureToggle.environments = Object.values(
|
featureToggle.environments = Object.values(
|
||||||
featureToggle.environments,
|
featureToggle.environments,
|
||||||
).sort((a, b) => {
|
).sort((a, b) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
return a.sortOrder - b.sortOrder;
|
return a.sortOrder - b.sortOrder;
|
||||||
});
|
});
|
||||||
featureToggle.environments = featureToggle.environments.map((e) => {
|
featureToggle.environments = featureToggle.environments.map((e) => {
|
||||||
|
@ -84,7 +84,6 @@ class ProjectStore implements IProjectStore {
|
|||||||
}
|
}
|
||||||
const projectAndFeatureCount = await projects;
|
const projectAndFeatureCount = await projects;
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const projectsWithFeatureCount = projectAndFeatureCount.map(
|
const projectsWithFeatureCount = projectAndFeatureCount.map(
|
||||||
this.mapProjectWithCountRow,
|
this.mapProjectWithCountRow,
|
||||||
);
|
);
|
||||||
|
@ -149,11 +149,11 @@ export default class MetricsMonitor {
|
|||||||
for (const entry of Object.entries(m.bucket.toggles)) {
|
for (const entry of Object.entries(m.bucket.toggles)) {
|
||||||
featureToggleUsageTotal
|
featureToggleUsageTotal
|
||||||
.labels(entry[0], 'true', m.appName)
|
.labels(entry[0], 'true', m.appName)
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.inc(entry[1].yes);
|
.inc(entry[1].yes);
|
||||||
featureToggleUsageTotal
|
featureToggleUsageTotal
|
||||||
.labels(entry[0], 'false', m.appName)
|
.labels(entry[0], 'false', m.appName)
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.inc(entry[1].no);
|
.inc(entry[1].no);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,7 @@ function demoAuthentication(
|
|||||||
email,
|
email,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
req.session.user = user;
|
req.session.user = user;
|
||||||
return res.status(200).json(user);
|
return res.status(200).json(user);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -29,18 +29,18 @@ function demoAuthentication(
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.use(`${basePath}/api/admin/`, (req, res, next) => {
|
app.use(`${basePath}/api/admin/`, (req, res, next) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
if (req.session.user && req.session.user.email) {
|
if (req.session.user && req.session.user.email) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
req.user = req.session.user;
|
req.user = req.session.user;
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(`${basePath}/api/client`, (req, res, next) => {
|
app.use(`${basePath}/api/client`, (req, res, next) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
if (!authentication.enableApiToken && !req.user) {
|
if (!authentication.enableApiToken && !req.user) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
req.user = new ApiUser({
|
req.user = new ApiUser({
|
||||||
username: 'unauthed-default-client',
|
username: 'unauthed-default-client',
|
||||||
permissions: [],
|
permissions: [],
|
||||||
@ -53,7 +53,7 @@ function demoAuthentication(
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.use(`${basePath}/api`, (req, res, next) => {
|
app.use(`${basePath}/api`, (req, res, next) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import NoAuthUser from '../types/no-auth-user';
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
function noneAuthentication(basePath = '', app: Application): void {
|
function noneAuthentication(basePath = '', app: Application): void {
|
||||||
app.use(`${basePath}/api/admin/`, (req, res, next) => {
|
app.use(`${basePath}/api/admin/`, (req, res, next) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
if (!req.user) {
|
if (!req.user) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
req.user = new NoAuthUser();
|
req.user = new NoAuthUser();
|
||||||
|
@ -18,7 +18,7 @@ function sessionDb(
|
|||||||
store = new KnexSessionStore({
|
store = new KnexSessionStore({
|
||||||
tablename: 'unleash_session',
|
tablename: 'unleash_session',
|
||||||
createtable: false,
|
createtable: false,
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
knex,
|
knex,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,14 +45,14 @@ class StateController extends Controller {
|
|||||||
const { drop, keep } = req.query;
|
const { drop, keep } = req.query;
|
||||||
// TODO: Should override request type so file is a type on request
|
// TODO: Should override request type so file is a type on request
|
||||||
let data;
|
let data;
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
if (mime.getType(req.file.originalname) === 'text/yaml') {
|
if (mime.getType(req.file.originalname) === 'text/yaml') {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
data = YAML.load(req.file.buffer);
|
data = YAML.load(req.file.buffer);
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
data = JSON.parse(req.file.buffer);
|
data = JSON.parse(req.file.buffer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,13 +57,12 @@ export default class FeatureController extends Controller {
|
|||||||
this.get('/:featureName', this.getFeatureToggle);
|
this.get('/:featureName', this.getFeatureToggle);
|
||||||
|
|
||||||
if (experimental && experimental.clientFeatureMemoize) {
|
if (experimental && experimental.clientFeatureMemoize) {
|
||||||
// @ts-ignore
|
|
||||||
this.cache = experimental.clientFeatureMemoize.enabled;
|
this.cache = experimental.clientFeatureMemoize.enabled;
|
||||||
this.cachedFeatures = memoizee(
|
this.cachedFeatures = memoizee(
|
||||||
(query) => this.resolveFeaturesAndSegments(query),
|
(query) => this.resolveFeaturesAndSegments(query),
|
||||||
{
|
{
|
||||||
promise: true,
|
promise: true,
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
maxAge: experimental.clientFeatureMemoize.maxAge,
|
maxAge: experimental.clientFeatureMemoize.maxAge,
|
||||||
normalizer(args) {
|
normalizer(args) {
|
||||||
// args is arguments object as accessible in memoized function
|
// args is arguments object as accessible in memoized function
|
||||||
|
@ -27,7 +27,7 @@ export const handleErrors: (
|
|||||||
error: Error,
|
error: Error,
|
||||||
) => void = (res, logger, error) => {
|
) => void = (res, logger, error) => {
|
||||||
logger.warn(error.message);
|
logger.warn(error.message);
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
error.isJoi = true;
|
error.isJoi = true;
|
||||||
|
|
||||||
|
@ -630,7 +630,6 @@ class FeatureToggleService {
|
|||||||
newToggle.environments.forEach((e: IEnvironmentDetail) =>
|
newToggle.environments.forEach((e: IEnvironmentDetail) =>
|
||||||
e.strategies.forEach((s: IStrategyConfig) => {
|
e.strategies.forEach((s: IStrategyConfig) => {
|
||||||
if (replaceGroupId && s.parameters.hasOwnProperty('groupId')) {
|
if (replaceGroupId && s.parameters.hasOwnProperty('groupId')) {
|
||||||
//@ts-ignore
|
|
||||||
s.parameters.groupId = newFeatureName;
|
s.parameters.groupId = newFeatureName;
|
||||||
}
|
}
|
||||||
delete s.id;
|
delete s.id;
|
||||||
|
@ -97,7 +97,7 @@ export default async function init(
|
|||||||
|
|
||||||
await db.raw(`DROP SCHEMA IF EXISTS ${config.db.schema} CASCADE`);
|
await db.raw(`DROP SCHEMA IF EXISTS ${config.db.schema} CASCADE`);
|
||||||
await db.raw(`CREATE SCHEMA IF NOT EXISTS ${config.db.schema}`);
|
await db.raw(`CREATE SCHEMA IF NOT EXISTS ${config.db.schema}`);
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
await migrateDb({ ...config, databaseSchema: config.db.schema });
|
await migrateDb({ ...config, databaseSchema: config.db.schema });
|
||||||
await db.destroy();
|
await db.destroy();
|
||||||
const testDb = createDb(config);
|
const testDb = createDb(config);
|
||||||
|
@ -11,7 +11,7 @@ export default class FakeClientApplicationsStore
|
|||||||
apps: IClientApplication[] = [];
|
apps: IClientApplication[] = [];
|
||||||
|
|
||||||
async bulkUpsert(details: Partial<IClientApplication>[]): Promise<void> {
|
async bulkUpsert(details: Partial<IClientApplication>[]): Promise<void> {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
details.forEach((d) => this.apps.push(d));
|
details.forEach((d) => this.apps.push(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
src/test/fixtures/fake-user-store.ts
vendored
4
src/test/fixtures/fake-user-store.ts
vendored
@ -82,14 +82,14 @@ class UserStoreMock implements IUserStore {
|
|||||||
|
|
||||||
async setPasswordHash(userId: number, passwordHash: string): Promise<void> {
|
async setPasswordHash(userId: number, passwordHash: string): Promise<void> {
|
||||||
const u = this.data.find((a) => a.id === userId);
|
const u = this.data.find((a) => a.id === userId);
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
u.passwordHash = passwordHash;
|
u.passwordHash = passwordHash;
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPasswordHash(id: number): Promise<string> {
|
async getPasswordHash(id: number): Promise<string> {
|
||||||
const u = this.data.find((i) => i.id === id);
|
const u = this.data.find((i) => i.id === id);
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
return Promise.resolve(u.passwordHash);
|
return Promise.resolve(u.passwordHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user