Skip to content

Commit 3543a34

Browse files
Add ESLint overrides and GitHub Actions workflow for linting
- Updated .eslintrc.cjs to disable the no-unused-vars rule for test files located in tests//.js and utils//.test.js. -
1 parent 1bc6e4e commit 3543a34

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

.eslintrc.cjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,13 @@ module.exports = {
1010
plugins: [],
1111
rules: {},
1212
settings: {},
13-
overrides: [],
13+
overrides: [
14+
{
15+
// Disable the no-unused-vars rule for test files
16+
files: ['tests/**/*.js', 'utils/**/*.test.js'],
17+
rules: {
18+
'@typescript-eslint/no-unused-vars': 'off',
19+
},
20+
},
21+
],
1422
}

.github/workflows/lint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Lint
2+
on:
3+
pull_request: ~
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: ./.github/actions/prepare
13+
- run: pnpm lint

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ const gptCommit = async () => {
122122
}
123123
}
124124

125-
const gitExtension = (args) => {
125+
const gitExtension = (_args) => {
126126
// Load configuration at startup
127127
loadConfig()
128128

129-
// Extract the command and arguments from the command line
130-
const [command, ...rest] = args
129+
// No need to extract command and args since we're using Commander
131130

132131
program
133132
.command('commit')

tests/index.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import fs from 'fs'
2-
import path from 'path'
3-
41
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
52

63
import * as gitGptCommit from '../index.js'

tests/setup-mocks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ vi.mock('openai', () => {
2424
// Mock the entire index.js module
2525
vi.mock('../index.js', () => {
2626
return {
27-
getGitSummary: vi.fn((options) => {
27+
getGitSummary: vi.fn((_options) => {
2828
try {
2929
// Check if there are file changes without actually executing the diff command
3030
const gitStatus = require('child_process')
@@ -37,11 +37,11 @@ vi.mock('../index.js', () => {
3737

3838
// Return mocked diff content
3939
return `diff --git a/file1.js b/file1.js\nindex 123456..789012 100644\n--- a/file1.js\n+++ b/file1.js\n@@ -1,5 +1,8 @@\nfunction greet(name) {\n- return \`Hello, \${name}!\`;\n+ // Add default value when name is empty\n+ const userName = name || 'Guest';\n+ return \`Hello, \${userName}!\`;\n }`
40-
} catch (error) {
40+
} catch (__) {
4141
throw new Error('Failed to get git summary')
4242
}
4343
}),
44-
gptCommit: vi.fn(async (options = {}) => {
44+
gptCommit: vi.fn(async (_options = {}) => {
4545
return 'Mock commit message'
4646
}),
4747
gitExtension: vi.fn(),

0 commit comments

Comments
 (0)