eslint-plugin-diff icon indicating copy to clipboard operation
eslint-plugin-diff copied to clipboard

Gitlab Support

Open btd1337 opened this issue 1 year ago • 2 comments

Is it possible to add GitLab CI support?

btd1337 avatar Aug 07 '24 17:08 btd1337

I would also like to see this.

Using eslint 8 I have added plugin plugin:diff/ci to .eslintrc.js.

I have tried to add to my .gitlab-ci.yml file

variables:
    ESLINT_PLUGIN_DIFF_COMMIT: $CI_COMMIT_SHA

But the pipeline fails with the error

Error: Failed to load plugin 'diff' declared in '.eslintrc.js': Command failed: git diff --diff-algorithm=histogram --diff-filter=ACM --find-renames=100% --name-only --no-ext-diff --relative origin/4a7f61a60b7832978759985188381440647524b4 --
fatal: bad revision 'origin/4a7f61a60b7832978759985188381440647524b4'
Referenced from: /builds/project/.eslintrc.js
    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:891:11)
    at Object.execFileSync (node:child_process:927:15)
    at getDiffFileList (/builds/project/node_modules/eslint-plugin-diff/dist/git.js:63:10)
    at getProcessors (/builds/project/node_modules/eslint-plugin-diff/dist/processors.js:84:52)
    at Object.<anonymous> (/builds/project/node_modules/eslint-plugin-diff/dist/processors.js:91:43)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)

It would seem that if we can find the correct predefined variables and replace $CI_COMMIT_SHA with the correct variable it should work.

https://docs.gitlab.com/ee/ci/variables/predefined_variables.html

Also tried this variable but it did not work: CI_MERGE_REQUEST_DIFF_BASE_SHA - The base SHA of the merge request diff.

When I used $CI_COMMIT_SHORT_SHA I get the error:

Error: Failed to load plugin 'diff' declared in '.eslintrc.js': Command failed: git fetch --quiet origin a8efa4b3
fatal: couldn't find remote ref a8efa4b3

waynethompson avatar Dec 18 '24 11:12 waynethompson

I realise that it will be something like this in gitlab config.

variables:
    ESLINT_PLUGIN_DIFF_COMMIT: origin\\/$CI_COMMIT_REF_SLUG

but I can't get the forward slash to show.

waynethompson avatar Jan 07 '25 10:01 waynethompson