Skip to content

Commit 0a6d6bb

Browse files
authored
ENG-1777 Enhance ESLint naming conventions in base config (#1060)
- Added new rules to allow leading underscores for various selectors. - Introduced flexibility for naming conventions in object properties, destructured variables, and class properties. - Allowed PascalCase for function declarations used as React components. - Updated existing rules to accommodate additional formats for constants and enum members.
1 parent 6a7bca8 commit 0a6d6bb

1 file changed

Lines changed: 71 additions & 2 deletions

File tree

packages/eslint-config/base.js

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,52 @@ export const config = [
2727
"@typescript-eslint/naming-convention": [
2828
"error",
2929
// Keep default
30-
{ selector: "default", format: ["camelCase"] },
30+
{
31+
selector: "default",
32+
format: ["camelCase"],
33+
leadingUnderscore: "allowSingleOrDouble",
34+
},
35+
// External APIs, generated database types, route maps, and host app
36+
// integration points often require exact property names.
37+
{
38+
selector: [
39+
"objectLiteralProperty",
40+
"objectLiteralMethod",
41+
"typeProperty",
42+
],
43+
format: null,
44+
},
45+
// Allow exact external field names when destructuring API/database data.
46+
{
47+
selector: "variable",
48+
modifiers: ["destructured"],
49+
format: null,
50+
},
51+
// Allow local names that intentionally mirror database identifiers.
52+
{
53+
selector: ["variable", "parameter"],
54+
filter: {
55+
regex:
56+
"^(?:[a-z][a-z0-9]*_)*(?:id|ids|uid|uids|t)$|^(?:last_modified|literal_content)$",
57+
match: true,
58+
},
59+
format: null,
60+
},
61+
// Allow compact geometry helper names used by tldraw relation logic.
62+
{
63+
selector: "variable",
64+
filter: {
65+
regex: "^(?:[A-Z]\\d+|handle_[A-Za-z0-9]+)$",
66+
match: true,
67+
},
68+
format: null,
69+
},
3170
// Keep default for const
3271
{
3372
selector: "variable",
3473
modifiers: ["const"],
35-
format: ["camelCase", "UPPER_CASE"],
74+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
75+
leadingUnderscore: "allowSingleOrDouble",
3676
},
3777
// Keep default for types
3878
{ selector: "typeLike", format: ["PascalCase"] },
@@ -41,6 +81,35 @@ export const config = [
4181
selector: "variable",
4282
types: ["function"],
4383
format: ["camelCase", "PascalCase"],
84+
leadingUnderscore: "allowSingleOrDouble",
85+
},
86+
// Allow PascalCase for function declarations used as React components
87+
// or tldraw SVG helper components.
88+
{
89+
selector: "function",
90+
format: ["camelCase", "PascalCase"],
91+
leadingUnderscore: "allowSingleOrDouble",
92+
},
93+
// Allow conventional ignored callback parameters.
94+
{
95+
selector: "parameter",
96+
modifiers: ["unused"],
97+
format: null,
98+
},
99+
// Allow constants and state names required by class-based libraries.
100+
{
101+
selector: "classProperty",
102+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
103+
leadingUnderscore: "allowSingleOrDouble",
104+
},
105+
// Support common enum member conventions.
106+
{
107+
selector: "enumMember",
108+
format: ["PascalCase", "UPPER_CASE"],
109+
},
110+
{
111+
selector: "enum",
112+
format: ["PascalCase", "UPPER_CASE"],
44113
},
45114
// Allow PascalCase for React imports
46115
{

0 commit comments

Comments
 (0)