-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(naming-convention): adds a new shared configuration for enforcin…
…g naming conventions
- Loading branch information
Matthias Hecht
committed
Jan 17, 2025
1 parent
9f028ed
commit 8f2fdf2
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const tseslint = require('typescript-eslint'); | ||
|
||
module.exports = tseslint.config({ | ||
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'], | ||
}, | ||
], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters