Page MenuHomePhabricator

Fix eslint issues in the OCR tool
Closed, ResolvedPublic

Description

For better code quality and general familiarity, it would be good to add eslint checks to the OCR tool.

The basic eslint config is in place, but the following rule transgressions need to be fixed:

  • no-jquery/no-global-selector
  • no-unused-vars
  • no-new
  • semi-style
  • yml/no-empty-document
  • yml/no-empty-mapping-value

For microtask participants: Please select one of the above rules, remove it from .eslintrc.json, and fix the code so that npm run test passes.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

PR: https://github.com/wikimedia/wikimedia-ocr/pull/165

OCR prod is still on Debian bookworm and so has Node v18.20.4 and npm 9.2.0. It looks like eslint-plugin-jsdoc requires something newer:

Oops! Something went wrong! :(

ESLint: 8.57.1

wikimedia-ocr/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.cjs:768
        const lastLineBreakPos = text.slice(0, jsdocNode.range[0]).search(/\n[ \t]*$/v);
                                                                          ^

SyntaxError: Invalid regular expression flags
    at internalCompileFunction (node:internal/vm:76:18)
    at wrapSafe (node:internal/modules/cjs/loader:1283:20)
    at Module._compile (node:internal/modules/cjs/loader:1328:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (node_modules/eslint-plugin-jsdoc/dist/buildForbidRuleDefinition.cjs:7:44)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)

PR ready for review.

I'm not sure what people think of the wholesale switching to the new coding standard, it is rather a large change (that's mostly whitespace).

Samwilson renamed this task from Add eslint to OCR tool to Fix eslint issues in the OCR tool.Mar 31 2026, 2:21 AM
Samwilson updated the task description. (Show Details)
Samwilson added a subscriber: Soda.

Thanks for merging that @Soda!

I've added the remaining rules to the task description, so they can be handled in individual patches, and linked this task as a microtask for T415145: GSoC 2026: Bulk OCR Improvements.

This is done. Request to close as completed

Soda claimed this task.
Soda reassigned this task from Soda to Okerekechinweotito.