1
0
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:
olav 2022-06-07 11:49:17 +02:00 committed by GitHub
parent 9aa1f39add
commit ee35c7ad74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 23 additions and 26 deletions

View File

@ -1,5 +1,5 @@
const semver = require('semver');
//@ts-ignore
// @ts-expect-error
const pck = require('../package.json');
const newUnleashVersion = process.argv[2];

View File

@ -185,7 +185,7 @@ class EventStore extends EventEmitter implements IEventStore {
created_by: e.createdBy,
data: e.data,
pre_data: e.preData,
//@ts-ignore workaround for json-array
// @ts-expect-error workaround for json-array
tags: JSON.stringify(e.tags),
feature_name: e.featureName,
project: e.project,

View File

@ -292,7 +292,7 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
featureToggle.environments = Object.values(
featureToggle.environments,
).sort((a, b) => {
// @ts-ignore
// @ts-expect-error
return a.sortOrder - b.sortOrder;
});
featureToggle.environments = featureToggle.environments.map((e) => {

View File

@ -84,7 +84,6 @@ class ProjectStore implements IProjectStore {
}
const projectAndFeatureCount = await projects;
// @ts-ignore
const projectsWithFeatureCount = projectAndFeatureCount.map(
this.mapProjectWithCountRow,
);

View File

@ -149,11 +149,11 @@ export default class MetricsMonitor {
for (const entry of Object.entries(m.bucket.toggles)) {
featureToggleUsageTotal
.labels(entry[0], 'true', m.appName)
// @ts-ignore
// @ts-expect-error
.inc(entry[1].yes);
featureToggleUsageTotal
.labels(entry[0], 'false', m.appName)
// @ts-ignore
// @ts-expect-error
.inc(entry[1].no);
}
});

View File

@ -18,7 +18,7 @@ function demoAuthentication(
email,
true,
);
//@ts-ignore
// @ts-expect-error
req.session.user = user;
return res.status(200).json(user);
} catch (e) {
@ -29,18 +29,18 @@ function demoAuthentication(
});
app.use(`${basePath}/api/admin/`, (req, res, next) => {
// @ts-ignore
// @ts-expect-error
if (req.session.user && req.session.user.email) {
// @ts-ignore
// @ts-expect-error
req.user = req.session.user;
}
next();
});
app.use(`${basePath}/api/client`, (req, res, next) => {
// @ts-ignore
// @ts-expect-error
if (!authentication.enableApiToken && !req.user) {
// @ts-ignore
// @ts-expect-error
req.user = new ApiUser({
username: 'unauthed-default-client',
permissions: [],
@ -53,7 +53,7 @@ function demoAuthentication(
});
app.use(`${basePath}/api`, (req, res, next) => {
// @ts-ignore
// @ts-expect-error
if (req.user) {
return next();
}

View File

@ -4,7 +4,7 @@ import NoAuthUser from '../types/no-auth-user';
// eslint-disable-next-line
function noneAuthentication(basePath = '', app: Application): void {
app.use(`${basePath}/api/admin/`, (req, res, next) => {
// @ts-ignore
// @ts-expect-error
if (!req.user) {
// @ts-expect-error
req.user = new NoAuthUser();

View File

@ -18,7 +18,7 @@ function sessionDb(
store = new KnexSessionStore({
tablename: 'unleash_session',
createtable: false,
// @ts-ignore
// @ts-expect-error
knex,
});
} else {

View File

@ -45,14 +45,14 @@ class StateController extends Controller {
const { drop, keep } = req.query;
// TODO: Should override request type so file is a type on request
let data;
// @ts-ignore
// @ts-expect-error
if (req.file) {
// @ts-ignore
// @ts-expect-error
if (mime.getType(req.file.originalname) === 'text/yaml') {
// @ts-ignore
// @ts-expect-error
data = YAML.load(req.file.buffer);
} else {
// @ts-ignore
// @ts-expect-error
data = JSON.parse(req.file.buffer);
}
} else {

View File

@ -57,13 +57,12 @@ export default class FeatureController extends Controller {
this.get('/:featureName', this.getFeatureToggle);
if (experimental && experimental.clientFeatureMemoize) {
// @ts-ignore
this.cache = experimental.clientFeatureMemoize.enabled;
this.cachedFeatures = memoizee(
(query) => this.resolveFeaturesAndSegments(query),
{
promise: true,
// @ts-ignore
// @ts-expect-error
maxAge: experimental.clientFeatureMemoize.maxAge,
normalizer(args) {
// args is arguments object as accessible in memoized function

View File

@ -27,7 +27,7 @@ export const handleErrors: (
error: Error,
) => void = (res, logger, error) => {
logger.warn(error.message);
// @ts-ignore
// @ts-expect-error
// eslint-disable-next-line no-param-reassign
error.isJoi = true;

View File

@ -630,7 +630,6 @@ class FeatureToggleService {
newToggle.environments.forEach((e: IEnvironmentDetail) =>
e.strategies.forEach((s: IStrategyConfig) => {
if (replaceGroupId && s.parameters.hasOwnProperty('groupId')) {
//@ts-ignore
s.parameters.groupId = newFeatureName;
}
delete s.id;

View File

@ -97,7 +97,7 @@ export default async function init(
await db.raw(`DROP SCHEMA IF EXISTS ${config.db.schema} CASCADE`);
await db.raw(`CREATE SCHEMA IF NOT EXISTS ${config.db.schema}`);
// @ts-ignore
// @ts-expect-error
await migrateDb({ ...config, databaseSchema: config.db.schema });
await db.destroy();
const testDb = createDb(config);

View File

@ -11,7 +11,7 @@ export default class FakeClientApplicationsStore
apps: IClientApplication[] = [];
async bulkUpsert(details: Partial<IClientApplication>[]): Promise<void> {
// @ts-ignore
// @ts-expect-error
details.forEach((d) => this.apps.push(d));
}

View File

@ -82,14 +82,14 @@ class UserStoreMock implements IUserStore {
async setPasswordHash(userId: number, passwordHash: string): Promise<void> {
const u = this.data.find((a) => a.id === userId);
// @ts-ignore
// @ts-expect-error
u.passwordHash = passwordHash;
return Promise.resolve();
}
async getPasswordHash(id: number): Promise<string> {
const u = this.data.find((i) => i.id === id);
// @ts-ignore
// @ts-expect-error
return Promise.resolve(u.passwordHash);
}