Skip to content

Commit

Permalink
chore: add formatting workflow and stylua.toml
Browse files Browse the repository at this point in the history
These should ensure consitent formatting in the future.

Feel free to modify the stylua.toml to your liking. I tried to keep it consistent with our current style (especially the tab-based indention)
  • Loading branch information
aarondill committed Nov 5, 2023
1 parent 1570b8a commit 9751d72
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/lua-format-check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check Lint With Stylua
on:
pull_request:
paths:
- "**.lua"
jobs:
format_code:
if: github.repository != github.event.pull_request.base.repo.full_name # if not a local branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .
21 changes: 21 additions & 0 deletions .github/workflows/lua-format-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint With Stylua
on:
push:
paths:
- "**.lua"
workflow_dispatch:
jobs:
format_code:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: .
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: linting with Stylua"
9 changes: 4 additions & 5 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.globals": [
"autocomplete"
]
}
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.globals": ["autocomplete"],
"unusedLocalExclude": ["_*"]
}
9 changes: 9 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
column_width = 120
line_endings = "Unix"
indent_type = "Tabs"
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "ConditionalOnly"

[sort_requires]
enabled = true

0 comments on commit 9751d72

Please sign in to comment.