There are 2 concepts in Lua for which I'd like to set a name style specifically:
Constants, constants_name_style
e.g. for local PI <const> = 3.14, I want to force UPPER_SNAKE_CASE, but don't want to allow it for all local variables (as I am now)
Module-local variables, module_local_name_style
e.g.
local _module1 = {};
local _variable = "module_local_variable"
-- more code
return _module1;
I want to force variables like `_variable` to be named with e.g. a leading underscore, but it is currently mixed into all local variable name styles as well. As these may collide with other namestyles, e.g. the constants above, the rule should be applied if it's not constant/module definition/module import already.
- Is it technically possible to add these options to the namestyle configurations?
- And is it something you would accept (/implement) in the formatter, or do you see any problems with it we should discuss?
Thank you!
we already have module_name_style, and the constant local t isn't too difficult, but the current parser and syntax tree aren't designed for code analysis, so it's still a bit of a pain in the ass to use, and I'll work on that when I get a chance. Maybe like this project https://github.com/CppCXY/EmmyLuaAnalyzer.
I'm currently working hard on this project, so I probably don't have a lot of energy to deal with this side of things.
There are 2 concepts in Lua for which I'd like to set a name style specifically:
Constants,
constants_name_style
e.g. forlocal PI <const> = 3.14
, I want to forceUPPER_SNAKE_CASE
, but don't want to allow it for all local variables (as I am now)Module-local variables,
module_local_name_style
e.g.local _variable = "module_local_variable"
-- more code
return _module1;