Goz3rr / vscode-glualint

glualint for vscode
https://marketplace.visualstudio.com/items?itemName=goz3rr.vscode-glualint
MIT License
7 stars 4 forks source link

Error when trying to format document #13

Closed Good1Cheese closed 1 year ago

Good1Cheese commented 1 year ago

When I open any GLua file and try to format it, vscode-glualint extension gives me error: Cannot read properties of undefined (reading 'document')

I have installed both glualint and vscode-glualint Also glualint folder is added to PATH

Goz3rr commented 1 year ago

I've published version 0.9.0 which should fix the cause of this warning, can you see if it works with that?

Good1Cheese commented 1 year ago

No, still not working. When I format any glua file, it still gives me: Failed to pretty print code, most likely due to syntax errors. In extension log there isn't any error.

If I use GLuaFixer via cmd, everything works fine.

Goz3rr commented 1 year ago

That means glualint either returned an error code or no output at all, which as the message suggests is usually the cause of syntax errors. Can you share the file you're trying to format? Does regular linting work (i.e. are you seeing warnings/errors from the linter if you intentionally add something bad)?

Can you also open a terminal inside vscode (ctrl+` or View -> Terminal) and run glualint --version from there, does that work and what does it print?

Good1Cheese commented 1 year ago

File to format - init.zip

glualint lint works and gives me a lot of warnings

warnings init.lua: [Warning] line 1, column 13 - line 1, column 29: Style: Please add a space after the parenthesis init.lua: [Warning] line 2, column 8 - line 2, column 24: Style: Please add a space after the parenthesis init.lua: [Warning] line 4, column 13 - line 4, column 27: Style: Please add a space after the parenthesis init.lua: [Warning] line 5, column 13 - line 5, column 26: Style: Please add a space after the parenthesis init.lua: [Warning] line 6, column 8 - line 6, column 21: Style: Please add a space after the parenthesis init.lua: [Warning] line 11, column 31 - line 11, column 38: Style: Please add a space after the parenthesis init.lua: [Warning] line 11, column 40 - line 11, column 46: Style: Please add a space before the parenthesis init.lua: [Warning] line 12, column 19 - line 12, column 26: Style: Please add a space after the parenthesis init.lua: [Warning] line 13, column 1 - line 13, column 4: Trailing whitespace init.lua: [Warning] line 15, column 26 - line 15, column 33: Style: Please add a space after the parenthesis init.lua: [Warning] line 15, column 46 - line 15, column 48: Style: Please add a space after the parenthesis init.lua: [Warning] line 15, column 53 - line 15, column 67: Style: Please add a space before the parenthesis init.lua: [Warning] line 19, column 11 - line 19, column 23: Inconsistent variable naming! There are variables that start with a lowercase letter, as well as ones that start with an uppercase letter. Please decide on one style. init.lua: [Warning] line 20, column 24 - line 20, column 37: Style: Please add a space after the parenthesis init.lua: [Warning] line 20, column 48 - line 20, column 50: Style: Please add a space before the parenthesis init.lua: [Warning] line 21, column 18 - line 21, column 31: Style: Please add a space after the parenthesis init.lua: [Warning] line 21, column 39 - line 21, column 41: Style: Please add a space before the parenthesis init.lua: [Warning] line 22, column 18 - line 22, column 31: Style: Please add a space after the parenthesis init.lua: [Warning] line 22, column 51 - line 22, column 57: Style: Please add a space after the parenthesis init.lua: [Warning] line 22, column 62 - line 22, column 65: Style: Please add a space before the parenthesis init.lua: [Warning] line 25, column 31 - line 25, column 38: Style: Please add a space after the parenthesis init.lua: [Warning] line 26, column 19 - line 26, column 26: Style: Please add a space after the parenthesis init.lua: [Warning] line 28, column 17 - line 28, column 19: Style: Please add a space after the parenthesis init.lua: [Warning] line 30, column 26 - line 30, column 32: Style: Please add a space after the parenthesis init.lua: [Warning] line 31, column 36 - line 31, column 43: Style: Please add a space after the parenthesis init.lua: [Warning] line 32, column 24 - line 32, column 31: Style: Please add a space after the parenthesis init.lua: [Warning] line 32, column 33 - line 32, column 53: Style: Please add a space before the parenthesis init.lua: [Warning] line 34, column 16 - line 34, column 21: Style: Please add a space after the parenthesis init.lua: [Warning] line 34, column 22 - line 34, column 36: Style: Please add a space before the parenthesis init.lua: [Warning] line 35, column 19 - line 35, column 27: Inconsistent variable naming! There are variables that start with a lowercase letter, as well as ones that start with an uppercase letter. Please decide on one style. init.lua: [Warning] line 36, column 25 - line 36, column 34: Style: Please add a space after the parenthesis init.lua: [Warning] line 38, column 33 - line 38, column 42: Style: Please add a space after the parenthesis init.lua: [Warning] line 42, column 40 - line 42, column 47: Style: Please add a space after the parenthesis init.lua: [Warning] line 42, column 60 - line 42, column 62: Style: Please add a space after the parenthesis init.lua: [Warning] line 42, column 67 - line 42, column 81: Style: Please add a space before the parenthesis init.lua: [Warning] line 43, column 13 - line 43, column 17: Style: Please add a space before the parenthesis init.lua: [Warning] line 45, column 5 - line 45, column 9: Style: Please add a space before the parenthesis init.lua: [Warning] line 50, column 23 - line 50, column 28: Style: Please add a space after the parenthesis init.lua: [Warning] line 50, column 42 - line 50, column 62: Style: Please add a space after the parenthesis init.lua: [Warning] line 50, column 62 - line 50, column 64: Style: Please add a space before the parenthesis init.lua: [Warning] line 55, column 29 - line 55, column 36: Style: Please add a space after the parenthesis init.lua: [Warning] line 59, column 29 - line 59, column 36: Style: Please add a space after the parenthesis init.lua: [Warning] line 59, column 38 - line 59, column 42: Style: Please add a space before the parenthesis init.lua: [Warning] line 61, column 20 - line 61, column 27: Style: Please add a space after the parenthesis init.lua: [Warning] line 61, column 76 - line 61, column 78: Style: Please add a space before the parenthesis init.lua: [Warning] line 65, column 20 - line 65, column 24: Style: Please add a space after the parenthesis init.lua: [Warning] line 65, column 71 - line 65, column 73: Inconsistent use of '&&' and 'and' init.lua: [Warning] line 65, column 241 - line 65, column 243: Style: Please add a space before the parenthesis init.lua: [Warning] line 69, column 11 - line 69, column 15: Inconsistent variable naming! There are variables that start with a lowercase letter, as well as ones that start with an uppercase letter. Please decide on one style. init.lua: [Warning] line 71, column 32 - line 71, column 35: Inconsistent use of 'and' and '&&' init.lua: [Warning] line 82, column 15 - line 82, column 23: Style: Please add a space after the parenthesis init.lua: [Warning] line 82, column 33 - line 82, column 40: Style: Please add a space after the parenthesis init.lua: [Warning] line 86, column 1 - line 86, column 5: Style: Please add a space before the parenthesis init.lua: [Warning] line 88, column 16 - line 88, column 35: Style: Please add a space after the parenthesis init.lua: [Warning] line 88, column 37 - line 88, column 46: Style: Please add a space before the parenthesis

glualint --version also works and prints 1.24.4

Goz3rr commented 1 year ago

This seems to be a problem with glualint 1.24.4 and up, I'll look into it but for now a workaround is to use version 1.24.3

Good1Cheese commented 1 year ago

Thanks for support! Actually works with 1.24.3 version.

FPtje commented 1 year ago

See https://github.com/FPtje/GLuaFixer/issues/154

Could you change the command to the following? That would use the newer CLI. Note that this newer interface is also already quite old.

const args = ['pretty-print', '--stdin', 'indentation', indentation];
Yogpod commented 1 year ago

const args = ['pretty-print', '--stdin', 'indentation', indentation];

const args = ['pretty-print', '--stdin', '--indentation', indentation]; works for me

Goz3rr commented 1 year ago

I realized the new interface existed when debugging this issue, but figured it was a new addition. At first I wanted to implement a version check and fall back to the older command if required, but if you say it's already quite old I'll just switch over completely and assume people keep their glualint up to date

Goz3rr commented 1 year ago

Switched to the newer CLI and fixed the issue with indendation, 0.10.0 should show up on the extension store soon

Good1Cheese commented 1 year ago

Everything works with version 1.24.5