8000 ci: lint browser bridge with ESLint by Tigon32 · Pull Request #4 · Tigon32/miniquad · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/integration-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ jobs:
run: cargo build --release --target wasm32-unknown-unknown --example quad
- name: JavaScript syntax check
run: node --check js/gl.js
- name: Install JavaScript lint tools
run: npm install --no-audit --no-fund
- name: ESLint browser bridge
run: npm run lint:js
44 changes: 44 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** ESLint flat configuration for Miniquad's browser-facing JavaScript.
* Node syntax checking is also retained in CI.
* Keep the initial rules focused on correctness, not stylistic rewrites.
*/
export default [
{
files: ["js/**/*.js"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "script",
globals: {
window: "readonly",
document: "readonly",
navigator: "readonly",
console: "readonly",
performance: "readonly",
alert: "readonly",
requestAnimationFrame: "readonly",
cancelAnimationFrame: "readonly",
setTimeout: "readonly",
clearTimeout: "readonly",
fetch: "readonly",
Image: "readonly",
XMLHttpRequest: "readonly",
WebAssembly: "readonly",
TextDecoder: "readonly",
TextEncoder: "readonly",
atob: "readonly",
btoa: "readonly"
}
},
rules: {
"no-undef": "error",
"no-dupe-args": "error",
"no-duplicate-case": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-invalid-regexp": "error",
"no-fallthrough": "error",
"no-constant-condition": ["error", { checkLoops: false }],
"no-unused-vars": "off"
}
}
];
17 changes: 6 additions & 11 deletions js/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function _webglGet(name_, p, type) {
if (type != 'EM_FUNC_SIG_PARAM_I' && type != 'EM_FUNC_SIG_PARAM_I64') {
GL.recordError(0x500); // GL_INVALID_ENUM

err('GL_INVALID_ENUM in glGet' + type + 'v(GL_SHADER_BINARY_FORMATS): Invalid parameter type!');
console.error('GL_INVALID_ENUM in glGet' + type + 'v(GL_SHADER_BINARY_FORMATS): Invalid parameter type!');
}
return; // Do not write anything to the out pointer, since no binary formats are supported.
case 0x87FE: // GL_NUM_PROGRAM_BINARY_FORMATS
Expand Down Expand Up @@ -409,7 +409,7 @@ function _webglGet(name_, p, type) {
}

switch (type) {
case 'EM_FUNC_SIG_PARAM_I64': getArray(p, Int32Array, 1)[0] = ret;
case 'EM_FUNC_SIG_PARAM_I64':
case 'EM_FUNC_SIG_PARAM_I': getArray(p, Int32Array, 1)[0] = ret; break;
case 'EM_FUNC_SIG_PARAM_F': getArray(p, Float32Array, 1)[0] = ret; break;
case 'EM_FUNC_SIG_PARAM_B': getArray(p, Int8Array, 1)[0] = ret ? 1 : 0; break;
Expand Down Expand Up @@ -1151,7 +1151,7 @@ var importObject = {
},
glDeleteQueries: function (n, ids) {
for (var i = 0; i < n; i++) {
var id = getArray(textures + i * 4, Uint32Array, 1)[0];
var id = getArray(ids + i * 4, Uint32Array, 1)[0];
var query = GL.timerQueries[id];
if (!query) {
continue;
Expand Down Expand Up @@ -1247,16 +1247,11 @@ var importObject = {
canvas. (event) {
var sapp_key_code = into_sapp_keycode(event.code);
switch (sapp_key_code) {
// space, arrows - prevent scrolling of the page
// Space, arrows, F1-F10, backspace, tab, quote and slash:
// prevent browser scrolling and navigation when the canvas has focus.
case 32: case 262: case 263: case 264: case 265:
// F1-F10
case 290: case 291: case 292: case 293: case 294: case 295: case 296: case 297: case 298: case 299:
// backspace is Back on Firefox/Windows
case 259:
// tab - for UI
case 258:
// quote and slash are Quick Find on Firefox
case 39: case 47:
case 259: case 258: case 39: case 47:
event.preventDefault();
break;
}
Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "miniquad-js-tooling",
"private": true,
"description": "Development-only linting for Miniquad's browser bridge",
"scripts": {
"lint:js": "eslint js/gl.js"
},
"devDependencies": {
"eslint": "9.39.1"
}
}
Loading
0