Skip to content

Commit

Permalink
feat(eslint-config): add naming convention rules
Browse files Browse the repository at this point in the history
BREAKING CHANGE: @typescript-eslint/typescript-eslint v3.0.0 introduces
a list of breaking changes. Existing code might violate the new or changed
rules. Manual fixes may be required.

See more details at:
https://github.com/typescript-eslint/typescript-eslint/releases/tag/v3.0.0
  • Loading branch information
raymondfeng committed May 28, 2020
1 parent 8179550 commit c8e2143
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions packages/eslint-config/eslintrc.js
Expand Up @@ -155,6 +155,106 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/return-await': 'error',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
camelcase: 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
},

{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
},

{
selector: 'variable',
format: null,
filter: {
regex: '^_$',
match: true,
},
},

// For mixin functions
{
selector: 'function',
format: ['PascalCase'],
filter: {
regex: 'Mixin$',
match: true,
},
},

{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},

// For members such as `Content-Type`
{
selector: 'memberLike',
format: null,
filter: {
// you can expand this regex as you find more cases that require
// quoting that you want to allow
regex: '[- ]',
match: true,
},
},

// For enum members
{
selector: 'enumMember',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},

// For properties
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},

{
selector: 'method',
format: ['camelCase'],
leadingUnderscore: 'allow',
},

// For static members
{
selector: 'memberLike',
modifiers: ['static'],
format: ['camelCase', 'UPPER_CASE'],
},

// For private members
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'allow',
},

// For protected members
{
selector: 'memberLike',
modifiers: ['protected'],
format: ['camelCase'],
leadingUnderscore: 'allow',
},

{
selector: 'typeLike',
format: ['PascalCase'],
},
],
},

overrides: [
Expand Down

0 comments on commit c8e2143

Please sign in to comment.