-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperimental-naming-convention.js
More file actions
68 lines (67 loc) · 2 KB
/
experimental-naming-convention.js
File metadata and controls
68 lines (67 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { defineConfig } from 'eslint/config';
export default defineConfig({
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
// Enforce that interface names do not start with an 'I'
custom: {
match: false,
regex: '^I[A-Z]',
},
format: ['StrictPascalCase'],
leadingUnderscore: 'forbid',
selector: 'interface',
trailingUnderscore: 'forbid',
},
{
// Enforce that type alias names do not start with an 'T'
custom: {
match: false,
regex: '^T[A-Z]',
},
format: ['StrictPascalCase'],
leadingUnderscore: 'forbid',
selector: 'typeAlias',
trailingUnderscore: 'forbid',
},
{
// Enforce that all top-level variables are in UPPER_CASE
format: ['UPPER_CASE'],
leadingUnderscore: 'forbid',
modifiers: ['global'],
selector: 'variable',
trailingUnderscore: 'forbid',
types: ['boolean', 'number', 'string'],
},
{
// Enforce that all top-level array variables are in UPPER_CASE and are suffixed with a 'S' to indicate plural form
format: ['UPPER_CASE'],
leadingUnderscore: 'forbid',
modifiers: ['global'],
selector: 'variable',
suffix: ['S'],
trailingUnderscore: 'forbid',
types: ['array'],
},
{
// Enforce that array variables are suffixed with a 's' to indicate plural form
format: ['strictCamelCase'],
leadingUnderscore: 'forbid',
selector: 'variable',
suffix: ['s'],
trailingUnderscore: 'forbid',
types: ['array'],
},
{
// Enforce that boolean variables are prefixed with an allowed verb
format: ['StrictPascalCase'],
leadingUnderscore: 'forbid',
prefix: ['is', 'has', 'should', 'can'],
selector: 'variable',
trailingUnderscore: 'forbid',
types: ['boolean'],
},
],
},
});