Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump eslint from 8.38.0 to 8.56.0 #1881

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
524 changes: 293 additions & 231 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"@types/npm-license-crawler": "0.2.3",
"@typescript-eslint/eslint-plugin": "5.30.6",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.38.0",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-prettier": "5.1.2",
"eslint-plugin-unicorn": "43.0.2",
"eslint-plugin-unicorn": "50.0.1",
"fs-extra": "11.2.0",
"globby": "11.0.4",
"graphql": "15.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"@types/validator": "13.11.7",
"@typescript-eslint/eslint-plugin": "5.30.6",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.38.0",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.29.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/src/controllers/webhook.v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ export const hook = (req: Request, res: Response): void => {
let insightSyncTask: InsightSyncTask | null = null;
if (req.headers['x-github-event'] !== undefined) {
insightSyncTask = handleGitHub(webhook);
} else if (webhook.path !== undefined) {
} else if (webhook.path === undefined) {
res.status(400).send('Not Recognized');
return;
} else {
insightSyncTask = {
repositoryType: RepositoryType.FILE,
owner: 'local',
repo: webhook.path
};
} else {
res.status(400).send('Not Recognized');
return;
}

if (insightSyncTask == null) {
Expand Down
40 changes: 20 additions & 20 deletions packages/backend/src/lib/backends/base.sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,13 @@ export abstract class BaseSync {
// This key should be unchanging to avoid creating duplicates
let existingDbInsight = await DbInsight.query().where('externalId', externalId).first();

if (existingDbInsight != undefined) {
logger.trace('Insight does exist in database');
await existingDbInsight.$query().patch({
insightName: insight.fullName,
itemType: insight.itemType,
deletedAt: null,
repositoryData
});
} else {
if (existingDbInsight == undefined) {
logger.trace('Insight does not exist in database');

// Check to see if the fullName already exists, but with a different externalID
existingDbInsight = await DbInsight.query().where('insightName', insight.fullName).first();

if (existingDbInsight != undefined) {
// Assume the repo was deleted and recreated, and just update the external ID
// (We've already checked to ensure the external ID is unique)
logger.trace('Insight exists in database, but with a different externalId');
await existingDbInsight.$query().patch({
externalId,
itemType: insight.itemType,
deletedAt: null,
repositoryData
});
} else {
if (existingDbInsight == undefined) {
logger.trace('Insight does not exist in database');
existingDbInsight = await DbInsight.query().insert({
externalId,
Expand All @@ -141,7 +123,25 @@ export abstract class BaseSync {
repositoryData,
itemType: insight.itemType
});
} else {
// Assume the repo was deleted and recreated, and just update the external ID
// (We've already checked to ensure the external ID is unique)
logger.trace('Insight exists in database, but with a different externalId');
await existingDbInsight.$query().patch({
externalId,
itemType: insight.itemType,
deletedAt: null,
repositoryData
});
}
} else {
logger.trace('Insight does exist in database');
await existingDbInsight.$query().patch({
insightName: insight.fullName,
itemType: insight.itemType,
deletedAt: null,
repositoryData
});
}

logger.trace(JSON.stringify(existingDbInsight, null, 2));
Expand Down
9 changes: 6 additions & 3 deletions packages/backend/src/lib/backends/file-system.sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,15 @@ const getConversions = (insightFile: Omit<InsightFile, 'id'>): undefined | Insig
switch (insightFile.mimeType) {
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {
return [
{
mimeType: 'application/pdf',
path: `.converted/${insightFile.path}.pdf`
}
];
case 'application/x-ipynb+json':
}
case 'application/x-ipynb+json': {
return [
{
mimeType: 'application/pdf',
Expand All @@ -316,8 +317,10 @@ const getConversions = (insightFile: Omit<InsightFile, 'id'>): undefined | Insig
path: `.converted/${insightFile.path}.html`
}
];
default:
}
default: {
return undefined;
}
}
};

Expand Down
9 changes: 6 additions & 3 deletions packages/backend/src/lib/backends/github.sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,15 @@ const getConversions = (insightFile: Omit<InsightFile, 'id'>): undefined | Insig
switch (insightFile.mimeType) {
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {
return [
{
mimeType: 'application/pdf',
path: `.converted/${insightFile.path}.pdf`
}
];
case 'application/x-ipynb+json':
}
case 'application/x-ipynb+json': {
return [
{
mimeType: 'application/pdf',
Expand All @@ -444,8 +445,10 @@ const getConversions = (insightFile: Omit<InsightFile, 'id'>): undefined | Insig
path: `.converted/${insightFile.path}.html`
}
];
default:
}
default: {
return undefined;
}
}
};

Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/lib/backends/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function makeGraphql(token: string = process.env.GITHUB_ACCESS_TOKEN!): g
}

return GQ.defaults({
baseUrl: process.env.GITHUB_GRAPHQL_API_URL !== '' ? process.env.GITHUB_GRAPHQL_API_URL : undefined,
baseUrl: process.env.GITHUB_GRAPHQL_API_URL === '' ? undefined : process.env.GITHUB_GRAPHQL_API_URL,
mediaType: {
previews: ['bane']
},
Expand All @@ -72,7 +72,7 @@ export function makeOctokit(token: string = process.env.GITHUB_ACCESS_TOKEN!): O
return new Octokit({
auth: token,
userAgent: `iex ${process.env.IEX_VERSION || '0.0.0'}`,
baseUrl: process.env.GITHUB_REST_API_URL !== '' ? process.env.GITHUB_REST_API_URL : undefined,
baseUrl: process.env.GITHUB_REST_API_URL === '' ? undefined : process.env.GITHUB_REST_API_URL,
log: {
debug: logger.debug.bind(logger),
info: logger.info.bind(logger),
Expand Down
9 changes: 6 additions & 3 deletions packages/backend/src/lib/backends/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export async function syncInsight(insightSyncTask: InsightSyncTask): Promise<Ind

let syncer: BaseSync;
switch (insightSyncTask.repositoryType) {
case RepositoryType.GITHUB:
case RepositoryType.GITHUB: {
syncer = new GitHubRepositorySync();
break;
case RepositoryType.FILE:
}
case RepositoryType.FILE: {
syncer = new FileSystemSync();
break;
default:
}
default: {
throw new Error('Unknown Repository Type');
}
}

return syncer.sync(insightSyncTask);
Expand Down
20 changes: 13 additions & 7 deletions packages/backend/src/lib/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,24 @@ export async function getInsightByFullName(
*/
function getSortField(field: string | undefined): string {
switch (field) {
case undefined:
case undefined: {
return defaultSort.field!;
case 'relevance':
}
case 'relevance': {
return '_score';
case 'name':
}
case 'name': {
return 'name.keyword';
case 'fullName':
}
case 'fullName': {
return 'fullName.keyword';
case 'publishedDate':
}
case 'publishedDate': {
return 'metadata.publishedDate';
default:
}
default: {
return field;
}
}
}

Expand Down Expand Up @@ -544,7 +550,7 @@ export async function getInsightsByContributor(
size: insights.length,
total: elasticResponse.body.hits.total.value,
startCursor: edges.length > 0 ? edges[0].cursor : undefined,
endCursor: edges.length > 0 ? edges[edges.length - 1].cursor : undefined,
endCursor: edges.length > 0 ? edges.at(-1)?.cursor : undefined,
// Unable to determine this
hasNextPage: true,
// Backwards cursor isn't supported
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/lib/git-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class GitInstance {

async retrieveFileUtf8(filePath: string): Promise<string | null> {
const buffer = await this.retrieveFile(filePath);
return buffer != null ? buffer.toString('utf8') : null;
return buffer == null ? null : buffer.toString('utf8');
}

// TODO: Only works for UTF-8 based-files
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/lib/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function convertToDraft(request: ImportRequest): DraftDataInput {
`<!-- Please review it for any conversion errors. -->\n\n` +
readmeFile.contents;

readmeFile.contents = readmeFile.contents.replace(/\u00A0/g, ' ');
readmeFile.contents = readmeFile.contents.replaceAll('\u00A0', ' ');
}

return combinedDraftData;
Expand Down
6 changes: 1 addition & 5 deletions packages/backend/src/resolvers/autocomplete.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ export class AutocompleteResolver {

// Combine both teams on Insights and Users
const combined = [...publishedTeams, ...userTeams].reduce<Record<string, number>>((acc, v) => {
if (acc[v.value]) {
acc[v.value] = acc[v.value] + v.occurrences;
} else {
acc[v.value] = v.occurrences;
}
acc[v.value] = acc[v.value] ? acc[v.value] + v.occurrences : v.occurrences;
return acc;
}, {});

Expand Down
9 changes: 6 additions & 3 deletions packages/backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ export async function createServer(): Promise<express.Express> {

// Show routes called in console during development
switch (process.env.NODE_ENV) {
case 'development':
case 'development': {
logger.info('Loading development middleware');
app.use(security);
break;
case 'production':
}
case 'production': {
logger.info('Loading production middleware');
app.use(security);
break;
default:
}
default: {
logger.info('Actually ' + process.env.NODE_ENV);
}
}

app.use(compression());
Expand Down
17 changes: 11 additions & 6 deletions packages/backend/src/services/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@ export class ActivityService {
const cursor = toElasticsearchCursor(
...sort!.map((s) => {
switch (s.field) {
case 'occurredAt':
case 'occurredAt': {
// Special date handling
return new Date(activity.occurredAt).getTime();
case 'relevance':
}
case 'relevance': {
return doc._score;
}
}
})
);
Expand All @@ -256,7 +258,7 @@ export class ActivityService {
size: edges.length,
total: elasticResponse.body.hits.total.value,
startCursor: edges.length > 0 ? edges[0].cursor : undefined,
endCursor: edges.length > 0 ? edges[edges.length - 1].cursor : undefined,
endCursor: edges.length > 0 ? edges.at(-1)?.cursor : undefined,
// Unable to determine this
hasNextPage: true,
// Backwards cursor isn't supported
Expand Down Expand Up @@ -367,12 +369,15 @@ export class ActivityService {
*/
getSortField(field: string | undefined): string {
switch (field) {
case undefined:
case undefined: {
return this.defaultSort.field!;
case 'relevance':
}
case 'relevance': {
return '_score';
default:
}
default: {
return field;
}
}
}
}
14 changes: 7 additions & 7 deletions packages/backend/src/services/draft.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ export class DraftService {
draftRemains.insightId = dbInsightId;
}

if (existingDraft != undefined) {
logger.trace('Draft does exist in database');
return await existingDraft.$query().patchAndFetch(draftRemains);
} else {
if (existingDraft == undefined) {
logger.trace('Draft does not exist in database');
return await Draft.query().insert({
...draftRemains,
createdByUserId: user?.userId
});
} else {
logger.trace('Draft does exist in database');
return await existingDraft.$query().patchAndFetch(draftRemains);
}
}

Expand All @@ -124,7 +124,9 @@ export class DraftService {
async deleteDraft(draftKey: DraftKey, user: User): Promise<Draft> {
const existingDraft = await Draft.query().where('draftKey', draftKey).first();

if (existingDraft != undefined) {
if (existingDraft == undefined) {
throw new Error('Draft not found by key: ' + draftKey);
} else {
if (existingDraft.createdByUserId != user.userId && existingDraft.createdByUserId != null) {
throw new Error('Not allowed');
}
Expand All @@ -135,8 +137,6 @@ export class DraftService {
throw new Error('Unexpectedly, Draft not deleted');
}
return existingDraft;
} else {
throw new Error('Draft not found by key: ' + draftKey);
}
}

Expand Down
Loading
Loading