Page MenuHomePhabricator

Eslint issues with Echo patch in Gerrit
Closed, ResolvedPublic

Description

Started from scratch with my patch.

  1. Ran git clone ssh://ephemeralwaves@gerrit.wikimedia.org:29418/mediawiki/extensions/Echo.git
  2. Added smoke.js file and updated echo.page.js
  3. Ran npm test and it showed formatting errors
  4. Ran npx eslint --fix . which fixed the stated errors
  5. Pushed to Gerrit
  6. eslint in Gerrit/Jenkins fails.

Tried removing spaces to 'break' formatting and ran npm test, and it catches those formatting issues. Are the rules different on gerrit?

Also of note:
When I run eslint .
I get the following error:

Error: Cannot find module 'eslint-config-wikimedia/jquery'
Referenced from: /home/ephemeral/Programs/Echo/.eslintrc.json
at ModuleResolver.resolve (/usr/lib/node_modules/eslint/lib/util/module-resolver.js:72:19)
at resolve (/usr/lib/node_modules/eslint/lib/config/config-file.js:484:28)
at load (/usr/lib/node_modules/eslint/lib/config/config-file.js:556:26)
at configExtends.reduceRight (/usr/lib/node_modules/eslint/lib/config/config-file.js:430:36)
at Array.reduceRight (<anonymous>)
at applyExtends (/usr/lib/node_modules/eslint/lib/config/config-file.js:408:26)
at loadFromDisk (/usr/lib/node_modules/eslint/lib/config/config-file.js:528:22)
at Object.load (/usr/lib/node_modules/eslint/lib/config/config-file.js:564:20)
at Config.getLocalConfigHierarchy (/usr/lib/node_modules/eslint/lib/config.js:240:44)
at Config.getConfigHierarchy (/usr/lib/node_modules/eslint/lib/config.js:192:43)

Event Timeline

After the error get fixed via npx eslint --fix ., verify that locally the tests are working (npm install then npm test). Then make sure to add the modified files (git add), and update the commit locally (git commit --amend). Then push to gerrit (git push origin HEAD:refs/for/master).

In the job console https://integration.wikimedia.org/ci/job/mwgate-npm-node-6-docker/73371/console , one can see eslint complaints:

+ npm run-script test

> echo@0.0.1 test /src
> grunt test

Running "eslint:src" (eslint) task

/src/tests/selenium/pageobjects/echo.page.js
   8:1  error  Expected indentation of 1 tab but found 8 spaces    indent
   9:1  error  Expected indentation of 1 tab but found 8 spaces    indent
  10:1  error  Expected indentation of 1 tab but found 8 spaces    indent
  11:1  error  Expected indentation of 1 tab but found 8 spaces    indent
  12:1  error  Trailing spaces not allowed                         no-trailing-spaces
  13:1  error  Expected indentation of 1 tab but found 8 spaces    indent
  14:1  error  Expected indentation of 2 tabs but found 16 spaces  indent
  15:1  error  Expected indentation of 1 tab but found 8 spaces    indent

/src/tests/selenium/specs/smoke.js
   3:14   error  Unexpected newline between function name and paren         func-call-spacing
   3:22   error  There must be a space inside this paren                    space-in-parens
   3:31   error  There must be a space inside this paren                    space-in-parens
...

On https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Echo/+/486411/1/tests/selenium/specs/smoke.js Gerrit should highlight lines that end with white spaces. It also differentiates spaces and tabulations. The view correspond to errors reported by eslint.

Make sure to configure your editor appropriately ;) https://editorconfig.org/ is sometime very helpful (needs a plugin added to your editor and a config file at the root of the repository).
:)