Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Introduce eslint, and conform to its recommended rule set #197

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

anko
Copy link
Contributor

@anko anko commented Feb 1, 2021

We talked about maybe doing this in 2018, and for some reason I woke up today wanting to eslint something. 🤔 Maybe it's because I've been playing Factorio for 2 days straight.

So I fired it up with "eslint:recommended"-settings and beat the red text with hammers until I got tired. Here's the progress so far.

I've fixed stuff that looked obvious (unused variables, mixed tabbing, vars overriding each other, …) but left eslint erroring if I felt unsure. I mostly did only the minimum to resolve the eslint error, so for example while a full varconst/let replacement round would be a good idea, I've so far just been replacing them individually where they fix eslint errors.


Ones I'm unsure about that @sidorares should maybe check that they're no problem:

  • lib/unpackstream.js:323 → takes an unused stream argument, but the stream.write call is commented out; is that a bug, or a remnant from an old implementation?

  • lib/xcore.js:22stash isn't called anywhere, is it for debugging like hexy? Seems like a no-op?

  • lib/ext/render.js:34 → the num_* stuff is extracted but not used. Should they be in res?

  • lib/ext/render.js:99 → Unused function. For debugging?

  • lib/ext/render.js:435 → Unused variable glyphPaddedLength. Sounds meaningful but isn't used. Is it a logical error?

  • lib/ext/render.js:647 → Unused variable charFormat. Again sounds meaningful. Check logic.

  • lib/ext/render.js:650 → as just above ↑

  • lib/ext/apple-wm.js:186SetWindowMenu only contains dead code, so I commented it out. Probably in-progress and intentional?


