Skip to content

Commit ffefa64

Browse files
committed
style: update eslint rules and prettier config
1 parent 76c18fc commit ffefa64

File tree

4 files changed

+99
-7
lines changed

4 files changed

+99
-7
lines changed

.eslintrc.js

+89-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
"simple-import-sort",
1111
],
1212
extends: [
13+
"eslint:recommended",
1314
"plugin:@typescript-eslint/recommended",
1415
"plugin:prettier/recommended",
1516
],
@@ -22,10 +23,96 @@ module.exports = {
2223
"@typescript-eslint/no-explicit-any": "off",
2324
"@typescript-eslint/no-empty-function": "off",
2425
"@typescript-eslint/no-inferrable-types": "off",
25-
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
2626
"@typescript-eslint/explicit-module-boundary-types": "error",
27-
eqeqeq: "error",
27+
"@typescript-eslint/no-duplicate-imports": "error",
28+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
29+
"@typescript-eslint/method-signature-style": ["error", "method"],
30+
"@typescript-eslint/explicit-member-accessibility": [
31+
"error",
32+
{ accessibility: "no-public" },
33+
],
34+
"@typescript-eslint/consistent-type-assertions": [
35+
"error",
36+
{ assertionStyle: "as", objectLiteralTypeAssertions: "never" },
37+
],
38+
"@typescript-eslint/no-unused-vars": [
39+
"error",
40+
{ argsIgnorePattern: "args" },
41+
],
42+
"@typescript-eslint/naming-convention": [
43+
"error",
44+
{ selector: "default", format: ["strictCamelCase"] },
45+
{ selector: "typeLike", format: ["PascalCase"] },
46+
{
47+
selector: "variable",
48+
format: ["strictCamelCase", "UPPER_CASE"],
49+
},
50+
{
51+
selector: "parameter",
52+
modifiers: ["unused"],
53+
format: ["strictCamelCase"],
54+
leadingUnderscore: "allow",
55+
},
56+
{ selector: "enumMember", format: ["PascalCase"] },
57+
],
58+
"eqeqeq": "error",
59+
"no-promise-executor-return": "error",
60+
"no-self-compare": "error",
61+
"no-template-curly-in-string": "error",
62+
"no-unreachable-loop": "error",
63+
"arrow-body-style": "error",
64+
"consistent-return": "error",
65+
"curly": ["error", "multi", "consistent"],
66+
"default-case-last": "error",
67+
"grouped-accessor-pairs": "error",
68+
"no-alert": "error",
69+
"no-bitwise": "error",
70+
"no-console": "error",
71+
"no-else-return": "error",
72+
"no-empty": ["error", { allowEmptyCatch: true }],
73+
"no-eval": "error",
74+
"no-extend-native": "error",
75+
"no-extra-label": "error",
76+
"no-implied-eval": "error",
77+
"no-label-var": "error",
78+
"no-negated-condition": "error",
79+
"no-new-wrappers": "error",
80+
"no-return-assign": "error",
81+
"no-return-await": "error",
82+
"no-sequences": "error",
83+
"no-throw-literal": "error",
84+
"prefer-promise-reject-errors": "error",
85+
"no-unneeded-ternary": "error",
86+
"@typescript-eslint/no-unused-expressions": "error",
87+
"no-useless-call": "error",
88+
"no-useless-escape": "error",
89+
"no-useless-rename": "error",
90+
"no-useless-return": "error",
91+
"no-void": "error",
92+
"object-shorthand": "error",
93+
"one-var": ["error", "never"],
94+
"operator-assignment": "error",
95+
"prefer-arrow-callback": "error",
96+
"prefer-exponentiation-operator": "error",
97+
"prefer-numeric-literals": "error",
98+
"prefer-object-spread": "error",
99+
"prefer-regex-literals": "error",
100+
"prefer-spread": "error",
101+
"require-unicode-regexp": "error",
102+
"max-depth": ["warn", 4],
103+
"max-lines": ["warn", 300],
104+
"max-lines-per-function": ["warn", 50],
105+
"complexity": ["warn", 8],
28106
"simple-import-sort/imports": "warn",
29107
"simple-import-sort/exports": "warn",
30108
},
109+
overrides: [
110+
{
111+
files: ["**/*.{spec,test}.ts"],
112+
rules: {
113+
"max-lines": "off",
114+
"max-lines-per-function": "off",
115+
},
116+
},
117+
],
31118
};

.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"trailingComma": "all"
2+
"trailingComma": "all",
3+
"quoteProps": "consistent"
34
}

src/database/database-event.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ export function forwardDatabaseEvents(
88
dispatcher: EventDispatcher,
99
): void {
1010
database.unitOfWorkEvents.onInsertPre.subscribe(async (event) =>
11-
dispatcher.dispatch(DatabasePreInsert, DatabaseUnitOfWorkEvent.from(event)),
11+
dispatcher.dispatch(
12+
DATABASE_PRE_INSERT,
13+
DatabaseUnitOfWorkEvent.from(event),
14+
),
1215
);
1316
}
1417

15-
export const DatabasePreInsert = new EventToken<
18+
export const DATABASE_PRE_INSERT = new EventToken<
1619
DatabaseUnitOfWorkEvent<unknown>
1720
>("database:pre-insert");
21+
1822
// @deepkit/orm is built before @deepkit/event, so there are some differences
1923
// between their interfaces. Database events will migrate to @deepkit/event
2024
// in a future release.

src/user/user.entity.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Unique,
1010
} from "@deepkit/type";
1111
import { compare, hash } from "bcryptjs";
12-
import { DatabasePreInsert } from "src/database/database-event";
12+
import { DATABASE_PRE_INSERT } from "src/database/database-event";
1313
import { Entity } from "src/shared/entity";
1414

1515
@entity.name("user")
@@ -33,7 +33,7 @@ export class User extends Entity {
3333
export type UserPassword = string & MinLength<6> & MaxLength<50>;
3434

3535
export class UserEventListener {
36-
@eventDispatcher.listen(DatabasePreInsert)
36+
@eventDispatcher.listen(DATABASE_PRE_INSERT)
3737
async preInsert(event: UnitOfWorkEvent<User>): Promise<void> {
3838
if (event.classSchema.getClassType() !== User) return;
3939
await Promise.all(event.items.map((user) => user.hashPassword()));

0 commit comments

Comments
 (0)