Skip to content

Commit 8da6c45

Browse files
yangchtcodingjoe
andauthored
Add a length check of non-comment lines in C/C++ to the cookbook (#89)
Co-authored-by: Johannes Maron <[email protected]>
1 parent 4eef740 commit 8da6c45

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

COOKBOOK.md

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ A collection of recipes for reLint. Please feel free to contribute!
77
- [Python](#python)
88
- [Django](#django)
99
- [HTML](#html)
10+
- [C/C++](#cc)
1011

1112
# Python
1213

@@ -104,3 +105,14 @@ A collection of recipes for reLint. Please feel free to contribute!
104105
You may use a CSS class instead.
105106
filePattern: .*\.(html|vue|jsx|tsx)
106107
```
108+
109+
# C/C++
110+
111+
```yaml
112+
# This rule requires you to install the extra `regex` dependency.
113+
- name: no line longer than 120 characters in a line (excluding comments) # by @yangcht
114+
pattern: '(?<!^[ \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*//.*)(?<!/\*(?:(?!\*/)[\s\S\r])*?)\b(.{120,})\b'
115+
hint: |
116+
Please do not use more than 120 characters in codes except for comments.
117+
filePattern: .*\.(C|cc|cxx|cpp|c++|cppm)
118+
```

0 commit comments

Comments
 (0)