Skip to content

Commit d5c1871

Browse files
chore: Add ESLint and Prettier configuration files for code quality (#26)
- Introduced `.prettierrc` for consistent code formatting with specified rules. - Added `.prettierignore` to exclude certain directories from formatting. - Created `eslint.config.mjs` to configure ESLint with TypeScript support and various plugins for improved code quality. - Updated `package.json` and `package-lock.json` to include necessary ESLint and Prettier dependencies. - Added `tsconfig.json` for TypeScript compilation settings. - Modified `vitest.config.ts` to export the configuration properly. These changes enhance code quality and maintainability by integrating ESLint and Prettier into the project.
1 parent 5e32dbd commit d5c1871

File tree

8 files changed

+4186
-464
lines changed

8 files changed

+4186
-464
lines changed

.github/workflows/code-quality.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ jobs:
1414
steps:
1515
- name: Checkout code
1616
uses: actions/checkout@v4
17-
- name: Run linting
18-
run: echo "Linting..."
17+
- name: Install dependencies
18+
run: cd workers/main && npm ci
19+
- name: Run ESLint
20+
run: cd workers/main && npm run eslint
1921

2022
sonarqube:
2123
name: SonarQube

workers/main/.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
/.nx/cache

workers/main/.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"trailingComma": "all",
3+
"printWidth": 80,
4+
"tabWidth": 2,
5+
"semi": true,
6+
"singleQuote": true,
7+
"bracketSpacing": true,
8+
"bracketSameLine": false,
9+
"endOfLine": "auto",
10+
"quoteProps": "consistent"
11+
}

workers/main/eslint.config.mjs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import tseslint from '@typescript-eslint/eslint-plugin';
2+
import tsparser from '@typescript-eslint/parser';
3+
import prettier from 'eslint-plugin-prettier';
4+
import eslintImport from 'eslint-plugin-import';
5+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
6+
7+
export default [
8+
{
9+
settings: {
10+
'import/resolver': {
11+
typescript: {
12+
extensions: [".ts"]
13+
},
14+
},
15+
},
16+
languageOptions: {
17+
ecmaVersion: 2021,
18+
sourceType: 'module',
19+
parser: tsparser,
20+
parserOptions: {
21+
project: './tsconfig.json',
22+
},
23+
},
24+
plugins: {
25+
'@typescript-eslint': tseslint,
26+
'prettier': prettier,
27+
'import': eslintImport,
28+
'simple-import-sort': simpleImportSort,
29+
},
30+
ignores: [
31+
'node_modules',
32+
'dist',
33+
'eslint.config.mjs',
34+
'coverage',
35+
'coverage/*',
36+
'coverage/**/*'
37+
],
38+
rules: {
39+
...tseslint.configs.recommended.rules,
40+
...tseslint.configs['recommended-requiring-type-checking'].rules,
41+
...prettier.configs.recommended.rules,
42+
43+
'prettier/prettier': 'error',
44+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
45+
'no-console': 'warn',
46+
'no-debugger': 'warn',
47+
'import/no-unresolved': 'error',
48+
'padding-line-between-statements': [
49+
'error',
50+
{ blankLine: 'always', prev: '*', next: 'return' },
51+
{
52+
blankLine: 'always',
53+
prev: ['const', 'let', 'var', 'import'],
54+
next: '*',
55+
},
56+
{
57+
blankLine: 'any',
58+
prev: ['const', 'let', 'var', 'import'],
59+
next: ['const', 'let', 'var', 'import'],
60+
},
61+
],
62+
'simple-import-sort/imports': 'error',
63+
'simple-import-sort/exports': 'error',
64+
},
65+
},
66+
];

0 commit comments

Comments
 (0)