Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isInEditor() support eslint invoked by VS Code git extension #589

Closed
3 tasks done
yunsii opened this issue Aug 21, 2024 · 3 comments
Closed
3 tasks done

isInEditor() support eslint invoked by VS Code git extension #589

yunsii opened this issue Aug 21, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@yunsii
Copy link
Contributor

yunsii commented Aug 21, 2024

Clear and concise description of the problem

If users commit code with IDE like below, the isInEditor() result is still true, so the related rules are still ignored.
image

Suggested solution

Support another env variable to make isInEditor() return false always? So git hooks can be run with the env variable to make eslint works as expected.

Alternative

No response

Additional context

No response

Validations

@yunsii yunsii added the enhancement New feature or request label Aug 21, 2024
@antfu
Copy link
Owner

antfu commented Aug 21, 2024

Yeah good points. Do you have any clue how?

@yunsii
Copy link
Contributor Author

yunsii commented Aug 21, 2024

Another solution with lint-staged I think is better:

  • package.json
{
  "lint-staged": {
    "*": "cross-env LINT_STAGED=true eslint --fix"
  }
}
  • new function isInLintStaged() to detect LINT_STAGED env variable

@Dimava
Copy link
Contributor

Dimava commented Aug 21, 2024

Yeah good points. Do you have any clue how?

I ran env > file.txt in git bas in vscode terminal, commited it, then added env > file.txt to .git/hooks/pre-commit, checked diff

diff --git a/file.txt b/file.txt
index 30aa3bfd..d9e2877d 100644
--- a/file.txt
+++ b/file.txt
@@ -1,89 +1,92 @@
+!D:=D:\repos\myrepo
-SHELL=/usr/bin/bash
-TERM_PROGRAM_VERSION=1.92.2
-MINGW_PREFIX=/mingw64
-PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
+GIT_CONFIG_PARAMETERS='user.useConfigOnly'='true'
-HOSTNAME=DESKTOP-R9AE28I
-ORIGINAL_TEMP=/tmp
-MINGW_CHOST=x86_64-w64-mingw32
+VSCODE_GIT_EDITOR_EXTRA_ARGS=
-MSYSTEM_CARCH=x86_64
+ELECTRON_RUN_AS_NODE=1
+VSCODE_GIT_EDITOR_MAIN=c:\Users\Dimava\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\git-editor-main.js
+VSCODE_GIT_EDITOR_NODE=C:\Users\Dimava\AppData\Local\Programs\Microsoft VS Code\Code.exe
+VSCODE_AMD_ENTRYPOINT=vs/workbench/api/node/extensionHostProcess
+GIT_INDEX_FILE=.git/index
-MANPATH=/mingw64/local/man:/mingw64/share/man:/usr/local/man:/usr/share/man:/usr/man:/share/man
+IMPORTX_LOADER=jiti-v1
+VSCODE_CODE_CACHE_PATH=C:\Users\Dimava\AppData\Roaming\Code\CachedData\fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
-MINGW_PACKAGE_PREFIX=mingw-w64-x86_64
+GIT_AUTHOR_DATE=@1724251319 +0300
-ORIGINAL_PATH=/mingw64/bin:/usr/bin:/c/Users/Dimava/bin:........
+GIT_EXEC_PATH=C:/Program Files/Git/mingw64/libexec/git-core
-SSH_ASKPASS=/mingw64/bin/git-askpass.exe
+SSH_ASKPASS=c:\Users\Dimava\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\ssh-askpass.sh
+VSCODE_IPC_HOOK=\\.\pipe\a9dba242-1.92.2-main-sock
+[email protected]
+GIT_PREFIX=
-INFOPATH=/mingw64/local/info:/mingw64/share/info:/usr/local/info:/usr/share/info:/usr/info:/share/info
-ACLOCAL_PATH=/mingw64/share/aclocal:/usr/share/aclocal
+GIT_PAGER=cat
+SSH_ASKPASS_REQUIRE=force
+VSCODE_GIT_COMMAND=-c
-MSYSTEM_CHOST=x86_64-w64-mingw32
-DISPLAY=needs-to-be-defined
-ORIGINAL_TMP=/tmp
+VSCODE_PID=26968
+GIT_EDITOR=:
+VSCODE_CWD=C:\Users\Dimava\AppData\Local\Programs\Microsoft VS Code
-EXEPATH=C:\Program Files\Git\bin
+VSCODE_CRASH_REPORTER_PROCESS_TYPE=extensionHost
-PS1=\[�]633;A�\]\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ \[�]633;B�\]
-PKG_CONFIG_SYSTEM_LIBRARY_PATH=/mingw64/lib
+LC_ALL=en_US.UTF-8
+GIT_AUTHOR_NAME=Dimava
-CONFIG_SITE=/etc/config.site
-PATH=/c/Users/Dimava/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Dimava/bin:..........
+PATH=/mingw64/libexec/git-core:/mingw64/bin:/usr/bin:/c/Users/Dimava/bin:.......
-MSYSTEM_PREFIX=/mingw64
+VSCODE_NLS_CONFIG={"userLocale":"en-us","osLocale":"en-us","resolvedLanguage":"en","defaultMessagesFile":"C:\\Users\\Dimava\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\nls.messages.json","locale":"en","availableLanguages":{}}
-PKG_CONFIG_SYSTEM_INCLUDE_PATH=/mingw64/include
-TERM_PROGRAM=vscode
+VSCODE_HANDLES_UNCAUGHT_ERRORS=true

VSCODE_GIT_COMMAND maybe? Or some of the GIT_XXX stuff

@antfu antfu closed this as completed in b60bfd3 Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants