Skip to content

Commit 4379419

Browse files
Add diagnostic to enforce lowercase local element names (#2)
1 parent 429c48f commit 4379419

File tree

16 files changed

+197
-21
lines changed

16 files changed

+197
-21
lines changed

doc/en-us/config.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ Array<string>
329329
* ``"unused-label"``
330330
* ``"unused-local"``
331331
* ``"unused-vararg"``
332+
* ``"uppercase-local"``
332333

333334
## default
334335

@@ -470,6 +471,7 @@ object<string, string>
470471
"strict": "Fallback",
471472
/*
472473
* global-element
474+
* uppercase-local
473475
*/
474476
"strict-convention": "None",
475477
/*
@@ -593,6 +595,7 @@ object<string, string>
593595
"strict": "Fallback",
594596
/*
595597
* global-element
598+
* uppercase-local
596599
*/
597600
"strict-convention": "Fallback",
598601
/*
@@ -926,7 +929,11 @@ object<string, string>
926929
/*
927930
Enable unused vararg diagnostics.
928931
*/
929-
"unused-vararg": "Opened"
932+
"unused-vararg": "Opened",
933+
/*
934+
Enable diagnostics to warn about local element names starting with an uppercase letter.
935+
*/
936+
"uppercase-local": "None"
930937
}
931938
```
932939

@@ -1178,7 +1185,11 @@ object<string, string>
11781185
/*
11791186
Enable unused vararg diagnostics.
11801187
*/
1181-
"unused-vararg": "Hint"
1188+
"unused-vararg": "Hint",
1189+
/*
1190+
Enable diagnostics to warn about local element names starting with an uppercase letter.
1191+
*/
1192+
"uppercase-local": "Warning"
11821193
}
11831194
```
11841195

doc/pt-br/config.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ Array<string>
329329
* ``"unused-label"``
330330
* ``"unused-local"``
331331
* ``"unused-vararg"``
332+
* ``"uppercase-local"``
332333

333334
## default
334335

@@ -470,6 +471,7 @@ object<string, string>
470471
"strict": "Fallback",
471472
/*
472473
* global-element
474+
* uppercase-local
473475
*/
474476
"strict-convention": "None",
475477
/*
@@ -593,6 +595,7 @@ object<string, string>
593595
"strict": "Fallback",
594596
/*
595597
* global-element
598+
* uppercase-local
596599
*/
597600
"strict-convention": "Fallback",
598601
/*
@@ -926,7 +929,11 @@ object<string, string>
926929
/*
927930
未使用的不定参数
928931
*/
929-
"unused-vararg": "Opened"
932+
"unused-vararg": "Opened",
933+
/*
934+
Enable diagnostics to warn about local element names starting with an uppercase letter.
935+
*/
936+
"uppercase-local": "None"
930937
}
931938
```
932939

@@ -1178,7 +1185,11 @@ object<string, string>
11781185
/*
11791186
未使用的不定参数
11801187
*/
1181-
"unused-vararg": "Hint"
1188+
"unused-vararg": "Hint",
1189+
/*
1190+
Enable diagnostics to warn about local element names starting with an uppercase letter.
1191+
*/
1192+
"uppercase-local": "Warning"
11821193
}
11831194
```
11841195

doc/zh-cn/config.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ Array<string>
329329
* ``"unused-label"``
330330
* ``"unused-local"``
331331
* ``"unused-vararg"``
332+
* ``"uppercase-local"``
332333

333334
## default
334335

@@ -470,6 +471,7 @@ object<string, string>
470471
"strict": "Fallback",
471472
/*
472473
* global-element
474+
* uppercase-local
473475
*/
474476
"strict-convention": "None",
475477
/*
@@ -593,6 +595,7 @@ object<string, string>
593595
"strict": "Fallback",
594596
/*
595597
* global-element
598+
* uppercase-local
596599
*/
597600
"strict-convention": "Fallback",
598601
/*
@@ -926,7 +929,11 @@ object<string, string>
926929
/*
927930
未使用的不定参数
928931
*/
929-
"unused-vararg": "Opened"
932+
"unused-vararg": "Opened",
933+
/*
934+
Enable diagnostics to warn about local element names starting with an uppercase letter.
935+
*/
936+
"uppercase-local": "None"
930937
}
931938
```
932939

@@ -1177,7 +1184,11 @@ object<string, string>
11771184
/*
11781185
未使用的不定参数
11791186
*/
1180-
"unused-vararg": "Hint"
1187+
"unused-vararg": "Hint",
1188+
/*
1189+
Enable diagnostics to warn about local element names starting with an uppercase letter.
1190+
*/
1191+
"uppercase-local": "Warning"
11811192
}
11821193
```
11831194

doc/zh-tw/config.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ Array<string>
329329
* ``"unused-label"``
330330
* ``"unused-local"``
331331
* ``"unused-vararg"``
332+
* ``"uppercase-local"``
332333

333334
## default
334335

@@ -470,6 +471,7 @@ object<string, string>
470471
"strict": "Fallback",
471472
/*
472473
* global-element
474+
* uppercase-local
473475
*/
474476
"strict-convention": "None",
475477
/*
@@ -593,6 +595,7 @@ object<string, string>
593595
"strict": "Fallback",
594596
/*
595597
* global-element
598+
* uppercase-local
596599
*/
597600
"strict-convention": "Fallback",
598601
/*
@@ -926,7 +929,11 @@ object<string, string>
926929
/*
927930
未使用的不定引數
928931
*/
929-
"unused-vararg": "Opened"
932+
"unused-vararg": "Opened",
933+
/*
934+
Enable diagnostics to warn about local element names starting with an uppercase letter.
935+
*/
936+
"uppercase-local": "None"
930937
}
931938
```
932939

@@ -1177,7 +1184,11 @@ object<string, string>
11771184
/*
11781185
未使用的不定引數
11791186
*/
1180-
"unused-vararg": "Hint"
1187+
"unused-vararg": "Hint",
1188+
/*
1189+
Enable diagnostics to warn about local element names starting with an uppercase letter.
1190+
*/
1191+
"uppercase-local": "Warning"
11811192
}
11821193
```
11831194

