Initial commit
This commit is contained in:
commit
f5bf16be91
|
@ -0,0 +1,15 @@
|
||||||
|
# Godot 4+ specific ignores
|
||||||
|
.godot/
|
||||||
|
|
||||||
|
# Godot-specific ignores
|
||||||
|
.import/
|
||||||
|
export.cfg
|
||||||
|
export_presets.cfg
|
||||||
|
|
||||||
|
# Imported translations (automatically generated from CSV files)
|
||||||
|
*.translation
|
||||||
|
|
||||||
|
# Mono-specific ignores
|
||||||
|
.mono/
|
||||||
|
data_*/
|
||||||
|
mono_crash.*.json
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Rob Kelly <contact@robkel.ly>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,21 @@
|
||||||
|
# gdLint Plugin
|
||||||
|
|
||||||
|
A bare-bones plugin to run gdLint in Godot 4.x.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Install [gdscript-toolkit](https://github.com/Scony/godot-gdscript-toolkit).
|
||||||
|
|
||||||
|
If you install the toolkit in a venv, you may want to edit
|
||||||
|
`run_linter.gd` to set the path to the `gdlint` binary
|
||||||
|
(e.g. `venv/bin/gdlint`). That way, you won't have to run Godot
|
||||||
|
through a venv just to use `gdlint`.
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
This is an extremely simple implementation -- the plugin runs `gdlint`
|
||||||
|
on save, and raises any errors as warnings.
|
||||||
|
|
||||||
|
If you want more full-featured linter integration, check out
|
||||||
|
[el-falso/gdlinter](https://github.com/el-falso/gdlinter). When I
|
||||||
|
wrote this plugin, it wasn't being actively maintained.
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Rob Kelly <contact@robkel.ly>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,6 @@
|
||||||
|
[plugin]
|
||||||
|
name="gdLint Plugin"
|
||||||
|
description="Static code analysis with `gdlint`"
|
||||||
|
author="Rob Kelly"
|
||||||
|
version="1.0.0"
|
||||||
|
script="run_linter.gd"
|
|
@ -0,0 +1,33 @@
|
||||||
|
@tool
|
||||||
|
class_name GDLintPlugin extends EditorPlugin
|
||||||
|
|
||||||
|
# If you've installed gdlint in a venv, you may want to overwrite this
|
||||||
|
const GDLINT: String = "gdlint"
|
||||||
|
|
||||||
|
|
||||||
|
func _enter_tree() -> void:
|
||||||
|
assert(not OS.execute(GDLINT, ["-h"]), "Could not find gdLint binary at {0}".format([GDLINT]))
|
||||||
|
resource_saved.connect(on_save)
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
resource_saved.disconnect(on_save)
|
||||||
|
|
||||||
|
|
||||||
|
func on_save(resource: Resource) -> void:
|
||||||
|
# Run linting when a script resource is saved
|
||||||
|
if resource is Script:
|
||||||
|
var script: Script = resource
|
||||||
|
var filepath: String = ProjectSettings.globalize_path(resource.resource_path)
|
||||||
|
|
||||||
|
var script_editor = EditorInterface.get_script_editor()
|
||||||
|
var code_editor: CodeEdit = (
|
||||||
|
script_editor.get_current_editor().get_base_editor()
|
||||||
|
if script_editor.get_current_script() == script
|
||||||
|
else null
|
||||||
|
)
|
||||||
|
|
||||||
|
var gdlint_output: Array[String] = []
|
||||||
|
var error: int = OS.execute(GDLINT, [filepath], gdlint_output, true)
|
||||||
|
if error:
|
||||||
|
push_warning("gdLint:\n" + gdlint_output[0])
|
Loading…
Reference in New Issue