Skip to content

Lightly applies ESLint to OZTreeModule and removes demonstrably unused imports and straightforward unused variables - #1017

Open
ScaleNature wants to merge 17 commits into
OneZoom:mainfrom
ScaleNature:dev/remove-unused-OZTreeModule-imports
Open

Lightly applies ESLint to OZTreeModule and removes demonstrably unused imports and straightforward unused variables#1017
ScaleNature wants to merge 17 commits into
OneZoom:mainfrom
ScaleNature:dev/remove-unused-OZTreeModule-imports

Conversation

@ScaleNature

@ScaleNature ScaleNature commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Lightly applies ESLint to OZTreeModule and removes demonstrably unused imports and straightforward unused variables
The changes are intentionally conservative:

  • removes demonstrably unused imports
  • removes unused variables where the changes are mechanical and behavior-preserving
  • slightly expands a small number of tests where previously unused variables became meaningful test assertions
  • makes no intentional behavioral changes
  • performs no refactoring beyond what is required for the cleanup

Some remaining no-unused-vars findings were intentionally left unchanged because they require project-level judgment (for example, complete theme palettes or interface methods) rather than mechanical cleanup. Whether those should be removed, suppressed, or retained is outside the scope of this PR.

Removing stale imports and straightforward unused variables makes module dependency declarations more accurately reflect the code they use and reduces maintenance noise.

ESLint is not part of build, test, or CI processes.
To run: npx eslint OZprivate/rawJS/OZTreeModule

The full test suite passes after these changes.

@lentinj

lentinj commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

This is a very worthwhile cleanup, but I'd rather that the unused imports were found by a linting tool, eslint / xo or similar. As well as having a bit more confidence in their work, it'd be something we can plug into the CI pipeline to stop unused imports cropping up in future.

OneZoom's code style is somewhat free range, so we'd have to have a very minimal set of rules at least to start with.

Copilot AI and others added 3 commits August 1, 2026 13:13
…d-imports

Merge lint configuration into unused import removal branch
Planning to clean up code next for a clean lint analysis of this module.
Removed import flagged by eslint.
@ScaleNature
ScaleNature marked this pull request as draft August 2, 2026 19:54
Removed import flagged by eslint.
Added import for capitalizeFirstLetter utility function.
 import {capitalizeFirstLetter, max} from '../util/index';
Removed import flagged by eslint as unused.
Removed import flagged by eslint as unused.
Removed import flagged by eslint as unused.
Removed import flagged by eslint as unused.
…r-preserving.

Some previously unused variables were retained because they improved the clarity of test setup or context. In those cases, the tests were expanded slightly to verify the associated state, making those variables part of the test assertions.

The remaining no-unused-vars findings were intentionally left unchanged because they appear to represent design decisions (for example, complete theme palettes or interface methods) rather than accidental dead code. Whether to remove, suppress, or retain those findings is a project policy decision rather than a mechanical cleanup and is outside the scope of this task.

The remaining no-unused-vars findings are not enforced by the existing development workflow. ESLint is not part of the build, test, or CI processes.
@ScaleNature ScaleNature changed the title Remove unused oz tree module imports Lightly applies ESLint to OZTreeModule and removes demonstrably unused imports and straightforward unused variables Aug 3, 2026
ESLint, removed unused variables, removed unused imports.
@ScaleNature
ScaleNature marked this pull request as ready for review August 3, 2026 01:47
@ScaleNature

Copy link
Copy Markdown
Contributor Author

Remaining unused variables found in OZTreeModule: npx eslint OZprivate/rawJS/OZTreeModule

src/factory/garbage_collection.js
74:10 error 'calc_real_richness' is defined but never used no-unused-vars

src/factory/polytomy_midnode.js
48:10 error 'display_cut_substr' is defined but never used no-unused-vars

src/themes/IUCN_explicit_colour_blind_friendly.js
4:5 error 'very_dark_grey' is assigned a value but never used no-unused-vars

src/themes/IUCN_explicit_theme.js
4:5 error 'very_dark_grey' is assigned a value but never used no-unused-vars

src/themes/genetic_conservation_theme.js
4:5 error 'very_dark_grey' is assigned a value but never used no-unused-vars
7:5 error 'mid_grey' is assigned a value but never used no-unused-vars
9:5 error 'very_light_grey' is assigned a value but never used no-unused-vars
17:5 error 'very_transparent_white' is assigned a value but never used no-unused-vars
23:5 error 'dark_blue' is assigned a value but never used no-unused-vars
28:5 error 'dark_orange' is assigned a value but never used no-unused-vars
29:5 error 'orange' is assigned a value but never used no-unused-vars
30:5 error 'light_orange' is assigned a value but never used no-unused-vars
48:10 error 'outline_highlight' is defined but never used no-unused-vars
88:10 error 'sponsor_color' is defined but never used no-unused-vars
96:10 error 'copyright_highlight_fill' is defined but never used no-unused-vars
104:10 error 'copyright_highlight_stroke' is defined but never used no-unused-vars
136:10 error 'copyright_text_highlight_fill' is defined but never used no-unused-vars

src/themes/natural_theme.js
4:5 error 'very_dark_grey' is assigned a value but never used no-unused-vars
6:5 error 'grey' is assigned a value but never used no-unused-vars
7:5 error 'mid_grey' is assigned a value but never used no-unused-vars
9:5 error 'very_light_grey' is assigned a value but never used no-unused-vars
17:5 error 'very_transparent_white' is assigned a value but never used no-unused-vars
74:10 error 'copyright_highlight_fill' is defined but never used no-unused-vars
82:10 error 'copyright_highlight_stroke' is defined but never used no-unused-vars
114:10 error 'copyright_text_highlight_fill' is defined but never used no-unused-vars

src/themes/popularity_colour_blind_friendly.js
4:5 error 'very_dark_grey' is assigned a value but never used no-unused-vars
16:5 error 'very_transparent_white' is assigned a value but never used no-unused-vars
18:5 error 'dark_blue' is assigned a value but never used no-unused-vars
19:5 error 'blue' is assigned a value but never used no-unused-vars
20:5 error 'light_blue' is assigned a value but never used no-unused-vars
22:5 error 'dark_red' is assigned a value but never used no-unused-vars
23:5 error 'red' is assigned a value but never used no-unused-vars
24:5 error 'light_red' is assigned a value but never used no-unused-vars
27:5 error 'pastel_green' is assigned a value but never used no-unused-vars
29:5 error 'pastel_cyan' is assigned a value but never used no-unused-vars
30:5 error 'pastel_magenta' is assigned a value but never used no-unused-vars
31:5 error 'pastel_yellow' is assigned a value but never used no-unused-vars

src/themes/popularity_theme.js
4:5 error 'very_dark_grey' is assigned a value but never used no-unused-vars
16:5 error 'very_transparent_white' is assigned a value but never used no-unused-vars
18:5 error 'dark_blue' is assigned a value but never used no-unused-vars
19:5 error 'blue' is assigned a value but never used no-unused-vars
20:5 error 'light_blue' is assigned a value but never used no-unused-vars
22:5 error 'dark_red' is assigned a value but never used no-unused-vars
23:5 error 'red' is assigned a value but never used no-unused-vars
24:5 error 'light_red' is assigned a value but never used no-unused-vars

@lentinj

lentinj commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks! After a quick look through I can't remember any gotchas about the lines in question, I think it's all just excessive copy-paste. Is there a reason you left the final unused variables, or just run out of time?

I'll have a bit more of a test then merge later in the week. Will have a look the final cases too in your comment.

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.

3 participants