Skip to content

Commit 055850f

Browse files
committed
chore: Linter stuff
1 parent a75e067 commit 055850f

File tree

5 files changed

+106
-38
lines changed

5 files changed

+106
-38
lines changed

.eslintrc.json

Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"root": true,
3-
"plugins": ["simple-import-sort", "unused-imports"],
3+
"plugins": [
4+
"simple-import-sort",
5+
"unused-imports"
6+
],
47
"parserOptions": {
58
"sourceType": "module",
69
"ecmaVersion": "latest"
@@ -18,7 +21,10 @@
1821
"ignoreRestSiblings": true
1922
}
2023
],
21-
"import/extensions": ["error", "ignorePackages"],
24+
"import/extensions": [
25+
"error",
26+
"ignorePackages"
27+
],
2228
"import/no-duplicates": [
2329
"error",
2430
{
@@ -30,26 +36,54 @@
3036
"error",
3137
{
3238
"groups": [
33-
["^\\u0000"],
34-
["^node:"],
35-
["^@?\\w"],
36-
["@seamapi/dbtypr"],
37-
["^lib/"],
38-
["^"],
39-
["^\\."]
39+
[
40+
"^\\u0000"
41+
],
42+
[
43+
"^node:"
44+
],
45+
[
46+
"^@?\\w"
47+
],
48+
[
49+
"@seamapi/dbtypr"
50+
],
51+
[
52+
"^lib/"
53+
],
54+
[
55+
"^"
56+
],
57+
[
58+
"^\\."
59+
]
4060
]
4161
}
4262
],
43-
"simple-import-sort/exports": "error"
63+
"simple-import-sort/exports": "error",
64+
"@typescript-eslint/explicit-function-return-type": "off"
4465
},
4566
"overrides": [
4667
{
47-
"files": ["*.js", "*.mjs", "*.cjs"],
48-
"extends": ["standard", "prettier"]
68+
"files": [
69+
"*.js",
70+
"*.mjs",
71+
"*.cjs"
72+
],
73+
"extends": [
74+
"standard",
75+
"prettier"
76+
]
4977
},
5078
{
51-
"files": ["*.ts", "*.tsx"],
52-
"extends": ["standard-with-typescript", "prettier"],
79+
"files": [
80+
"*.ts",
81+
"*.tsx"
82+
],
83+
"extends": [
84+
"standard-with-typescript",
85+
"prettier"
86+
],
5387
"parserOptions": {
5488
"project": "./tsconfig.json"
5589
},
@@ -65,8 +99,13 @@
6599
"@typescript-eslint/naming-convention": [
66100
"error",
67101
{
68-
"selector": ["interface", "typeAlias"],
69-
"format": ["PascalCase"],
102+
"selector": [
103+
"interface",
104+
"typeAlias"
105+
],
106+
"format": [
107+
"PascalCase"
108+
],
70109
"leadingUnderscore": "forbid",
71110
"trailingUnderscore": "forbid"
72111
},
@@ -78,32 +117,59 @@
78117
"variable",
79118
"parameter"
80119
],
81-
"types": ["function"],
82-
"format": ["camelCase"]
120+
"types": [
121+
"function"
122+
],
123+
"format": [
124+
"camelCase"
125+
]
83126
},
84127
{
85-
"selector": ["objectLiteralProperty"],
128+
"selector": [
129+
"objectLiteralProperty"
130+
],
86131
"format": null
87132
},
88133
{
89-
"selector": ["parameterProperty", "variable", "parameter"],
90-
"types": ["boolean", "string", "number", "array"],
91-
"format": ["snake_case", "UPPER_CASE"],
134+
"selector": [
135+
"parameterProperty",
136+
"variable",
137+
"parameter"
138+
],
139+
"types": [
140+
"boolean",
141+
"string",
142+
"number",
143+
"array"
144+
],
145+
"format": [
146+
"snake_case",
147+
"UPPER_CASE"
148+
],
92149
"leadingUnderscore": "allow",
93150
"trailingUnderscore": "allow"
94151
},
95152
{
96-
"selector": ["function"],
97-
"format": ["camelCase"]
153+
"selector": [
154+
"function"
155+
],
156+
"format": [
157+
"camelCase"
158+
]
98159
},
99160
{
100161
"selector": "default",
101-
"format": ["camelCase", "snake_case", "UPPER_CASE", "PascalCase"],
162+
"format": [
163+
"camelCase",
164+
"snake_case",
165+
"UPPER_CASE",
166+
"PascalCase"
167+
],
102168
"leadingUnderscore": "allow",
103169
"trailingUnderscore": "forbid"
104170
}
105171
]
106172
}
107173
}
108174
]
109-
}
175+
}

src/lib/file-generators/generated/[schema_name]/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ export const createSchemaGeneratedTypeIndexFile = (
3838
]
3939

4040
for (const table of tables) {
41+
const pascal_table_name = pascal_table_names[table.name] ?? ''
42+
4143
statements.push({
4244
kind: StructureKind.ImportDeclaration,
4345
isTypeOnly: true,
44-
moduleSpecifier: `./${pascal_table_names[table.name]}`,
46+
moduleSpecifier: `./${pascal_table_name}`,
4547
namedImports: [
46-
pascal_table_names[table.name]!,
48+
pascal_table_name,
4749
...(table.is_affected_by_pgtui_bugs
48-
? [`${pascal_table_names[table.name]}WithPgtuiBugs`]
50+
? [`${pascal_table_name}WithPgtuiBugs`]
4951
: []),
50-
`${pascal_table_names[table.name]}Initializer`,
52+
`${pascal_table_name}Initializer`,
5153
],
5254
})
5355
}
@@ -71,7 +73,7 @@ export const createSchemaGeneratedTypeIndexFile = (
7173
(writer) => writer.newLine(),
7274
)
7375

74-
if (config.generate_knex_types) {
76+
if (config.generate_knex_types === true) {
7577
statements.push({
7678
kind: StructureKind.Interface,
7779
isExported: true,
@@ -83,7 +85,7 @@ export const createSchemaGeneratedTypeIndexFile = (
8385
: `"${schema.name}.${table.name}"`,
8486
type: table.is_affected_by_pgtui_bugs
8587
? `${pascal_table_names[table.name]}WithPgtuiBugs`
86-
: pascal_table_names[table.name]!,
88+
: (pascal_table_names[table.name] ?? ''),
8789
})),
8890
})
8991
}
@@ -107,7 +109,7 @@ export const createSchemaGeneratedTypeIndexFile = (
107109
kind: StructureKind.ExportDeclaration,
108110
isTypeOnly: true,
109111
namedExports: tables.flatMap((table) => [
110-
pascal_table_names[table.name]!,
112+
pascal_table_names[table.name] ?? '',
111113
...(table.is_affected_by_pgtui_bugs
112114
? [`${pascal_table_names[table.name]}WithPgtuiBugs`]
113115
: []),

src/lib/file-generators/generated/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const createGeneratedIndexFile = (
8383
},
8484
]
8585

86-
if (config.generate_knex_types) {
86+
if (config.generate_knex_types === true) {
8787
statements.push({
8888
kind: StructureKind.ExportDeclaration,
8989
namespaceExport: 'knex',

src/lib/generate-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const createGeneratedTypesFiles = (
4343
createGeneratedUtilsFile({ project }, config),
4444
]
4545

46-
if (config.generate_knex_types) {
46+
if (config.generate_knex_types === true) {
4747
generated_types_files.push(
4848
createKnexIndexFile({ project, schemas }, config),
4949
)
@@ -86,7 +86,7 @@ const createCustomTypesFiles = (
8686
createCustomTypesFile({ project, schema, table }, config),
8787
)
8888
} catch (error: any) {
89-
if (error.message.includes('A source file already exists')) {
89+
if (error.message.includes('A source file already exists') === true) {
9090
continue
9191
}
9292
throw error as Error

src/lib/read-database-tree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const readDatabaseTree = (config: Config): DatabaseTree => {
1717
const source_file = project.addSourceFileAtPath(`${zapatos_dir}/schema.d.ts`)
1818
const zapatos_module = source_file.getModules()[0]
1919

20-
if (!zapatos_module) {
20+
if (zapatos_module === undefined) {
2121
throw new Error('Could not find the zapatos module in the schema file')
2222
}
2323

@@ -123,7 +123,7 @@ const readCustomZapatosTypes = (config: Config) => {
123123
for (const source_file of source_files) {
124124
const zapatos_module = source_file.getModules()[0]
125125

126-
if (!zapatos_module) {
126+
if (zapatos_module === undefined) {
127127
throw new Error('Could not find the zapatos module in the schema file')
128128
}
129129

0 commit comments

Comments
 (0)