locale/en-us/script.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ DIAG_INVISIBLE_PROTECTED =
150150
'Field `{field}` is protected, it can only be accessed in class `{class}` and its subclasses.'
151151
DIAG_INVISIBLE_PACKAGE =
152152
'Field `{field}` can only be accessed in same file `{uri}`.'
153-
DIAG_GLOBAL_ELEMENT =
153+
DIAG_GLOBAL_ELEMENT =
154154
'Element is global.'
155+
DIAG_UPPERCASE_LOCAL =
156+
'Local element `{}` must start with lowercase letter'
157+
155158

156159
MWS_NOT_SUPPORT =
157160
'{} does not support multi workspace for now, I may need to restart to support the new workspace ...'

locale/en-us/setting.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,10 @@ config.diagnostics['unknown-operator'] =
415415
'Enable diagnostics for unknown operators.'
416416
config.diagnostics['unreachable-code'] =
417417
'Enable diagnostics for unreachable code.'
418-
config.diagnostics['global-element'] =
419-
'Enable diagnostics to warn about global elements.'
418+
config.diagnostics['global-element'] =
419+
'Enable diagnostics to warn about global variables.'
420+
config.diagnostics['uppercase-local'] =
421+
'Enable diagnostics to warn about local element names starting with an uppercase letter.'
420422
config.typeFormat.config =
421423
'Configures the formatting behavior while typing Lua code.'
422424
config.typeFormat.config.auto_complete_end =

locale/pt-br/script.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ DIAG_INVISIBLE_PROTECTED = -- TODO: need translate!
150150
'Field `{field}` is protected, it can only be accessed in class `{class}` and its subclasses.'
151151
DIAG_INVISIBLE_PACKAGE = -- TODO: need translate!
152152
'Field `{field}` can only be accessed in same file `{uri}`.'
153-
DIAG_GLOBAL_ELEMENT = -- TODO: need translate!
153+
DIAG_GLOBAL_ELEMENT = -- TODO: need translate!
154154
'Element is global.'
155+
DIAG_UPPERCASE_LOCAL = -- TODO: need translate!
156+
'Local element `{}` must start with lowercase letter'
155157

156158
MWS_NOT_SUPPORT =
157159
'{} não é suportado múltiplos espaços de trabalho por enquanto, posso precisar reiniciar para estabelecer um novo espaço de trabalho ...'

locale/pt-br/setting.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,10 @@ config.diagnostics['unknown-operator'] = -- TODO: need translate!
415415
'Enable diagnostics for unknown operators.'
416416
config.diagnostics['unreachable-code'] = -- TODO: need translate!
417417
'Enable diagnostics for unreachable code.'
418-
config.diagnostics['global-element'] = -- TODO: need translate!
419-
'Enable diagnostics to warn about global elements.'
418+
config.diagnostics['global-element'] = -- TODO: need translate!
419+
'Enable diagnostics to warn about global variables.'
420+
config.diagnostics['uppercase-local'] = -- TODO: need translate!
421+
'Enable diagnostics to warn about local element names starting with an uppercase letter.'
420422
config.typeFormat.config = -- TODO: need translate!
421423
'Configures the formatting behavior while typing Lua code.'
422424
config.typeFormat.config.auto_complete_end = -- TODO: need translate!

locale/zh-cn/script.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ DIAG_INVISIBLE_PROTECTED =
150150
'字段 `{field}` 受到保护,只能在 `{class}` 类极其子类中才能访问。'
151151
DIAG_INVISIBLE_PACKAGE =
152152
'字段 `{field}` 只能在相同的文件 `{uri}` 中才能访问。'
153-
DIAG_GLOBAL_ELEMENT = -- TODO: need translate!
153+
DIAG_GLOBAL_ELEMENT = -- TODO: need translate!
154154
'Element is global.'
155+
DIAG_UPPERCASE_LOCAL = -- TODO: need translate!
156+
'Local element `{}` must start with lowercase letter'
155157

156158
MWS_NOT_SUPPORT =
157159
'{} 目前还不支持多工作目录,我可能需要重启才能支持新的工作目录...'

locale/zh-cn/setting.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,10 @@ config.diagnostics['unknown-operator'] = -- TODO: need translate!
414414
'Enable diagnostics for unknown operators.'
415415
config.diagnostics['unreachable-code'] = -- TODO: need translate!
416416
'Enable diagnostics for unreachable code.'
417-
config.diagnostics['global-element'] = -- TODO: need translate!
418-
'Enable diagnostics to warn about global elements.'
417+
config.diagnostics['global-element'] = -- TODO: need translate!
418+
'Enable diagnostics to warn about global variables.'
419+
config.diagnostics['uppercase-local'] = -- TODO: need translate!
420+
'Enable diagnostics to warn about local element names starting with an uppercase letter.'
419421
config.typeFormat.config = -- TODO: need translate!
420422
'Configures the formatting behavior while typing Lua code.'
421423
config.typeFormat.config.auto_complete_end = -- TODO: need translate!

0 commit comments

Comments
 (0)