Skip to content

Commit

Permalink
chore: migrate to eslint v9 (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 16, 2024
1 parent 8085527 commit 34e6224
Show file tree
Hide file tree
Showing 40 changed files with 769 additions and 672 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

20 changes: 20 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @ts-check
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'

export default createConfigForNuxt({
features: {
tooling: true,
stylistic: true,
},
dirs: {
src: [
'./playground',
],
},
}).append({
rules: {
'vue/singleline-html-element-content-newline': 'off',
// TODO: remove usage of `any` throughout codebase
'@typescript-eslint/no-explicit-any': 'off',
},
})
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"build:stub": "unbuild --stub",
"dev": "node ./bin/nuxi.mjs dev ./playground",
"dev:bun": "bun --bun ./bin/nuxi.mjs dev ./playground",
"lint": "eslint . && prettier --check src",
"lint:fix": "eslint --fix . && prettier --write src",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"nuxi": "node ./bin/nuxi.mjs",
"nuxi-bun": "bun --bun ./bin/nuxi.mjs",
"prepack": "unbuild",
Expand All @@ -37,7 +37,7 @@
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@nuxt/eslint-config": "^0.3.6",
"@nuxt/eslint-config": "^0.3.12",
"@nuxt/kit": "^3.11.2",
"@nuxt/schema": "^3.11.2",
"@nuxt/test-utils": "^3.13.0",
Expand All @@ -53,7 +53,7 @@
"colorette": "^2.0.20",
"consola": "^3.2.3",
"destr": "^2.0.3",
"eslint": "^8.57.0",
"eslint": "^9.2.0",
"execa": "^8.0.1",
"fuse.js": "^7.0.0",
"giget": "^1.2.3",
Expand All @@ -69,7 +69,6 @@
"pathe": "^1.1.2",
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.0.3",
"prettier": "^3.2.5",
"scule": "^1.3.0",
"semver": "^7.6.0",
"unbuild": "^2.0.0",
Expand All @@ -89,4 +88,4 @@
"engines": {
"node": "^16.10.0 || >=18.0.0"
}
}
}
6 changes: 3 additions & 3 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export default defineNuxtConfig({
nitro: {
experimental: {
websocket: true
}
}
websocket: true,
},
},
})
4 changes: 2 additions & 2 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<template>
<div>
Welcome to the Nuxt CLI playground!
<br />
<br />
<br>
<br>
<NuxtLink to="/ws"> /ws </NuxtLink>
</div>
</template>
73 changes: 37 additions & 36 deletions playground/pages/ws.vue
Original file line number Diff line number Diff line change
@@ -1,59 +1,58 @@
<script setup lang="ts">
const logs = ref<string[]>([])
const log = (...args: any[]) => {
console.log("[ws]", ...args);
logs.value.push(args.join(" "));
};
console.log('[ws]', ...args)
logs.value.push(args.join(' '))
}
let ws: WebSocket | undefined
const connect = async () => {
const isSecure = location.protocol === "https:";
const url = (isSecure ? "wss://" : "ws://") + location.host + "/_ws";
const isSecure = location.protocol === 'https:'
const url = (isSecure ? 'wss://' : 'ws://') + location.host + '/_ws'
if (ws) {
log("Closing...");
ws.close();
log('Closing...')
ws.close()
}
log("Connecting to", url, "...");
ws = new WebSocket(url);
log('Connecting to', url, '...')
ws = new WebSocket(url)
ws.addEventListener("close", () => {
log("Connection closed");
});
ws.addEventListener('close', () => {
log('Connection closed')
})
ws.addEventListener("error", (event) => {
log("Error:", event);
});
ws.addEventListener('error', (event) => {
log('Error:', event)
})
ws.addEventListener("message", (event) => {
log("Message from server:", event.data);
});
ws.addEventListener('message', (event) => {
log('Message from server:', event.data)
})
log("Waiting for connection...");
await new Promise((resolve) => ws!.addEventListener("open", resolve));
};
log('Waiting for connection...')
await new Promise(resolve => ws!.addEventListener('open', resolve))
}
const clearLogs = () => {
logs.value = []
};
}
const sendPing = () => {
log("Sending ping...");
ws?.send("ping");
};
log('Sending ping...')
ws?.send('ping')
}
const message = ref<string>("ping")
const message = ref<string>('ping')
const sendMessage = () => {
ws?.send(message.value);
};
ws?.send(message.value)
}
onMounted(async () => {
await connect();
sendPing();
await connect()
sendPing()
})
</script>

Expand All @@ -80,7 +79,7 @@ onMounted(async () => {
class="ms-secondary ms-small"
placeholder="Message..."
@keydown.enter="sendMessage"
/>
>
</div>
<div class="col-sm-1">
<button
Expand All @@ -91,13 +90,15 @@ onMounted(async () => {
</button>
</div>
</div>
<br />
<br>
</div>
<pre id="logs">
<div
v-for="log in logs"
:key="log"
>{{ log }}</div>
v-for="l in logs"
:key="l"
>
{{ l }}
</div>
</pre>
</div>
</template>
Expand Down
14 changes: 7 additions & 7 deletions playground/server/routes/_ws.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export default defineWebSocketHandler({
open(peer) {
console.log("[ws] open", peer);
console.log('[ws] open', peer)
},

message(peer, message) {
console.log("[ws] message", peer, message);
if (message.text().includes("ping")) {
peer.send("pong");
console.log('[ws] message', peer, message)
if (message.text().includes('ping')) {
peer.send('pong')
}
},

close(peer, event) {
console.log("[ws] close", peer, event);
console.log('[ws] close', peer, event)
},

error(peer, error) {
console.log("[ws] error", peer, error);
console.log('[ws] error', peer, error)
},
});
})
Loading

0 comments on commit 34e6224

Please sign in to comment.