Skip to content

Commit 5b70367

Browse files
authored
Merge pull request #12 from kubit-ui/bugfix/eslint-errors
feat(workflow): modify workflow and fix eslint errors
2 parents 61bf194 + 80c795d commit 5b70367

File tree

3 files changed

+83
-12
lines changed

3 files changed

+83
-12
lines changed

.github/workflows/pr-validation.yml

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,50 @@ jobs:
8383
# Title length is now just a warning
8484
echo "title_length_valid=true" >> $GITHUB_OUTPUT
8585
86+
- name: ESLint Validation
87+
id: eslint-validation
88+
run: |
89+
echo "Running ESLint..."
90+
91+
# Check if ESLint script exists and run it
92+
if yarn run --help | grep -q "lint"; then
93+
echo "Found lint script, running ESLint..."
94+
if yarn lint; then
95+
echo "✅ ESLint passed"
96+
echo "eslint_valid=true" >> $GITHUB_OUTPUT
97+
else
98+
echo "❌ ESLint failed - code must pass linting to merge"
99+
echo "eslint_valid=false" >> $GITHUB_OUTPUT
100+
exit 1 # This will fail the job and block merge
101+
fi
102+
elif yarn run --help | grep -q "eslint"; then
103+
echo "Found eslint script, running ESLint..."
104+
if yarn eslint; then
105+
echo "✅ ESLint passed"
106+
echo "eslint_valid=true" >> $GITHUB_OUTPUT
107+
else
108+
echo "❌ ESLint failed - code must pass linting to merge"
109+
echo "eslint_valid=false" >> $GITHUB_OUTPUT
110+
exit 1 # This will fail the job and block merge
111+
fi
112+
else
113+
echo "⚠️ No ESLint script found - checking for eslint.config.js"
114+
if [ -f "eslint.config.js" ] || [ -f ".eslintrc.js" ] || [ -f ".eslintrc.json" ]; then
115+
echo "ESLint config found, running with npx..."
116+
if npx eslint . --ext .js,.jsx,.ts,.tsx; then
117+
echo "✅ ESLint passed"
118+
echo "eslint_valid=true" >> $GITHUB_OUTPUT
119+
else
120+
echo "❌ ESLint failed - code must pass linting to merge"
121+
echo "eslint_valid=false" >> $GITHUB_OUTPUT
122+
exit 1 # This will fail the job and block merge
123+
fi
124+
else
125+
echo "⚠️ No ESLint configuration found - skipping"
126+
echo "eslint_valid=true" >> $GITHUB_OUTPUT
127+
fi
128+
fi
129+
86130
- name: Test Coverage
87131
id: test-validation
88132
continue-on-error: true
@@ -116,11 +160,13 @@ jobs:
116160
script: |
117161
const branchName = '${{ github.head_ref }}';
118162
const prTitle = '${{ github.event.pull_request.title }}';
163+
const eslintValid = '${{ steps.eslint-validation.outputs.eslint_valid }}';
119164
120-
// Simplified validation - everything passes by default
121-
let status = '✅ **PASSED**';
165+
// Check if ESLint validation passed
166+
let status = eslintValid === 'true' ? '✅ **PASSED**' : '❌ **FAILED**';
167+
const eslintStatus = eslintValid === 'true' ? '✅ Pass' : '❌ Fail';
122168
123-
// Generate simple report
169+
// Generate report with ESLint status
124170
let report = `## 🔍 PR Validation Report
125171
126172
**Status:** ${status}
@@ -129,10 +175,11 @@ jobs:
129175
130176
---
131177
132-
### Validation Results
178+
### Validation Results
133179
134180
| Check | Status | Description |
135181
|-------|--------|-------------|
182+
| **ESLint** | ${eslintStatus} | Code linting validation ${eslintValid === 'true' ? '(Required ✅)' : '(Required ❌)'} |
136183
| **Basic Validation** | ✅ Pass | PR structure validated |
137184
| **Branch Check** | ✅ Pass | Branch name accepted |
138185
| **Tests** | ✅ Pass | Tests completed |
@@ -141,7 +188,21 @@ jobs:
141188
142189
### 🎯 Next Steps
143190
144-
**This PR is ready for review** - all validation checks passed!
191+
${eslintValid === 'true'
192+
? '**This PR is ready for review** - all validation checks passed!'
193+
: '**❌ This PR cannot be merged** - ESLint validation failed. Please fix linting errors and push again.'
194+
}
195+
196+
${eslintValid !== 'true'
197+
? `
198+
**To fix ESLint errors:**
199+
1. Run \`yarn lint\` locally to see all errors
200+
2. Fix the linting issues in your code
201+
3. Commit and push the fixes
202+
4. The validation will run automatically again
203+
`
204+
: ''
205+
}
145206
146207
---
147208
@@ -179,5 +240,9 @@ jobs:
179240
console.log('Could not post comment:', error.message);
180241
}
181242
182-
// Always pass
183-
core.info('✅ All PR validation checks passed - ready for review!');
243+
// Check if ESLint passed - fail if not
244+
if (eslintValid !== 'true') {
245+
core.setFailed('❌ PR validation failed: ESLint errors must be fixed before merge');
246+
} else {
247+
core.info('✅ All PR validation checks passed - ready for review!');
248+
}

src/extension.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ function registerGitListeners(context: vscode.ExtensionContext): void {
125125
const logsWatcher = vscode.workspace.createFileSystemWatcher('**/.git/logs/HEAD');
126126

127127
logsWatcher.onDidChange(() => {
128-
if (!kubitoWebviewProvider || !isEventEnabled('gitCommit')) return;
128+
if (!kubitoWebviewProvider || !isEventEnabled('gitCommit')) {
129+
return;
130+
}
129131

130132
kubitoWebviewProvider.triggerMessage({
131133
content: t('messages.committed'),
@@ -137,7 +139,9 @@ function registerGitListeners(context: vscode.ExtensionContext): void {
137139
const refsLogsWatcher = vscode.workspace.createFileSystemWatcher('**/.git/logs/refs/remotes/**');
138140

139141
refsLogsWatcher.onDidChange(() => {
140-
if (!kubitoWebviewProvider || !isEventEnabled('gitPush')) return;
142+
if (!kubitoWebviewProvider || !isEventEnabled('gitPush')) {
143+
return;
144+
}
141145

142146
kubitoWebviewProvider.triggerMessage({
143147
content: t('messages.pushed'),
@@ -154,8 +158,10 @@ function registerGitListeners(context: vscode.ExtensionContext): void {
154158
*/
155159
function registerEditorEventListeners(context: vscode.ExtensionContext): void {
156160
// Listen for file save events
157-
const onSaveListener = vscode.workspace.onDidSaveTextDocument(document => {
158-
if (!kubitoWebviewProvider || !isEventEnabled('fileSave')) return;
161+
const onSaveListener = vscode.workspace.onDidSaveTextDocument(() => {
162+
if (!kubitoWebviewProvider || !isEventEnabled('fileSave')) {
163+
return;
164+
}
159165

160166
kubitoWebviewProvider.triggerMessage({
161167
content: '💾',

src/webview/kubito.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function getWebviewTranslation(key: string): string {
119119
// Get translations from window object or use defaults
120120
const translations = (window as any).kubitoTranslations || {
121121
sleeping: 'Zzz...',
122-
letsCode: "Let's code! 🚀",
122+
letsCode: 'Let\'s code! 🚀',
123123
coffee: 'Coffee? ☕️',
124124
vivaKubit: 'Viva Kubit!'
125125
};

0 commit comments

Comments
 (0)