Skip to content

Commit

Permalink
fixup! chore: Upgrade eslint monorepo to v9.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
avaly committed Jan 9, 2025
1 parent 63fabd0 commit 94bda7d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 36 deletions.
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export default typescriptEslint.config(
'@typescript-eslint/no-extra-semi': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-restricted-types': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"docs": "pnpm build:docs && docsify serve ./docs",
"benchmark": "pnpm build && node --experimental-specifier-resolution=node ./benchmark/run.js",
"lint:ci": "./tests/build.sh && eslint .",
"lint": "eslint .",
"lint": "eslint --report-unused-disable-directives .",
"postpack": "pinst --enable",
"prepack": "pinst --disable && pnpm build",
"prepare": "husky",
Expand Down
62 changes: 31 additions & 31 deletions src/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ describe('schema', () => {
{},
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<boolean | undefined>(value[0].foo);
expectType<ObjectId>(value[0]?._id);
expectType<boolean | undefined>(value[0]?.foo);
expectType<(typeof value)[0]>({
_id: new ObjectId(),
bar: 123,
Expand Down Expand Up @@ -104,8 +104,8 @@ describe('schema', () => {
},
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<boolean | undefined>(value[0].foo);
expectType<ObjectId>(value[0]?._id);
expectType<boolean | undefined>(value[0]?.foo);
expectType<(typeof value)[0]>({
_id: new ObjectId(),
bar: 123,
Expand Down Expand Up @@ -180,9 +180,9 @@ describe('schema', () => {
},
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<'baz' | 'ham' | undefined>(value[0].enumConstOptional);
expectType<'baz' | 'ham'>(value[0].enumConstRequired);
expectType<ObjectId>(value[0]?._id);
expectType<'baz' | 'ham' | undefined>(value[0]?.enumConstOptional);
expectType<'baz' | 'ham'>(value[0]?.enumConstRequired);
expectType<(typeof value)[0]>({
_id: new ObjectId(),
enumConstOptional: 'ham',
Expand Down Expand Up @@ -242,10 +242,10 @@ describe('schema', () => {
{ timestamps: boolean },
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<boolean | undefined>(value[0].foo);
expectType<Date>(value[0].createdAt);
expectType<Date>(value[0].updatedAt);
expectType<ObjectId>(value[0]?._id);
expectType<boolean | undefined>(value[0]?.foo);
expectType<Date>(value[0]?.createdAt);
expectType<Date>(value[0]?.updatedAt);
expectType<(typeof value)[0]>({
_id: new ObjectId(),
createdAt: new Date(),
Expand Down Expand Up @@ -289,10 +289,10 @@ describe('schema', () => {
{ timestamps: boolean },
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<boolean | undefined>(value[0].foo);
expectType<ObjectId>(value[0]?._id);
expectType<boolean | undefined>(value[0]?.foo);
// @ts-expect-error `createdAt` is undefined here
value[0].createdAt;
value[0]?.createdAt;
expectType<(typeof value)[0]>({
_id: new ObjectId(),
foo: true,
Expand Down Expand Up @@ -354,14 +354,14 @@ describe('schema', () => {
},
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<boolean | undefined>(value[0].foo);
expectType<Date>(value[0]._createdDate);
expectType<Date>(value[0]._updatedDate);
expectType<ObjectId>(value[0]?._id);
expectType<boolean | undefined>(value[0]?.foo);
expectType<Date>(value[0]?._createdDate);
expectType<Date>(value[0]?._updatedDate);
// @ts-expect-error `createdAt` is undefined here
value[0].createdAt;
value[0]?.createdAt;
// @ts-expect-error `updatedAt` is undefined here
value[0].updatedAt;
value[0]?.updatedAt;
expectType<(typeof value)[0]>({
_createdDate: new Date(),
_id: new ObjectId(),
Expand Down Expand Up @@ -422,12 +422,12 @@ describe('schema', () => {
},
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<boolean | undefined>(value[0].foo);
expectType<Date>(value[0]._createdDate);
expectType<Date>(value[0].updatedAt);
expectType<ObjectId>(value[0]?._id);
expectType<boolean | undefined>(value[0]?.foo);
expectType<Date>(value[0]?._createdDate);
expectType<Date>(value[0]?.updatedAt);
// @ts-expect-error `createdAt` is undefined here
value[0].createdAt;
value[0]?.createdAt;
expectType<(typeof value)[0]>({
_createdDate: new Date(),
_id: new ObjectId(),
Expand Down Expand Up @@ -469,7 +469,7 @@ describe('schema', () => {
{},
]
>(value);
expectType<string>(value[0]._id);
expectType<string>(value[0]?._id);
expectType<(typeof value)[0]>({
_id: 'first',
foo: 123,
Expand Down Expand Up @@ -512,7 +512,7 @@ describe('schema', () => {
{},
]
>(value);
expectType<number>(value[0]._id);
expectType<number>(value[0]?._id);
expectType<(typeof value)[0]>({
_id: 123,
foo: 'first',
Expand Down Expand Up @@ -857,7 +857,7 @@ describe('schema', () => {
validationAction: typeof VALIDATION_ACTIONS.WARN;
validationLevel: typeof VALIDATION_LEVEL.MODERATE;
}>(value[1]);
expectType<ObjectId>(value[0]._id);
expectType<ObjectId>(value[0]?._id);
});

test('explicit optional - simple', () => {
Expand Down Expand Up @@ -896,8 +896,8 @@ describe('schema', () => {
{},
]
>(value);
expectType<ObjectId>(value[0]._id);
expectType<boolean | undefined>(value[0].foo);
expectType<ObjectId>(value[0]?._id);
expectType<boolean | undefined>(value[0]?.foo);
expectType<(typeof value)[0]>({
_id: new ObjectId(),
bar: 123,
Expand Down Expand Up @@ -1219,6 +1219,6 @@ describe('schema', () => {
validationAction: typeof VALIDATION_ACTIONS.WARN;
validationLevel: typeof VALIDATION_LEVEL.MODERATE;
}>(value[1]);
expectType<ObjectId>(value[0]._id);
expectType<ObjectId>(value[0]?._id);
});
});
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default class Papr {
// If we have models defined before initializing a database, we build them now
for (const [collectionName, collectionSchema] of this.schemas.entries()) {
const model = this.models.get(collectionName);
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (model && !model.collection) {
build(collectionSchema, model, this.db.collection(collectionName), this.options);
}
Expand Down Expand Up @@ -114,7 +113,6 @@ export default class Papr {
if (!this.db) {
throw new Error('The DB is not connected');
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!model.collection) {
throw new Error('The model collection is not initialized');
}
Expand Down
1 change: 0 additions & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ export function build<TSchema extends BaseSchema, TOptions extends SchemaOptions
): void {
// Sanity check for already built models
// @ts-expect-error Ignore type mismatch error
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (model.collection && model.aggregate !== abstractMethod) {
return;
}
Expand Down

0 comments on commit 94bda7d

Please sign in to comment.