Marked items either passed lint already, or I did a basic pass over them (adding notable issues to the above list for competent review):

  • examples/opengl/test1.js
  • examples/opengl/tp2.js
  • examples/opengl/glxgears.js
  • examples/opengl/triangle.js
  • examples/smoketest/listext.js
  • examples/smoketest/map_unmap.js
  • examples/smoketest/xcmisc.js
  • examples/smoketest/xeyes.js
  • examples/smoketest/keyboard/getkeyboardmapping.js
  • examples/smoketest/changeprop.js
  • examples/smoketest/trapezoids.js
  • examples/smoketest/query_ext.js
  • examples/smoketest/cleararea.js
  • examples/smoketest/polypoint.js
  • examples/smoketest/putimage1.js
  • examples/smoketest/testwnd.js
  • examples/smoketest/sstest.js
  • examples/smoketest/bmp.js
  • examples/smoketest/polytext8.js
  • examples/smoketest/applewm.js
  • examples/smoketest/copyarea.js
  • examples/smoketest/wndwrap.js
  • examples/smoketest/polyfillarc.js
  • examples/smoketest/putimage.js
  • examples/smoketest/warppointer.js
  • examples/smoketest/sendevent.js
  • examples/smoketest/query_pointer.js
  • examples/smoketest/compositetest.js
  • examples/smoketest/atoms.js
  • examples/smoketest/xtesttest.js
  • examples/smoketest/damagetest.js
  • examples/smoketest/fixestest.js
  • examples/smoketest/benchmarks/atom_benchmark_buffered.js
  • examples/smoketest/benchmarks/query_pointer_benchmark_sync.js
  • examples/smoketest/benchmarks/atom_benchmark_parallel.js
  • examples/smoketest/benchmarks/query_pointer_benchmark_parallel.js
  • examples/smoketest/shapetest.js
  • examples/smoketest/subwindows.js
  • examples/smoketest/polyfillrect.js
  • examples/smoketest/blur-convolution.js
  • examples/smoketest/shape-rectangles.js
  • examples/smoketest/randr.js
  • examples/smoketest/transpwindow.js
  • examples/smoketest/pixmap.js
  • examples/smoketest/listfonts.js
  • examples/smoketest/selections.js
  • examples/smoketest/querytree.js
  • examples/smoketest/listproperties.js
  • examples/smoketest/polyline.js
  • examples/vncviewer/d3des.js
  • examples/vncviewer/constants.js
  • examples/vncviewer/hexy.js
  • examples/vncviewer/rfbclient.js
  • examples/vncviewer/rfbserver.js
  • examples/vncviewer/unpackstream.js
  • examples/vncviewer/vncgui.js
  • examples/simple/hello.js
  • examples/simple/gcinvert.js
  • examples/simple/createwindow.js
  • examples/simple/render.js
  • examples/simple/xembed.js
  • examples/simple/embed.js
  • examples/simple/creategc.js
  • examples/simple/lsatoms.js
  • examples/simple/events.js
  • examples/simple/text/render-glyph.js
  • examples/simple/alloccolor.js
  • examples/simple/lsatomsp.js
  • examples/simple/getprop.js
  • examples/simple/resizewindow.js
  • examples/simple/gradients.js
  • examples/key-recognition.js
  • examples/screenshot.js
  • examples/xpm/test.js
  • examples/xpm/node-xpm.js
  • examples/png/test1.js
  • examples/png/node-png.js
  • examples/png/png-decoder.js
  • examples/png/test.js
  • examples/tetris.js
  • examples/kbdheatmap/kbdheatmap.js
  • examples/kbdheatmap/node-jpg.js
  • examples/windowmanager/wm.js
  • examples/paint.js
  • autogen/generate.js
  • autogen/makeindex.js
  • autogen/dependency_list.js
  • lib/corereqs.js
  • lib/ext/xc-misc.js
  • lib/ext/shape.js
  • lib/ext/glxconstants.js
  • lib/ext/glx.js
  • lib/ext/render.js
  • lib/ext/composite.js
  • lib/ext/fixes.js
  • lib/ext/dpms.js
  • lib/ext/big-requests.js
  • lib/ext/xtest.js
  • lib/ext/damage.js
  • lib/ext/glxrender.js
  • lib/ext/randr.js
  • lib/ext/screen-saver.js
  • lib/ext/apple-wm.js
  • lib/auth.js
  • lib/hexy.js
  • lib/unpackbuffer.js
  • lib/xerrors.js
  • lib/index.js
  • lib/xutil.js
  • lib/xserver.js
  • lib/keysyms.js
  • lib/stdatoms.js
  • lib/xcore.js
  • lib/unpackstream.js
  • lib/handshake.js
  • lib/eventmask.js
  • lib/gcfunction.js
  • test/configure-window.js
  • test/connect.js
  • test/cache-extensions.js
  • test/client-message.js
  • test/sequence-overflow.js
  • test/smoke-require-ext.js
  • test/dpms.js
  • test/core-properties.js
  • test/createGC.js
  • test/change-property.js
  • test/core-KillKlient.js
  • test/connection-utils.js
  • test/xtest.js
  • test/errors.js
  • test/core-ForceScreenSaver.js
  • test/allow-events.js
  • test/changeGC.js
  • test/randr.js
  • test/configure-request.js
  • test/core-CreateWindow.js
  • test/atoms-cache.js
  • test-runner.js

anko added 19 commits February 1, 2021 02:37
With the "recommended" eslint set
I ignored any weird or inconsistent indentation.  Just killing tabs.
Eslint flagged this unused variable.  Seems like a typo to me.
I'm guessing this was a typo, since the previous opcode in the file is
107 SetScreenSaver, and the wrong opcode for this was 108.
Lots of unused arguments are around, but I would feel bad deleting them
because they make the code easier to read.  So let's just prepend them
with an underscore to make it clear not using them was intentional.
 - Missing initialisers.
 - Switched `var` for `let` where they shadow another variable.
   (A full `var` → `const`/`let` pass would be good later.)
Just an unused variable.
- Deleted some Unused arguments.
- Fixed some redeclared variables, either by making them `let` or adding
  blocks to give variables their own scope.

I'm not sure why :323 is a bug or leftovers, so I left it erroring for
now.
Mostly a bunch of `let`s to avoid redefining stuff that's technically in
the same scope.

I don't know what the purpose of the `stash` function is, so I left it
alone.  It isn't called anywhere.  Is it for debugging like hexy?
unused require
- Unused require
- Underscore-prefixing unused arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant