-
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(permission-controller)!: Fix various lint rule violations (#…
…4521) ## Explanation Fixes various `@typescript-eslint` violations in the permission controller. Due to the prevalence of RPC method names as object literal keys in a couple of files, an `.eslintrc.js` has been added to the permission controller workspace to accommodate this exception to our naming convention. ## Changelog ### `@metamask/permission-controller` - **BREAKING**: Rename enum property names to match PascalCase instead of camelCase - The affected enums are: - `CaveatMutatorOperations` - `MethodNames`
- Loading branch information
Showing
12 changed files
with
269 additions
and
430 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
module.exports = { | ||
extends: ['../../.eslintrc.js'], | ||
|
||
overrides: [ | ||
{ | ||
files: [ | ||
'src/PermissionController.test.ts', | ||
'src/rpc-methods/revokePermissions.test.ts', | ||
], | ||
rules: { | ||
// This is taken directly from @metamask/eslint-config-typescript@12.1.0 | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
// We have to disable the default selector for our objectLiteralProperty | ||
// filter to work. | ||
// { | ||
// selector: 'default', | ||
// format: ['camelCase'], | ||
// leadingUnderscore: 'allow', | ||
// trailingUnderscore: 'forbid', | ||
// }, | ||
{ | ||
selector: 'enumMember', | ||
format: ['PascalCase'], | ||
}, | ||
{ | ||
selector: 'interface', | ||
format: ['PascalCase'], | ||
custom: { | ||
regex: '^I[A-Z]', | ||
match: false, | ||
}, | ||
}, | ||
{ | ||
selector: 'objectLiteralMethod', | ||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'], | ||
}, | ||
// This option is modified by the addition of a filter. | ||
{ | ||
selector: 'objectLiteralProperty', | ||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'], | ||
filter: { | ||
// Match RPC method names like foo_bar, foo_barBaz, etc., and metamask.io | ||
regex: '(^[a-z]+_[a-z]+[a-zA-Z0-9]*)|metamask\\.io$', | ||
match: false, | ||
}, | ||
}, | ||
{ | ||
selector: 'typeLike', | ||
format: ['PascalCase'], | ||
}, | ||
{ | ||
selector: 'typeParameter', | ||
format: ['PascalCase'], | ||
custom: { | ||
regex: '^.{3,}', | ||
match: true, | ||
}, | ||
}, | ||
{ | ||
selector: 'variable', | ||
format: ['camelCase', 'UPPER_CASE', 'PascalCase'], | ||
leadingUnderscore: 'allow', | ||
}, | ||
{ | ||
selector: 'parameter', | ||
format: ['camelCase', 'PascalCase'], | ||
leadingUnderscore: 'allow', | ||
}, | ||
{ | ||
selector: [ | ||
'classProperty', | ||
'objectLiteralProperty', | ||
'typeProperty', | ||
'classMethod', | ||
'objectLiteralMethod', | ||
'typeMethod', | ||
'accessor', | ||
'enumMember', | ||
], | ||
format: null, | ||
modifiers: ['requiresQuotes'], | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.