From bd2622b232639a30f654e6b9559c86d4d98783a3 Mon Sep 17 00:00:00 2001 From: Jessica Mulein Date: Wed, 25 Sep 2024 20:58:25 +0000 Subject: [PATCH] lint improvements, basic tweaks to has-soft-deleter --- apps/duality-social-node/.eslintrc.json | 2 +- apps/duality-social-node/package.json | 8 ++++---- apps/duality-social-queue-worker-e2e/.eslintrc.json | 2 +- apps/duality-social-queue-worker/.eslintrc.json | 2 +- apps/duality-social-react-e2e/.eslintrc.json | 2 +- apps/duality-social-react/.eslintrc.json | 2 +- do-yarn.sh | 9 +++++++++ libs/duality-social-lib/src/index.ts | 2 +- .../src/lib/interfaces/has-creator.ts | 1 - .../{has-deleter.ts => has-soft-deleter.ts} | 3 +-- .../src/lib/interfaces/has-timestamp-owners.ts | 1 - .../src/lib/interfaces/has-updater.ts | 1 - .../src/lib/interfaces/models/post-viewpoint.ts | 4 ++-- .../src/lib/interfaces/models/post.ts | 4 ++-- .../src/lib/interfaces/models/user.ts | 4 ++-- libs/duality-social-node-lib/.eslintrc.json | 2 +- libs/duality-social-node-lib/package.json | 5 ++++- list-scripts.sh | 12 ++++++++++++ package.json | 3 ++- yarn.lock | 4 ++-- 20 files changed, 47 insertions(+), 26 deletions(-) rename libs/duality-social-lib/src/lib/interfaces/{has-deleter.ts => has-soft-deleter.ts} (61%) create mode 100755 list-scripts.sh diff --git a/apps/duality-social-node/.eslintrc.json b/apps/duality-social-node/.eslintrc.json index 1bbccde..8c7a89b 100644 --- a/apps/duality-social-node/.eslintrc.json +++ b/apps/duality-social-node/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["node_modules", "!**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/apps/duality-social-node/package.json b/apps/duality-social-node/package.json index bb37e16..7f5224b 100644 --- a/apps/duality-social-node/package.json +++ b/apps/duality-social-node/package.json @@ -38,15 +38,15 @@ }, "devDependencies": { "@faker-js/faker": "^9.0.1", - "@types/cors": "^2.8.17", - "@types/express-session": "^1.18.0", - "@types/uuid": "^10.0.0", "@types/bcrypt": "^5.0.2", + "@types/cors": "^2.8.17", "@types/express": "^4.17.21", + "@types/express-session": "^1.18.0", "@types/jest": "^29.5.13", "@types/multer": "^1.4.12", - "@types/node": "^22.5.5", + "@types/node": "^22.6.1", "@types/supertest": "^6.0.2", + "@types/uuid": "^10.0.0", "@types/validator": "^13.12.0", "jest": "^29.7.0", "jest-mock-extended": "^3.0.7", diff --git a/apps/duality-social-queue-worker-e2e/.eslintrc.json b/apps/duality-social-queue-worker-e2e/.eslintrc.json index 9d9c0db..7928477 100644 --- a/apps/duality-social-queue-worker-e2e/.eslintrc.json +++ b/apps/duality-social-queue-worker-e2e/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["node_modules", "!**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/apps/duality-social-queue-worker/.eslintrc.json b/apps/duality-social-queue-worker/.eslintrc.json index 9d9c0db..7928477 100644 --- a/apps/duality-social-queue-worker/.eslintrc.json +++ b/apps/duality-social-queue-worker/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["node_modules", "!**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/apps/duality-social-react-e2e/.eslintrc.json b/apps/duality-social-react-e2e/.eslintrc.json index 696cb8b..750a567 100644 --- a/apps/duality-social-react-e2e/.eslintrc.json +++ b/apps/duality-social-react-e2e/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["plugin:cypress/recommended", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["node_modules", "!**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/apps/duality-social-react/.eslintrc.json b/apps/duality-social-react/.eslintrc.json index 6508cd1..a23d114 100644 --- a/apps/duality-social-react/.eslintrc.json +++ b/apps/duality-social-react/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["plugin:@nx/react", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["node_modules", "!**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/do-yarn.sh b/do-yarn.sh index 8b0debe..49b0491 100755 --- a/do-yarn.sh +++ b/do-yarn.sh @@ -6,11 +6,20 @@ PACKAGE_ROOTS=$(find . -type f -name "package.json" ! -path "*/node_modules/*" ! # Make sure we start with the project root PROJECT_ROOT=$(pwd) +# Run yarn in the project root +echo "Running yarn in $PROJECT_ROOT" +yarn "$@" + # Loop through each package.json file for PACKAGE in $PACKAGE_ROOTS; do # Get the directory containing the package.json file PACKAGE_DIR=$(dirname "$PACKAGE") + # Skip the project root directory + if [ "$PACKAGE_DIR" == "$PROJECT_ROOT" ]; then + continue + fi + # Change to the package directory cd "$PACKAGE_DIR" || exit diff --git a/libs/duality-social-lib/src/index.ts b/libs/duality-social-lib/src/index.ts index 6250a83..d7cace5 100644 --- a/libs/duality-social-lib/src/index.ts +++ b/libs/duality-social-lib/src/index.ts @@ -74,7 +74,7 @@ export * from './lib/interfaces/feed-post.ts'; export * from './lib/interfaces/feed-post-viewpoint.ts'; export * from './lib/interfaces/has-creation.ts'; export * from './lib/interfaces/has-creator.ts'; -export * from './lib/interfaces/has-deleter.ts'; +export * from './lib/interfaces/has-soft-deleter.ts'; export * from './lib/interfaces/has-id.ts'; export * from './lib/interfaces/has-soft-delete.ts'; export * from './lib/interfaces/has-timestamp-owners.ts'; diff --git a/libs/duality-social-lib/src/lib/interfaces/has-creator.ts b/libs/duality-social-lib/src/lib/interfaces/has-creator.ts index 91b990c..7e35844 100644 --- a/libs/duality-social-lib/src/lib/interfaces/has-creator.ts +++ b/libs/duality-social-lib/src/lib/interfaces/has-creator.ts @@ -1,6 +1,5 @@ import { Types } from 'mongoose'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any export interface IHasCreator { /** * The MongoDB unique identifier for the user who created the object. diff --git a/libs/duality-social-lib/src/lib/interfaces/has-deleter.ts b/libs/duality-social-lib/src/lib/interfaces/has-soft-deleter.ts similarity index 61% rename from libs/duality-social-lib/src/lib/interfaces/has-deleter.ts rename to libs/duality-social-lib/src/lib/interfaces/has-soft-deleter.ts index 83dd3c4..6d3d2f2 100644 --- a/libs/duality-social-lib/src/lib/interfaces/has-deleter.ts +++ b/libs/duality-social-lib/src/lib/interfaces/has-soft-deleter.ts @@ -1,7 +1,6 @@ import { Types } from 'mongoose'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export interface IHasDeleter { +export interface IHasSoftDeleter { /** * The MongoDB unique identifier for the user who deleted the object. */ diff --git a/libs/duality-social-lib/src/lib/interfaces/has-timestamp-owners.ts b/libs/duality-social-lib/src/lib/interfaces/has-timestamp-owners.ts index dcd2685..bac6b52 100644 --- a/libs/duality-social-lib/src/lib/interfaces/has-timestamp-owners.ts +++ b/libs/duality-social-lib/src/lib/interfaces/has-timestamp-owners.ts @@ -1,5 +1,4 @@ import { IHasCreator } from './has-creator.ts'; import { IHasUpdater } from './has-updater.ts'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any export interface IHasTimestampOwners extends IHasCreator, IHasUpdater {} diff --git a/libs/duality-social-lib/src/lib/interfaces/has-updater.ts b/libs/duality-social-lib/src/lib/interfaces/has-updater.ts index 6d4f36f..a8c10e6 100644 --- a/libs/duality-social-lib/src/lib/interfaces/has-updater.ts +++ b/libs/duality-social-lib/src/lib/interfaces/has-updater.ts @@ -1,6 +1,5 @@ import { Types } from 'mongoose'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any export interface IHasUpdater { /** * The MongoDB unique identifier for the user who updated the object. diff --git a/libs/duality-social-lib/src/lib/interfaces/models/post-viewpoint.ts b/libs/duality-social-lib/src/lib/interfaces/models/post-viewpoint.ts index 0b0401c..2590a4c 100644 --- a/libs/duality-social-lib/src/lib/interfaces/models/post-viewpoint.ts +++ b/libs/duality-social-lib/src/lib/interfaces/models/post-viewpoint.ts @@ -3,13 +3,13 @@ import { HumanityTypeEnum } from '../../enumerations/humanity-type.ts'; import { ViewpointTypeEnum } from '../../enumerations/viewpoint-type.ts'; import { IHasSoftDelete } from '../has-soft-delete.ts'; import { IHasTimestamps } from '../has-timestamps.ts'; -import { IHasDeleter } from '../has-deleter.ts'; +import { IHasSoftDeleter } from '../has-soft-deleter.ts'; import { DefaultReactionsTypeEnum } from '../../enumerations/default-reactions-type.ts'; export interface IPostViewpoint extends IHasTimestamps, IHasSoftDelete, - IHasDeleter { + IHasSoftDeleter { /** * Correlation id to link the dualities. */ diff --git a/libs/duality-social-lib/src/lib/interfaces/models/post.ts b/libs/duality-social-lib/src/lib/interfaces/models/post.ts index 41fd1b2..dbfc63a 100644 --- a/libs/duality-social-lib/src/lib/interfaces/models/post.ts +++ b/libs/duality-social-lib/src/lib/interfaces/models/post.ts @@ -1,5 +1,5 @@ import { Types } from 'mongoose'; -import { IHasDeleter } from '../has-deleter.ts'; +import { IHasSoftDeleter } from '../has-soft-deleter.ts'; import { IHasSoftDelete } from '../has-soft-delete.ts'; import { IHasTimestampOwners } from '../has-timestamp-owners.ts'; import { IHasTimestamps } from '../has-timestamps.ts'; @@ -20,7 +20,7 @@ export interface IPost extends IHasTimestamps, IHasSoftDelete, IHasTimestampOwners, - IHasDeleter { + IHasSoftDeleter { /** * Whether the post is hidden from the feed. */ diff --git a/libs/duality-social-lib/src/lib/interfaces/models/user.ts b/libs/duality-social-lib/src/lib/interfaces/models/user.ts index 8229c7c..4e40215 100644 --- a/libs/duality-social-lib/src/lib/interfaces/models/user.ts +++ b/libs/duality-social-lib/src/lib/interfaces/models/user.ts @@ -6,13 +6,13 @@ import { IHasSoftDelete } from '../has-soft-delete.ts'; import { IHasTimestampOwners } from '../has-timestamp-owners.ts'; import { IHasTimestamps } from '../has-timestamps.ts'; import { HumanityTypeEnum } from '../../enumerations/humanity-type.ts'; -import { IHasDeleter } from '../has-deleter.ts'; +import { IHasSoftDeleter } from '../has-soft-deleter.ts'; export interface IUser extends IHasTimestamps, IHasTimestampOwners, IHasSoftDelete, - IHasDeleter { + IHasSoftDeleter { username: string; languages: string[]; /** diff --git a/libs/duality-social-node-lib/.eslintrc.json b/libs/duality-social-node-lib/.eslintrc.json index 1bbccde..8c7a89b 100644 --- a/libs/duality-social-node-lib/.eslintrc.json +++ b/libs/duality-social-node-lib/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["node_modules", "!**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/duality-social-node-lib/package.json b/libs/duality-social-node-lib/package.json index bbd7804..54dd84e 100644 --- a/libs/duality-social-node-lib/package.json +++ b/libs/duality-social-node-lib/package.json @@ -1,5 +1,8 @@ { "name": "duality-social-node-lib", "version": "0.0.1", - "license": "MIT" + "license": "MIT", + "dependencies": { + "mongoose": "^8.6.3" + } } diff --git a/list-scripts.sh b/list-scripts.sh new file mode 100755 index 0000000..7e42d10 --- /dev/null +++ b/list-scripts.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Check if jq is installed +if ! command -v jq &> /dev/null +then + echo "jq could not be found. Please install jq to use this script." + exit +fi + +# Read and list the scripts from package.json +echo "Available scripts in package.json:" +jq -r '.scripts | to_entries[] | "\(.key): \(.value)"' package.json \ No newline at end of file diff --git a/package.json b/package.json index 7d7388f..a8e7029 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "clean:all": "rm -rf node_modules dist/ ~/.cache && yarn cache clean", "migrate:latest": "npx nx migrate latest", "migrate:run-migrations": "npx nx migrate --run-migrations", - "upgrade:all": "./do-yarn.sh upgrade" + "upgrade:all": "./do-yarn.sh upgrade", + "commands": "./list-scripts.sh" }, "dependencies": { "@awesome.me/kit-89ec609b07": "^1.0.4", diff --git a/yarn.lock b/yarn.lock index c513dbc..14f378a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4477,7 +4477,7 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@^22.5.5": +"@types/node@*", "@types/node@^22.6.1": version "22.6.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-22.6.1.tgz#e531a45f4d78f14a8468cb9cdc29dc9602afc7ac" integrity sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw== @@ -12602,7 +12602,7 @@ mongoose-browser@^5.2.8-pre-2: resolved "https://registry.yarnpkg.com/mongoose-browser/-/mongoose-browser-5.2.8-pre-2.tgz#e7272ea2657dd2ab299fe31762f341ad6a67892d" integrity sha512-DCRCfcvhVtW3E861Vdx+d4btMcpgN7COYuo5hgnEzl6TjRK4gJKYDq7myRhv24dIHvGn2hscfE93CjPbI4Sr/w== -mongoose@^8.5.1: +mongoose@^8.5.1, mongoose@^8.6.3: version "8.6.3" resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-8.6.3.tgz#fdc1f4defd4de87dc3f5c18aacaf811cafcfcfbe" integrity sha512-++yRmm7hjMbqVA/8WeiygTnEfrFbiy+OBjQi49GFJIvCQuSYE56myyQWo4j5hbpcHjhHQU8NukMNGTwAWFWjIw==