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

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.shell=bash
shellcheck.disable=SC2034

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

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

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

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.disable=SC2034
shellcheck.sourcefile=/the/path/of/PKGBUILD.d.sh

PKGBUILD.d.sh:

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

@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.

This does not search .editorconfig’s in parental directories when root=false.

Also, this is not compliant with https://editorconfig.org/#file-location

EditorConfig files are read top to bottom and the most recent rules found take precedence.

$ cat > .editorconfig << 'EOF'
root = true

[*]
shellcheck.shell=sh

[foo]
shellcheck.shell=bash
EOF
$ echo 'pushd foo || exit' > foo
$ shellcheck foo

In foo line 1:
pushd foo || exit
^-------^ SC3044 (warning): In POSIX sh, 'pushd' is undefined.

For more information:
  https://www.shellcheck.net/wiki/SC3044 -- In POSIX sh, 'pushd' is undefined.

Copilot AI and others added 2 commits August 6, 2026 12:47
Fix EditorConfig section priority, glob depth matching, and root=true search stop

Co-authored-by: Freed-Wu <32936898+Freed-Wu@users.noreply.github.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 72371d8 to 3dcd562 Compare August 6, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for configuring Shellcheck via .editorconfig Request: Support PKGBUILD files

3 participants