Skip to content

Support editorconfig - #3513

Open
Freed-Wu wants to merge 2 commits into
koalaman:masterfrom
Freed-Wu:copilot/support-editorconfig-another-one
Open

Support editorconfig#3513
Freed-Wu wants to merge 2 commits into
koalaman:masterfrom
Freed-Wu:copilot/support-editorconfig-another-one

Conversation

@Freed-Wu

@Freed-Wu Freed-Wu commented Aug 5, 2026

Copy link
Copy Markdown

Fix #1843, Fix #2128, Fix #2118

EditorConfig cores shall accept and report all syntactically valid key-value pairs, even if the key is not defined in this specification.
EditorConfig plugins shall ignore unrecognized keys and invalid/unsupported values.

So we can use .editorconfig or global ~/.config/editorconfig.ini :

[{build,*.subpackage}.sh]
shellcheck.disable=SC2034

[{*.ebuild,*.eclass,*.conf,color.map,.devscripts,*.mdd}]
shellcheck.shell=bash
shellcheck.disable=SC2034

[{PKGBUILD,*.install}]
shellcheck.shell=bash
shellcheck.disable=SC2034,SC2154

[APKBUILD]
shellcheck.shell=sh
shellcheck.disable=SC2034,SC2154

[*/bash-completion/completions/*]
shellcheck.shell=bash

Refer termux-language-server for filenames.

Add a command line option --file-name=FILE to specify the file name when input is read from stdin. This allows bash-language-server

shellcheck --file-name=PKGBUILD -

Final result:

Screenshot_20260805_211713

PS: If someone want to realize #1844 #356 , can extend the config:

[{PKGBUILD,*.install}]
shellcheck.shell=bash
shellcheck.sourcefile=/the/path/of/PKGBUILD.d.sh

PKGBUILD.d.sh:

# avoid SC2154
export pkgdir srcdir
# avoid SC2034
export pkgver # ...

haskell doesn't have library for editorconfig. and ini doesn't support disabling inline comment as editorconfig. So we have to create one.

e-kwsm

This comment was marked as resolved.

@Freed-Wu
Freed-Wu force-pushed the copilot/support-editorconfig-another-one branch from 72371d8 to 3dcd562 Compare August 6, 2026 04:52
Comment thread shellcheck.hs Outdated

@e-kwsm e-kwsm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without .editorconfig, shellcheck issues SC2148:

$ echo 'pushd foo || exit' > x
$ shellcheck x

In x line 1:
pushd foo || exit
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...

But when .editorconfig specifies a wrong shell, SC2148 is not issued

$ > .editorconfig cat << 'EOF'
root = true
[*]
shellcheck.shell = zsh
# XXX: zsh is not supported
EOF
$ shellcheck     x  # no warning
$ shellcheck - < x  # stdin, neither

@Freed-Wu
Freed-Wu force-pushed the copilot/support-editorconfig-another-one branch from 3dcd562 to 5da4a5f Compare August 7, 2026 11:49

@e-kwsm e-kwsm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root =

→ No warnings/errors are issued.

root = true
[*]
shellcheck.shell =

→ SC1134 is issued but the location is incorrect

$ shellcheck -s bash x

In x line 1:
pushd foo || exit
^-- SC1134 (error): Failed to process x, line 1:  Fix any mentioned problems and try again.

For more information:
  https://www.shellcheck.net/wiki/SC1134 -- Failed to process x, line 1:  Fix...
root = true
[*]
shellcheck.disable = abc

→ the same as above

Comment thread src/ShellCheck/EditorConfig.hs
e-kwsm

This comment was marked as resolved.

Comment thread src/ShellCheck/EditorConfig.hs Outdated
@Freed-Wu
Freed-Wu force-pushed the copilot/support-editorconfig-another-one branch from 5da4a5f to 6ea5a2a Compare August 9, 2026 09:39
Comment thread src/ShellCheck/EditorConfig.hs Outdated
@Freed-Wu
Freed-Wu force-pushed the copilot/support-editorconfig-another-one branch 2 times, most recently from bf0cbc7 to 40d670a Compare August 10, 2026 13:53
Comment thread src/ShellCheck/EditorConfig.hs Outdated
Comment thread src/ShellCheck/EditorConfig.hs
@Freed-Wu
Freed-Wu force-pushed the copilot/support-editorconfig-another-one branch from 678f155 to 2b16090 Compare August 11, 2026 06:50
e-kwsm

This comment was marked as resolved.

@e-kwsm

This comment was marked as resolved.

e-kwsm

This comment was marked as resolved.

@Freed-Wu

This comment was marked as resolved.

@Freed-Wu
Freed-Wu force-pushed the copilot/support-editorconfig-another-one branch 2 times, most recently from 3eea45e to e863124 Compare August 12, 2026 23:22
Copilot AI and others added 2 commits August 13, 2026 13:26
Fix EditorConfig section priority, glob depth matching, and root=true search stop

Co-authored-by: Eisuke Kawashima <e.kawaschima+github@gmail.com>
Co-authored-by: Freed-Wu <32936898+Freed-Wu@users.noreply.github.com>
@Freed-Wu
Freed-Wu force-pushed the copilot/support-editorconfig-another-one branch from e863124 to 51df507 Compare August 13, 2026 05:26
@Freed-Wu
Freed-Wu requested a review from e-kwsm August 20, 2026 21:16
e-kwsm

This comment was marked as duplicate.

Comment on lines +99 to +105
-- Only emit directives that the .shellcheckrc parser can handle.
-- Unknown shells (e.g. 'shellcheck.shell=zsh') would otherwise
-- silently suppress the SC2148 "unknown shell" warning, so they are
-- dropped here. Empty values are kept: the rc parser rejects them,
-- producing an SC1134 error at the right file and line.
isUsableDirective "shell" value = null value || isJust (shellForExecutable value)
isUsableDirective _ value = not (null value)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I prefer to emit Unknown shell: zsh and exit with four.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like

shellcheck.shell = zsh
^-- SC1071 (error): ShellCheck only supports sh/bash/dash/ksh/'busybox sh' scripts. Sorry!

@e-kwsm e-kwsm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root = true

[foo]
shellcheck.disable = #abc
#       ^~~ no error is issued (unexpected)

[bar]
shellcheck.disable = abc
#       ^-- SC1134 (error): Failed to process /tmp/.editorconfig, line 8:  Fix any mentioned problems and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants