Skip to content

Commit e704ef9

Browse files
Copilotfregante
andcommitted
Fix linting and vite config for tests
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
1 parent c7aa210 commit e704ef9

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

demo/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ const urls = [
142142

143143
const currentLocation = 'https://github.com/fregante/shorten-repo-url/issue/1';
144144

145-
const urlInput = document.getElementById('url-input');
146-
const output = document.getElementById('output');
147-
const examplesContainer = document.getElementById('examples');
145+
const urlInput = document.querySelector('#url-input');
146+
const output = document.querySelector('#output');
147+
const examplesContainer = document.querySelector('#examples');
148148

149149
function updateOutput(url) {
150150
if (!url) {
@@ -154,7 +154,7 @@ function updateOutput(url) {
154154
}
155155

156156
const shortened = shortenUrl(url, currentLocation);
157-
157+
158158
if (shortened) {
159159
output.classList.add('has-content');
160160
output.innerHTML = `
@@ -171,8 +171,8 @@ function updateOutput(url) {
171171
}
172172

173173
// Handle input changes
174-
urlInput.addEventListener('input', (e) => {
175-
updateOutput(e.target.value);
174+
urlInput.addEventListener('input', event => {
175+
updateOutput(event.target.value);
176176
});
177177

178178
// Initialize examples

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
},
3434
"xo": {
3535
"parser": "@typescript-eslint/parser",
36+
"ignores": [
37+
"demo/**"
38+
],
3639
"globals": [
3740
"document"
3841
],

vite.config.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ import {defineConfig} from 'vite';
44

55
const __dirname = fileURLToPath(new URL('.', import.meta.url));
66

7-
export default defineConfig({
8-
base: '',
9-
root: resolve(__dirname, 'demo'),
10-
build: {
11-
outDir: resolve(__dirname, 'demo/dist'),
12-
emptyOutDir: true,
13-
rollupOptions: {
14-
input: {
15-
main: resolve(__dirname, 'demo/index.html'),
7+
export default defineConfig(({command}) => {
8+
if (command === 'build') {
9+
return {
10+
base: '',
11+
root: resolve(__dirname, 'demo'),
12+
build: {
13+
outDir: resolve(__dirname, 'demo/dist'),
14+
emptyOutDir: true,
15+
rollupOptions: {
16+
input: {
17+
main: resolve(__dirname, 'demo/index.html'),
18+
},
19+
},
1620
},
17-
},
18-
},
21+
};
22+
}
23+
24+
// Default config for test/serve
25+
return {};
1926
});

0 commit comments

Comments
 (0)