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

add eslint #95

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4137cea
add eslint
RamRamez Jun 8, 2024
35edb29
update eslint config
RamRamez Jun 8, 2024
297fabb
add eslint plugins
RamRamez Jun 8, 2024
d0222d4
apply eslint to migrations
RamRamez Jun 8, 2024
37a537a
fix eslint errors 1
RamRamez Jun 8, 2024
7325ede
fix eslint errors 2
RamRamez Jun 8, 2024
d165b3a
fix eslint errors 3
RamRamez Jun 8, 2024
d6ad583
fix Redis eslint error
RamRamez Jun 8, 2024
b06ca6a
update ioredis and typeorm
RamRamez Jun 8, 2024
944ab5a
npm audit fix
RamRamez Jun 8, 2024
7b65fef
update eslint config
RamRamez Jun 9, 2024
202491d
update package.json config
RamRamez Jun 9, 2024
9acb54b
fix eslint errors part 4
RamRamez Jun 9, 2024
dc9a496
fix eslint errors part 5
RamRamez Jun 9, 2024
ff503af
update node version
RamRamez Jun 10, 2024
447fe78
replace esm with commonjs
RamRamez Jun 10, 2024
3f4710a
use alpha version for typeorm
RamRamez Jun 10, 2024
06fd2fd
replace npm with yarn
RamRamez Jun 10, 2024
ea78bdb
replace npm with yarn
RamRamez Jun 10, 2024
08363f7
update pipeline to use yarn
RamRamez Jun 10, 2024
ff0beb3
update pipeline to use yarn
RamRamez Jun 10, 2024
75fe6be
update pipeline to use yarn
RamRamez Jun 10, 2024
94b86d9
update pipeline to use yarn
RamRamez Jun 10, 2024
ee6f203
Merge branch 'refs/heads/staging' into add-eslint
RamRamez Jul 2, 2024
fe7d17d
fix eslint errors
RamRamez Jul 2, 2024
3b45e5d
fix errors
RamRamez Jul 2, 2024
3dc51fd
fix errors
RamRamez Jul 2, 2024
7b82652
fix errors
RamRamez Jul 2, 2024
dfe1590
fix errors
RamRamez Jul 2, 2024
8a0d320
Merge branch 'refs/heads/staging' into add-eslint
RamRamez Jul 2, 2024
e386b60
fix errors
RamRamez Jul 2, 2024
1433829
fix errors
RamRamez Jul 2, 2024
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
41 changes: 41 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["import", "unused-imports"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/no-unused-vars": [
"error", { "argsIgnorePattern": "^_" }],
"prettier/prettier": [
"error",
{
"arrowParens": "avoid",
"singleQuote": true,
"semi": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"jsdoc-format": false,
"endOfLine": "auto"
}
],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
["internal", "parent", "sibling"],
"index",
"object",
"type"
]
}
]
}
}
26 changes: 0 additions & 26 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.14.0
node-version: 20.11.0
- name: Install dependencies
run: npm ci
- name: Run linter
Expand Down
24 changes: 19 additions & 5 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,22 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.14.0
node-version: 20.14.0

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: npm ci
run: yarn install

- name: Run linter
run: npm run lint
run: yarn lint

- name: Run migrations
run: npm run db:migrate:run:test
run: yarn db:migrate:run:test

- name: Run tests
run: npm run test
run: yarn test

publish:
needs: test
Expand All @@ -58,6 +65,13 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install

- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions migrations/1678175596807-changeNotificationCopies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class changeNotificationCopies1678175596807
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(_queryRunner: QueryRunner): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -339,7 +339,7 @@ export class changeNotificationCopies1678175596807
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(_queryRunner: QueryRunner): Promise<void> {
//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class changeCancelProjectNotificationCopies1681206838965
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(_queryRunner: QueryRunner): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -84,7 +84,7 @@ export class changeCancelProjectNotificationCopies1681206838965
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(_queryRunner: QueryRunner): Promise<void> {
//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import {
NotificationType,
SCHEMA_VALIDATORS_NAMES,
} from '../src/entities/notificationType';
import { MICRO_SERVICES, THIRD_PARTY_EMAIL_SERVICES } from '../src/utils/utils';
import { MICRO_SERVICES } from '../src/utils/utils';
import {
NOTIFICATION_CATEGORY,
NOTIFICATION_TYPE_NAMES,
} from '../src/types/general';
import { NOTIFICATION_CATEGORY_GROUPS } from '../src/entities/notificationSetting';
import { SegmentEvents } from '../src/services/segment/segmentAnalyticsSingleton';

// https://github.com/Giveth/notification-center/issues/6 , https://gist.github.com/MohammadPCh/24434d50bc9ccd9b74905c271ee05482
// icons https://gist.github.com/MohammadPCh/31e2b750dd9aa54edb21dcc6e7332efb
Expand Down
4 changes: 2 additions & 2 deletions migrations/1692698983844-changeNotificationCopies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class changeNotificationCopies1692698983844
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(_queryRunner: QueryRunner): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -85,7 +85,7 @@ export class changeNotificationCopies1692698983844
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(_queryRunner: QueryRunner): Promise<void> {
//
}
}
44 changes: 23 additions & 21 deletions migrations/1712683625687-addSuperFluidNotificationForAllUsers.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addSuperFluidNotificationForAllUsers1712683625687 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
export class addSuperFluidNotificationForAllUsers1712683625687
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`);

// Fetch all unique userAddressIds
const userAddressIds = await queryRunner.query(`
// Fetch all unique userAddressIds
const userAddressIds = await queryRunner.query(`
SELECT DISTINCT "userAddressId" FROM "notification_setting";
`);

