Closed rubens-lopes closed 2 years ago
Hi @rubens-lopes ! Thanks for reporting the issue.
Could you see if the issue still persists in version 1.0.15?
npm i eslint-plugin-diff@1.0.15
Hi @paleite, thank you for addressing this issue
now I'm getting a different error, not sure if is something that I'm not doing right
I'm running through powerShell script
$MAIN_FEATURE = $env:SYSTEM_PULLREQUEST_TARGETBRANCH.Replace('refs/heads/', '')
git -c http.extraheader="AUTHORIZATION: bearer $($env:System_AccessToken)" fetch origin $($MAIN_FEATURE)
$env:ESLINT_PLUGIN_DIFF_COMMIT="HEAD..origin/$($MAIN_FEATURE)"
pnpm ci:lint
log
2022-06-14T12:05:10.7338328Z ##[section]Starting: padroniza código com eslint
2022-06-14T12:05:10.7545598Z ==============================================================================
2022-06-14T12:05:10.7545904Z Task : PowerShell
2022-06-14T12:05:10.7546156Z Description : Run a PowerShell script on Linux, macOS, or Windows
2022-06-14T12:05:10.7546411Z Version : 2.200.0
2022-06-14T12:05:10.7546607Z Author : Microsoft Corporation
2022-06-14T12:05:10.7546914Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2022-06-14T12:05:10.7547295Z ==============================================================================
2022-06-14T12:05:14.1708061Z Generating script.
2022-06-14T12:05:14.2892291Z ========================== Starting Command Output ===========================
2022-06-14T12:05:14.3235575Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agent15\_work\_temp\e551ecaa-31ea-471c-9822-9715fcaa6ea3.ps1'"
2022-06-14T12:05:15.8271863Z From https://dev.azure.com/simp-cloud/UX/_git/UX.Web
2022-06-14T12:05:15.8272470Z * branch master -> FETCH_HEAD
2022-06-14T12:05:17.0818301Z
2022-06-14T12:05:17.0819126Z > company@1.0.0 ci:lint C:\agent15\_work\1\s\company
2022-06-14T12:05:17.0819538Z > eslint ./wwwroot/js/ --max-warnings 0
2022-06-14T12:05:17.0819717Z
2022-06-14T12:05:28.1588252Z usage: git diff [<options>] [<commit>] [--] [<path>...]
2022-06-14T12:05:28.1588778Z or: git diff [<options>] --cached [<commit>] [--] [<path>...]
2022-06-14T12:05:28.1589183Z or: git diff [<options>] <commit> [--merge-base] [<commit>...] <commit> [--] [<path>...]
2022-06-14T12:05:28.1589605Z or: git diff [<options>] <commit>...<commit>] [--] [<path>...]
2022-06-14T12:05:28.1589936Z or: git diff [<options>] <blob> <blob>]
2022-06-14T12:05:28.1590298Z or: git diff [<options>] --no-index [--] <path> <path>]
2022-06-14T12:05:28.1590464Z
2022-06-14T12:05:28.1590701Z common diff options:
2022-06-14T12:05:28.1591008Z -z output diff-raw with lines terminated with NUL.
2022-06-14T12:05:28.1591339Z -p output patch format.
2022-06-14T12:05:28.1591859Z -u synonym for -p.
2022-06-14T12:05:28.1592165Z --patch-with-raw
2022-06-14T12:05:28.1592463Z output both a patch and the diff-raw format.
2022-06-14T12:05:28.1592792Z --stat show diffstat instead of patch.
2022-06-14T12:05:28.1593144Z --numstat show numeric diffstat instead of patch.
2022-06-14T12:05:28.1593443Z --patch-with-stat
2022-06-14T12:05:28.1593744Z output a patch and prepend its diffstat.
2022-06-14T12:05:28.1594126Z --name-only show only names of changed files.
2022-06-14T12:05:28.1594493Z --name-status show names and status of changed files.
2022-06-14T12:05:28.1594866Z --full-index show full object name on index lines.
2022-06-14T12:05:28.1595269Z --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.
2022-06-14T12:05:28.1595622Z -R swap input file pairs.
2022-06-14T12:05:28.1595918Z -B detect complete rewrites.
2022-06-14T12:05:28.1596189Z -M detect renames.
2022-06-14T12:05:28.1596452Z -C detect copies.
2022-06-14T12:05:28.1596702Z --find-copies-harder
2022-06-14T12:05:28.1597029Z try unchanged files as candidate for copy detection.
2022-06-14T12:05:28.1597380Z -l<n> limit rename attempts up to <n> paths.
2022-06-14T12:05:28.1597727Z -O<file> reorder diffs according to the <file>.
2022-06-14T12:05:28.1598096Z -S<string> find filepair whose only one side contains the string.
2022-06-14T12:05:28.1598421Z --pickaxe-all
2022-06-14T12:05:28.1598719Z show all files diff when -S is used and hit is found.
2022-06-14T12:05:28.1599066Z -a --text treat all files as text.
2022-06-14T12:05:28.1599209Z
2022-06-14T12:05:28.1626997Z
2022-06-14T12:05:28.1628417Z Oops! Something went wrong! :(
2022-06-14T12:05:28.1628573Z
2022-06-14T12:05:28.1628778Z ESLint: 8.15.0
2022-06-14T12:05:28.1628902Z
2022-06-14T12:05:28.1629329Z Error: Command failed: git diff --diff-algorithm=histogram --diff-filter=ACM -M100% --name-only --relative --staged HEAD..origin/master
2022-06-14T12:05:28.1629851Z usage: git diff [<options>] [<commit>] [--] [<path>...]
2022-06-14T12:05:28.1630201Z or: git diff [<options>] --cached [<commit>] [--] [<path>...]
2022-06-14T12:05:28.1630611Z or: git diff [<options>] <commit> [--merge-base] [<commit>...] <commit> [--] [<path>...]
2022-06-14T12:05:28.1631012Z or: git diff [<options>] <commit>...<commit>] [--] [<path>...]
2022-06-14T12:05:28.1631848Z or: git diff [<options>] <blob> <blob>]
2022-06-14T12:05:28.1632184Z or: git diff [<options>] --no-index [--] <path> <path>]
2022-06-14T12:05:28.1632588Z
2022-06-14T12:05:28.1632844Z common diff options:
2022-06-14T12:05:28.1633152Z -z output diff-raw with lines terminated with NUL.
2022-06-14T12:05:28.1633492Z -p output patch format.
2022-06-14T12:05:28.1633752Z -u synonym for -p.
2022-06-14T12:05:28.1634010Z --patch-with-raw
2022-06-14T12:05:28.1634300Z output both a patch and the diff-raw format.
2022-06-14T12:05:28.1634640Z --stat show diffstat instead of patch.
2022-06-14T12:05:28.1634976Z --numstat show numeric diffstat instead of patch.
2022-06-14T12:05:28.1635285Z --patch-with-stat
2022-06-14T12:05:28.1635572Z output a patch and prepend its diffstat.
2022-06-14T12:05:28.1635916Z --name-only show only names of changed files.
2022-06-14T12:05:28.1636267Z --name-status show names and status of changed files.
2022-06-14T12:05:28.1636662Z --full-index show full object name on index lines.
2022-06-14T12:05:28.1637057Z --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.
2022-06-14T12:05:28.1637437Z -R swap input file pairs.
2022-06-14T12:05:28.1637721Z -B detect complete rewrites.
2022-06-14T12:05:28.1637993Z -M detect renames.
2022-06-14T12:05:28.1638277Z -C detect copies.
2022-06-14T12:05:28.1638528Z --find-copies-harder
2022-06-14T12:05:28.1638874Z try unchanged files as candidate for copy detection.
2022-06-14T12:05:28.1639221Z -l<n> limit rename attempts up to <n> paths.
2022-06-14T12:05:28.1639582Z -O<file> reorder diffs according to the <file>.
2022-06-14T12:05:28.1639950Z -S<string> find filepair whose only one side contains the string.
2022-06-14T12:05:28.1640290Z --pickaxe-all
2022-06-14T12:05:28.1640588Z show all files diff when -S is used and hit is found.
2022-06-14T12:05:28.1640947Z -a --text treat all files as text.
2022-06-14T12:05:28.1641093Z
2022-06-14T12:05:28.1641175Z
2022-06-14T12:05:28.1641511Z at checkExecSyncError (node:child_process:828:11)
2022-06-14T12:05:28.1641928Z at Object.execFileSync (node:child_process:863:15)
2022-06-14T12:05:28.1642631Z at getDiffFileList (C:\agent15\_work\1\s\company\node_modules\.pnpm\eslint-plugin-diff@1.0.15_eslint@8.15.0\node_modules\eslint-plugin-diff\dist\git.js:61:10)
2022-06-14T12:05:28.1643530Z at C:\agent15\_work\1\s\company\node_modules\.pnpm\eslint-plugin-diff@1.0.15_eslint@8.15.0\node_modules\eslint-plugin-diff\dist\processors.js:16:35
2022-06-14T12:05:28.1644411Z at Linter._verifyWithProcessor (C:\agent15\_work\1\s\company\node_modules\.pnpm\eslint@8.15.0\node_modules\eslint\lib\linter\linter.js:1793:30)
2022-06-14T12:05:28.1645244Z at Linter._verifyWithConfigArray (C:\agent15\_work\1\s\company\node_modules\.pnpm\eslint@8.15.0\node_modules\eslint\lib\linter\linter.js:1722:25)
2022-06-14T12:05:28.1646077Z at Linter.verify (C:\agent15\_work\1\s\company\node_modules\.pnpm\eslint@8.15.0\node_modules\eslint\lib\linter\linter.js:1471:65)
2022-06-14T12:05:28.1646893Z at Linter.verifyAndFix (C:\agent15\_work\1\s\company\node_modules\.pnpm\eslint@8.15.0\node_modules\eslint\lib\linter\linter.js:1953:29)
2022-06-14T12:05:28.1648097Z at verifyText (C:\agent15\_work\1\s\company\node_modules\.pnpm\eslint@8.15.0\node_modules\eslint\lib\cli-engine\cli-engine.js:245:48)
2022-06-14T12:05:28.2223673Z ELIFECYCLE Command failed with exit code 2.
2022-06-14T12:05:28.6461961Z ##[error]PowerShell exited with code '1'.
2022-06-14T12:05:28.6881526Z ##[section]Finishing: padroniza código com eslint
Hi again @rubens-lopes
I'm not sure how the syntax to set environment variables is supposed to look in Windows, but I noticed two dollar-signs here.
$env:ESLINT_PLUGIN_DIFF_COMMIT="HEAD..origin/$($MAIN_FEATURE)"
What do you get if you echo
the variable?
eslint-plugin-diff
will pick up on process.env.ESLINT_PLUGIN_DIFF_COMMIT
and in a Linux environment, your syntax should look like the following (note there's only one dollar-sign there).
export ESLINT_PLUGIN_DIFF_COMMIT="origin/$MAIN_FEATURE";
echo "$ESLINT_PLUGIN_DIFF_COMMIT"; # Should say for example `origin/main` or `origin/master`
I'm looking at this again, and reading it now, I noticed that it might be the git command itself that's failing.
The following line is of interest:
Command failed: git diff --diff-algorithm=histogram --diff-filter=ACM -M100% --name-only --relative --staged HEAD..origin/master
Could you try running git --version
and let me know what your output is? On my setup, I get the following:
git version 2.37.1
Our pipeline is saying 2.30.2.windows.1
I'm looking how to update it
Managed to update to git version 2.36.1.windows.1
but still getting a error on the diff command
ESLint: 8.19.0
Error: Command failed: git diff --diff-algorithm=histogram --diff-filter=ACM -M100% --name-only --relative --staged HEAD..origin/master
Found the issue.
Since we were not able to run it on the pipeline, we went for diff/staged
on the config file. Seems that it is not acceptable on the pipeline.
Moving back to diff/diff
worked. And the plugin linted only the changes lines.
Thank you!
Thanks for investigating, @rubens-lopes ! I'm really happy you found the issue. You're completely correct; "diff/diff" is the setting you want to use for a pipeline, because diff/staged is suited towards when you have many staged changes and unstaged changes in a project, but only want to lint what you've staged
When running eslint on Azure pipeline it's rise a error on a line that was not modified.
locally it's works fine
Pipeline![image](https://user-images.githubusercontent.com/68246549/149384618-1fd31217-20eb-4410-be8d-f67541f85485.png)
PR's![image](https://user-images.githubusercontent.com/68246549/149384773-40cec4ae-5245-4036-af39-d70caf2a145b.png)