Skip to content

Commit

Permalink
new eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Apr 20, 2024
1 parent 88faaf8 commit c61e2ff
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 198 deletions.
22 changes: 0 additions & 22 deletions .eslintrc.yml

This file was deleted.

30 changes: 30 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import prettier from "eslint-plugin-prettier";
import eslintConfigPrettier from "eslint-config-prettier";
import js from "@eslint/js";
import globals from "globals";

export default [
js.configs.recommended,
eslintConfigPrettier,
{
plugins: { prettier },
// env: {
// browser: true,
// amd: true,
// commonjs: true,
// es2021: true,
// node: true
// },
ignores: ["lib/", "out/"],
languageOptions: {
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
},
globals: {
...globals.browser,
...globals.node,
},
},
},
];
4 changes: 2 additions & 2 deletions lib/jsunzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function JSUnzip() {
var lastModFileDate = this.getInt(fileOffset + 14, 2);
var lastModifiedDate = this.getDOSDate(lastModFileDate, lastModFileTime);

var crc = this.getInt(fileOffset + 16, 4);
//var crc = this.getInt(fileOffset + 16, 4);
// TODO: crc

var compressedSize = this.getInt(fileOffset + 20, 4);
Expand Down Expand Up @@ -470,7 +470,7 @@ export function TINF() {
var ddest = d.dest;
var ddestlength = d.destIndex;

while (1) {
while (true) {
var sym = this.decode_symbol(d, lt);

/* check for end of block */
Expand Down
52 changes: 9 additions & 43 deletions lib/webgl-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function glEnumToString(value) {
function glFunctionArgToString(functionName, numArgs, argumentIndex, value) {
var funcInfo = glValidEnumContexts[functionName];
if (funcInfo !== undefined) {
var funcInfo = funcInfo[numArgs];
funcInfo = funcInfo[numArgs];
if (funcInfo !== undefined) {
if (funcInfo[argumentIndex]) {
if (
Expand Down Expand Up @@ -304,17 +304,6 @@ function makePropertyWrapper(wrapper, original, propertyName) {
});
}

// Makes a function that calls a function on another object.
function makeFunctionWrapper(original, functionName) {
//log("wrap fn: " + functionName);
var f = original[functionName];
return function () {
//log("call: " + functionName);
var result = f.apply(original, arguments);
return result;
};
}

/**
* Given a WebGL context returns a wrapped context that calls
* gl.getError after every command and calls a function if the
Expand Down Expand Up @@ -389,7 +378,7 @@ function makeDebugContext(ctx, opt_onErrorFunc, opt_onFunc, opt_err_ctx) {
// Override the getError function with one that returns our saved results.
wrapper.getError = function () {
for (var err in glErrorShadow) {
if (glErrorShadow.hasOwnProperty(err)) {
if (Object.prototype.hasOwnProperty.call(glErrorShadow, err)) {
if (glErrorShadow[err]) {
glErrorShadow[err] = false;
return err;
Expand All @@ -414,7 +403,7 @@ function resetToInitialState(ctx) {
ctx.deleteBuffer(tmp);

var numTextureUnits = ctx.getParameter(ctx.MAX_TEXTURE_IMAGE_UNITS);
for (var ii = 0; ii < numTextureUnits; ++ii) {
for (ii = 0; ii < numTextureUnits; ++ii) {
ctx.activeTexture(ctx.TEXTURE0 + ii);
ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, null);
ctx.bindTexture(ctx.TEXTURE_2D, null);
Expand Down Expand Up @@ -468,13 +457,11 @@ function resetToInitialState(ctx) {

function makeLostContextSimulatingCanvas(canvas) {
var unwrappedContext_;
var wrappedContext_;
var onLost_ = [];
var onRestored_ = [];
var wrappedContext_ = {};
var contextId_ = 1;
var contextLost_ = false;
var resourceId_ = 0;
var resourceDb_ = [];
var numCallsToLoseContext_ = 0;
var numCalls_ = 0;
Expand Down Expand Up @@ -522,7 +509,7 @@ function makeLostContextSimulatingCanvas(canvas) {

function wrapAddEventListener(canvas) {
var f = canvas.addEventListener;
canvas.addEventListener = function (type, listener, bubble) {
canvas.addEventListener = function (type, listener) {
switch (type) {
case "webglcontextlost":
addOnContextLostListener(listener);
Expand Down Expand Up @@ -600,27 +587,6 @@ function makeLostContextSimulatingCanvas(canvas) {
restoreTimeout_ = timeout;
};

function isWebGLObject(obj) {
//return false;
return (
obj instanceof WebGLBuffer ||
obj instanceof WebGLFramebuffer ||
obj instanceof WebGLProgram ||
obj instanceof WebGLRenderbuffer ||
obj instanceof WebGLShader ||
obj instanceof WebGLTexture
);
}

function checkResources(args) {
for (var ii = 0; ii < args.length; ++ii) {
var arg = args[ii];
if (isWebGLObject(arg)) {
return arg.__webglDebugContextLostId__ == contextId_;
}
}
return true;
}

function clearErrors() {
var k = Object.keys(glErrorShadow_);
Expand Down Expand Up @@ -705,7 +671,7 @@ function makeLostContextSimulatingCanvas(canvas) {
glErrorShadow_[err] = true;
}
}
for (var err in glErrorShadow_) {
for (err in glErrorShadow_) {
if (glErrorShadow_[err]) {
delete glErrorShadow_[err];
return err;
Expand Down Expand Up @@ -757,8 +723,8 @@ function makeLostContextSimulatingCanvas(canvas) {
"getUniformLocation",
"getVertexAttrib",
];
for (var ii = 0; ii < functionsThatShouldReturnNull.length; ++ii) {
var functionName = functionsThatShouldReturnNull[ii];
for (ii = 0; ii < functionsThatShouldReturnNull.length; ++ii) {
functionName = functionsThatShouldReturnNull[ii];
wrappedContext_[functionName] = (function (f) {
return function () {
loseContextIfTime();
Expand All @@ -779,8 +745,8 @@ function makeLostContextSimulatingCanvas(canvas) {
"isShader",
"isTexture",
];
for (var ii = 0; ii < isFunctions.length; ++ii) {
var functionName = isFunctions[ii];
for (ii = 0; ii < isFunctions.length; ++ii) {
functionName = isFunctions[ii];
wrappedContext_[functionName] = (function (f) {
return function () {
loseContextIfTime();
Expand Down
Loading

0 comments on commit c61e2ff

Please sign in to comment.