|
| 1 | +## Overview |
| 2 | + |
| 3 | +Naming style checking supports checking based on basic nomenclature and regular expression checking: |
| 4 | +* snake-case |
| 5 | +* camel-case |
| 6 | +* pascal-case |
| 7 | +* upper-snake-case |
| 8 | +* pattern |
| 9 | + |
| 10 | +## configuration |
| 11 | + |
| 12 | +To enable naming style checking, you need to add configuration in settings: |
| 13 | +```json |
| 14 | +"emmylua.lint.nameStyle": true |
| 15 | +``` |
| 16 | + |
| 17 | +Add the configuration item `emmylua.name.config` in the setting of vscode, which can be filled in as follows: |
| 18 | +```json |
| 19 | + "emmylua.name.config": { |
| 20 | + "local_name_style": "snake_case" |
| 21 | + }, |
| 22 | +``` |
| 23 | +The configurable items are: |
| 24 | +* local_name_style |
| 25 | +* function_param_name_style |
| 26 | +* function_name_style |
| 27 | +* local_function_name_style |
| 28 | +* table_field_name_style |
| 29 | +* global_variable_name_style |
| 30 | +* module_name_style |
| 31 | +* require_module_name_style |
| 32 | +* class_name_style |
| 33 | + |
| 34 | +The format of each configurable item is the same, and the configurable value of each configurable item supports the following formats: |
| 35 | +* Single string Example: |
| 36 | +```json |
| 37 | +"local_name_style": "snake_case" |
| 38 | +``` |
| 39 | + |
| 40 | +Supported values for single string are: `snake_case`, `pascal_case`, `upper_snake_case`, `camel_case` |
| 41 | + |
| 42 | +* String array, for example: |
| 43 | +```json |
| 44 | +"local_name_style": [ |
| 45 | + "snake_case", |
| 46 | + "upper_snake_case" |
| 47 | +] |
| 48 | +``` |
| 49 | + |
| 50 | +* ignore list |
| 51 | + |
| 52 | +The general form of an ignore list is: |
| 53 | +```json |
| 54 | +"local_name_style": { |
| 55 | + "type": "ignore", |
| 56 | + "param": ["m", "M", "Do"] |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +* regular expression |
| 61 | + |
| 62 | +The regular syntax is javascript regular syntax. |
| 63 | +The general form of a regular expression is: |
| 64 | +```json |
| 65 | +"local_name_style": { |
| 66 | + "type" : "pattern", |
| 67 | + "param": "uuu*" |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +Regular expressions support capture groups and then match basic nomenclature: |
| 72 | +```json |
| 73 | +"local_name_style": { |
| 74 | + "type" : "pattern", |
| 75 | + "param": "m_(w+)", |
| 76 | + "$1": "camel_case" |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +Where `"$1": "camel_case"` means that the content of the first capture group needs to match the `camel_case` nomenclature |
| 81 | + |
| 82 | +* Supports mixed arrays of table structures and strings For example: |
| 83 | + |
| 84 | +```json |
| 85 | +"local_name_style": [ |
| 86 | + "snake_case", |
| 87 | + "pascal_case", |
| 88 | + "camel_case", |
| 89 | + { |
| 90 | + "type" : "pattern", |
| 91 | + "param": "m_(w+)", |
| 92 | + "$1": "camel_case" |
| 93 | + } |
| 94 | +] |
| 95 | +``` |
0 commit comments