// For each userAddressId, insert a new row for each notificationTypeId
for (const { userAddressId } of userAddressIds) {
for (const { id: notificationTypeId } of notificationTypeIds) {
await queryRunner.query(`
// For each userAddressId, insert a new row for each notificationTypeId
for (const { userAddressId } of userAddressIds) {
for (const { id: notificationTypeId } of notificationTypeIds) {
await queryRunner.query(`
INSERT INTO "notification_setting" (
"allowNotifications",
"allowEmailNotification",
Expand All @@ -24,22 +26,22 @@ export class addSuperFluidNotificationForAllUsers1712683625687 implements Migrat
"userAddressId"
) VALUES (true, true, true, ${notificationTypeId}, ${userAddressId});
`);
}
}
}
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
public async down(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`);

// Convert fetched rows to a list of IDs for the IN clause
const ids = notificationTypeIds.map((nt: { id: any; }) => nt.id).join(', ');
// Convert fetched rows to a list of IDs for the IN clause
const ids = notificationTypeIds.map((nt: { id: any }) => nt.id).join(', ');

// Delete the rows with the fetched notificationTypeIds for all userAddressIds
await queryRunner.query(`
// Delete the rows with the fetched notificationTypeIds for all userAddressIds
await queryRunner.query(`
DELETE FROM "notification_setting" WHERE "notificationTypeId" IN (${ids});
`);
}
}
}
84 changes: 44 additions & 40 deletions migrations/1713834025817-addGroupParentSuperFluid.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import { MigrationInterface, QueryRunner } from 'typeorm';
import { NOTIFICATION_CATEGORY } from '../src/types/general';
import { NotificationType } from '../src/entities/notificationType';
import { MICRO_SERVICES } from '../src/utils/utils';
import { NOTIFICATION_CATEGORY_GROUPS } from '../src/entities/notificationSetting';

export const superFluidNotificationTypes = [
{
isGlobal: false,
isGroupParent: true,
showOnSettingPage: true,
webDefaultValue: true,
emailDefaultValue: true,
isEmailEditable: true,
isWebEditable: true,
name: 'Stream balance warnings',
description: 'Notify me when any of my Stream Balances are running low',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS,
schemaValidator: null,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPERFLUID,
title: 'Stream balance warnings',
},
]
{
isGlobal: false,
isGroupParent: true,
showOnSettingPage: true,
webDefaultValue: true,
emailDefaultValue: true,
isEmailEditable: true,
isWebEditable: true,
name: 'Stream balance warnings',
description: 'Notify me when any of my Stream Balances are running low',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS,
schemaValidator: null,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPERFLUID,
title: 'Stream balance warnings',
},
];

export class addGroupParentSuperFluid1713834025817 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = (await queryRunner.query(`
export class addGroupParentSuperFluid1713834025817
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = (
await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`)).map((i: any) => i.id);
await queryRunner.query(
`UPDATE notification_type
`)
).map((i: any) => i.id);
await queryRunner.query(
`UPDATE notification_type
SET "showOnSettingPage" = false, "emailDefaultValue" = true, "category" = '${NOTIFICATION_CATEGORY.SUPPORTED_PROJECTS}'
WHERE id IN (${notificationTypeIds.join(", ")})`
);
await queryRunner.manager.save(
NotificationType,
superFluidNotificationTypes,
);
}
WHERE id IN (${notificationTypeIds.join(', ')})`,
);
await queryRunner.manager.save(
NotificationType,
superFluidNotificationTypes,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DELETE FROM notification_type WHERE "categoryGroup" = 'superfluid' AND "name" = 'Stream Balance Warnings';`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DELETE FROM notification_type WHERE "categoryGroup" = 'superfluid' AND "name" = 'Stream Balance Warnings';`,
);
}
}
Loading
Loading