Skip to content

Commit 8f6093d

Browse files
Chore/update eslint config (#48)
* Update eslint config to mjs * Update tsconfig target to ES2022 * Upgraded @stylistic/eslint-plugin package * Fix main tests workflow * Fix typescript error
1 parent ea9774c commit 8f6093d

File tree

7 files changed

+150
-144
lines changed

7 files changed

+150
-144
lines changed

.github/workflows/main-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
TEST_DB_HOST: localhost
1414
TEST_DB_NAME: test_db
1515
TEST_DB_PORT: 5432
16+
JWT_SECRET: secret
1617

1718
jobs:
1819
e2e-tests:

eslint.config.js

Lines changed: 0 additions & 133 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import importPlugin from 'eslint-plugin-import';
2+
import commentsPlugin from '@eslint-community/eslint-plugin-eslint-comments/configs';
3+
import stylistic from '@stylistic/eslint-plugin';
4+
import jseslint from '@eslint/js';
5+
import tseslint from 'typescript-eslint';
6+
import globals from 'globals';
7+
8+
export default tseslint.config(
9+
{
10+
ignores: ['build/*', 'src/infra/database/migrations/*', 'jest.config.ts', '**/tmp/**', '**/coverage/**', 'eslint.config.mjs'],
11+
},
12+
jseslint.configs.recommended,
13+
tseslint.configs.recommended,
14+
importPlugin.flatConfigs.recommended,
15+
importPlugin.flatConfigs.typescript,
16+
commentsPlugin.recommended,
17+
{
18+
files: ['**/*.ts', '**/*.mts'],
19+
extends: [...tseslint.configs.recommended],
20+
languageOptions: {
21+
parser: tseslint.parser,
22+
ecmaVersion: 2020,
23+
sourceType: 'module',
24+
25+
globals: {
26+
...globals.node,
27+
},
28+
29+
parserOptions: {
30+
project: './tsconfig.json',
31+
},
32+
},
33+
settings: {
34+
'import/resolver': {
35+
typescript: {
36+
alwaysTryTypes: true,
37+
project: './tsconfig.lint.json',
38+
}
39+
},
40+
},
41+
plugins: {
42+
'@typescript-eslint': tseslint.plugin,
43+
'@stylistic': stylistic,
44+
},
45+
rules: {
46+
// General rules
47+
"no-console": "warn",
48+
"no-duplicate-imports": "off",
49+
"camelcase": "warn",
50+
"require-await": "off",
51+
"arrow-body-style": ["warn", "as-needed"],
52+
"eqeqeq": "error",
53+
"object-shorthand": "warn",
54+
"prefer-const": "warn",
55+
"consistent-return": "error",
56+
57+
// TypeScript rules
58+
"@typescript-eslint/await-thenable": "error",
59+
"@typescript-eslint/require-await": "error",
60+
"@typescript-eslint/no-unnecessary-condition": "warn",
61+
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "req|res|next|err" }],
62+
"@typescript-eslint/consistent-type-imports": ["warn", { "prefer": "type-imports" }],
63+
"@typescript-eslint/no-floating-promises": "error",
64+
65+
// Import rules
66+
"import/default": "off",
67+
"import/no-duplicates": ["error"],
68+
"import/no-named-as-default-member": "off",
69+
"import/order": [
70+
"warn",
71+
{
72+
"groups": [
73+
["builtin", "external"],
74+
["internal", "index", "sibling", "parent", "object"]
75+
],
76+
"newlines-between": "always-and-inside-groups"
77+
}
78+
],
79+
80+
// Comments rules
81+
"@eslint-community/eslint-comments/no-unused-disable": "error",
82+
"@eslint-community/eslint-comments/disable-enable-pair": ["error", { "allowWholeFile": true }],
83+
84+
// Stylistic rules
85+
"@stylistic/array-bracket-spacing": ["warn", "never"],
86+
"@stylistic/array-element-newline": ["warn", "consistent"],
87+
"@stylistic/arrow-spacing": "warn",
88+
"@stylistic/block-spacing": "warn",
89+
"@stylistic/brace-style": ["warn", "1tbs", { "allowSingleLine": true }],
90+
"@stylistic/comma-spacing": ["warn", { "before": false, "after": true }],
91+
"@stylistic/computed-property-spacing": ["warn", "never"],
92+
"@stylistic/comma-style": ["warn", "last"],
93+
"@stylistic/function-call-spacing": ["warn", "never"],
94+
"@stylistic/function-call-argument-newline": ["warn", "consistent"],
95+
"@stylistic/function-paren-newline": ["warn", "multiline-arguments"],
96+
"@stylistic/indent": ['warn', 2],
97+
"@stylistic/indent-binary-ops": ["warn", 2],
98+
"@stylistic/key-spacing": "warn",
99+
"@stylistic/keyword-spacing": "warn",
100+
"@stylistic/member-delimiter-style": ["warn", {
101+
"multiline": {
102+
"delimiter": "semi",
103+
"requireLast": true
104+
},
105+
"singleline": {
106+
"delimiter": "semi",
107+
"requireLast": false
108+
}
109+
}],
110+
"@stylistic/new-parens": "warn",
111+
"@stylistic/semi": "warn",
112+
"@stylistic/no-extra-semi": "warn",
113+
"@stylistic/no-floating-decimal": "warn",
114+
"@stylistic/no-multi-spaces": "warn",
115+
"@stylistic/no-multiple-empty-lines": "warn",
116+
"@stylistic/no-trailing-spaces": "warn",
117+
"@stylistic/no-whitespace-before-property": "warn",
118+
"@stylistic/nonblock-statement-body-position": ["warn", "beside"],
119+
"@stylistic/object-curly-spacing": ["warn", "always"],
120+
"@stylistic/quote-props": ["warn", "as-needed"],
121+
"@stylistic/quotes": ["warn", "single", { "avoidEscape": true }],
122+
"@stylistic/rest-spread-spacing": "warn",
123+
"@stylistic/semi-spacing": "warn",
124+
"@stylistic/space-before-blocks": "warn",
125+
"@stylistic/space-before-function-paren": ["warn", { "anonymous": "ignore", "named": "never", "asyncArrow": "always" }],
126+
"@stylistic/space-in-parens": "warn",
127+
"@stylistic/space-infix-ops": "warn",
128+
"@stylistic/space-unary-ops": "warn",
129+
"@stylistic/spaced-comment": "warn",
130+
"@stylistic/switch-colon-spacing": "warn",
131+
"@stylistic/template-curly-spacing": "warn",
132+
"@stylistic/type-annotation-spacing": "warn",
133+
"@stylistic/type-named-tuple-spacing": "warn",
134+
"@stylistic/yield-star-spacing": ["error", "after"],
135+
}
136+
},
137+
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"devDependencies": {
4646
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
4747
"@eslint/js": "9.22.0",
48-
"@stylistic/eslint-plugin": "2.12.1",
48+
"@stylistic/eslint-plugin": "4.2.0",
4949
"@types/bcryptjs": "3.0.0",
5050
"@types/cors": "2.8.17",
5151
"@types/express": "4.17.21",

src/core/result/result.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export class Result<TValue, TFailure extends { error: Error }> {
2121
}
2222

2323
export class Success<T> extends Result<T, never> {
24-
value!: T;
24+
declare value: T;
2525
constructor(value: T) {
2626
super({ value });
2727
}
2828
}
2929

3030
export class Failure<TFailure extends { error: Error }> extends Result<never, TFailure> {
31-
failure!: TFailure;
31+
declare failure: TFailure;
3232
constructor(failure: TFailure) {
3333
super({ failure });
3434
}

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
},
77
"compilerOptions": {
88
"types": ["node", "jest"],
9-
"target": "ES2020",
10-
"module": "commonjs",
9+
"target": "ES2022",
10+
"module": "CommonJS",
11+
"lib": ["ES2022"],
1112
"moduleResolution": "node",
1213
"sourceMap": true,
1314
"outDir": "build",

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -720,12 +720,12 @@
720720
resolved "https://registry.yarnpkg.com/@sqltools/formatter/-/formatter-1.2.5.tgz#3abc203c79b8c3e90fd6c156a0c62d5403520e12"
721721
integrity sha512-Uy0+khmZqUrUGm5dmMqVlnvufZRSK0FbYzVgp0UMstm+F5+W2/jnEEQyc9vo1ZR/E5ZI/B1WjjoTqBqwJL6Krw==
722722

723-
"@stylistic/eslint-plugin@2.12.1":
724-
version "2.12.1"
725-
resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-2.12.1.tgz#e341beb4e4315084d8be20bceeeda7d8a46f079f"
726-
integrity sha512-fubZKIHSPuo07FgRTn6S4Nl0uXPRPYVNpyZzIDGfp7Fny6JjNus6kReLD7NI380JXi4HtUTSOZ34LBuNPO1XLQ==
723+
"@stylistic/eslint-plugin@4.2.0":
724+
version "4.2.0"
725+
resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-4.2.0.tgz#7860ea84aa7ee3b21757907b863eb62f4f8b0455"
726+
integrity sha512-8hXezgz7jexGHdo5WN6JBEIPHCSFyyU4vgbxevu4YLVS5vl+sxqAAGyXSzfNDyR6xMNSH5H1x67nsXcYMOHtZA==
727727
dependencies:
728-
"@typescript-eslint/utils" "^8.13.0"
728+
"@typescript-eslint/utils" "^8.23.0"
729729
eslint-visitor-keys "^4.2.0"
730730
espree "^10.3.0"
731731
estraverse "^5.3.0"
@@ -1054,7 +1054,7 @@
10541054
semver "^7.6.0"
10551055
ts-api-utils "^2.0.1"
10561056

1057-
"@typescript-eslint/utils@8.26.1", "@typescript-eslint/utils@^8.13.0":
1057+
"@typescript-eslint/utils@8.26.1", "@typescript-eslint/utils@^8.23.0":
10581058
version "8.26.1"
10591059
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.26.1.tgz#54cc58469955f25577f659753b71a0e117a0539f"
10601060
integrity sha512-V4Urxa/XtSUroUrnI7q6yUTD3hDtfJ2jzVfeT3VK0ciizfK2q/zGC0iDh1lFMUZR8cImRrep6/q0xd/1ZGPQpg==

0 commit comments

Comments
 (0)