Skip to content

Commit 800082c

Browse files
committed
update eslint and workflow
1 parent 1418f06 commit 800082c

2 files changed

Lines changed: 57 additions & 36 deletions

File tree

.github/workflows/backend-ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ on:
44
push:
55
branches: [ "main", "QUY-TRINH-1", "QUY-TRINH-2", "QUY-TRINH-3", "QUY-TRINH-4", "SOURCE" ]
66
paths:
7-
- 'backend/**'
7+
- 'Backend/**'
88
- '.github/workflows/backend-ci.yml'
99
pull_request:
1010
branches: [ "main", "QUY-TRINH-1", "QUY-TRINH-2", "QUY-TRINH-3", "QUY-TRINH-4", "SOURCE" ]
1111
paths:
12-
- 'backend/**'
12+
- 'Backend/**'
1313
- '.github/workflows/backend-ci.yml'
1414

1515
jobs:
16-
1716
build:
1817
runs-on: ubuntu-latest
1918
strategy:
@@ -27,13 +26,11 @@ jobs:
2726
with:
2827
node-version: ${{ matrix.node-version }}
2928
cache: 'npm'
30-
cache-dependency-path: 'backend/package-lock.json'
3129
- name: Install dependencies
32-
working-directory: ./backend
3330
run: npm ci
31+
- name: Code Quality - Lint
32+
run: npm run lint
3433
- name: Build
35-
working-directory: ./backend
3634
run: npm run build --if-present
3735
- name: Run tests
38-
working-directory: ./backend
3936
run: npm test

backend/eslint.config.mjs

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,55 @@
1-
module.exports = {
2-
parser: '@typescript-eslint/parser',
3-
parserOptions: {
4-
project: 'tsconfig.json',
5-
tsconfigRootDir: __dirname,
6-
sourceType: 'module',
1+
import { dirname } from 'path';
2+
import { fileURLToPath } from 'url';
3+
import tsPlugin from '@typescript-eslint/eslint-plugin';
4+
import tsParser from '@typescript-eslint/parser';
5+
import prettierConfig from 'eslint-config-prettier';
6+
import prettierPlugin from 'eslint-plugin-prettier';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = dirname(__filename);
10+
11+
export default [
12+
{
13+
ignores: [
14+
'**/node_modules/**',
15+
'**/dist/**',
16+
'**/.eslintrc.js',
17+
'**/coverage/**',
18+
],
719
},
8-
plugins: ['@typescript-eslint/eslint-plugin'],
9-
extends: [
10-
'plugin:@typescript-eslint/recommended',
11-
'plugin:prettier/recommended',
12-
],
13-
root: true,
14-
env: {
15-
node: true,
16-
jest: true,
20+
{
21+
files: ['**/*.ts'],
22+
languageOptions: {
23+
parser: tsParser,
24+
parserOptions: {
25+
project: './tsconfig.json',
26+
tsconfigRootDir: __dirname,
27+
sourceType: 'module',
28+
},
29+
globals: {
30+
node: true,
31+
jest: true,
32+
},
33+
},
34+
plugins: {
35+
'@typescript-eslint': tsPlugin,
36+
prettier: prettierPlugin,
37+
},
38+
rules: {
39+
...tsPlugin.configs.recommended.rules,
40+
...prettierConfig.rules,
41+
'@typescript-eslint/interface-name-prefix': 'off',
42+
'@typescript-eslint/explicit-function-return-type': 'off',
43+
'@typescript-eslint/explicit-module-boundary-types': 'off',
44+
'@typescript-eslint/no-explicit-any': 'off',
45+
'@typescript-eslint/no-unused-vars': 'warn',
46+
'@typescript-eslint/ban-ts-comment': 'warn',
47+
'prettier/prettier': [
48+
'error',
49+
{
50+
endOfLine: 'auto',
51+
},
52+
],
53+
},
1754
},
18-
ignorePatterns: ['.eslintrc.js'],
19-
rules: {
20-
'@typescript-eslint/interface-name-prefix': 'off',
21-
'@typescript-eslint/explicit-function-return-type': 'off',
22-
'@typescript-eslint/explicit-module-boundary-types': 'off',
23-
'@typescript-eslint/no-explicit-any': 'off',
24-
},
25-
"prettier/prettier": [
26-
"error",
27-
{
28-
"endOfLine": "auto"
29-
}
30-
]
31-
};
55+
];

0 commit comments

Comments
 (0)