Skip to content

Commit

Permalink
feat(eslint): Add naming convention for typeLike
Browse files Browse the repository at this point in the history
Update @typescript-eslint/naming-convention to use 'PascalCase'
for typeLike declarations -> (class, interface, typeAlias, enum, typeParameter)
  • Loading branch information
AbhiPrasad committed May 14, 2021
1 parent 60e1982 commit 6c5cd37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"fix": "lerna run --parallel fix",
"link:yarn": "lerna run --stream --concurrency 1 link:yarn",
"lint": "lerna run --parallel lint",
"lint:eslint": "lerna run --parallel lint:eslint",
"test": "lerna run --stream --concurrency 1 --sort test",
"codecov": "codecov",
"pack:changed": "lerna run pack --since",
Expand Down
8 changes: 7 additions & 1 deletion packages/eslint-config-sdk/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ module.exports = {
// in SDKs, we should make sure that we are correctly preserving class scope.
'@typescript-eslint/unbound-method': 'error',

// Private and protected members of a class should be prefixed with a leading underscore
// Private and protected members of a class should be prefixed with a leading underscore.
// typeLike declarations (class, interface, typeAlias, enum, typeParameter) should be
// PascalCase.
'@typescript-eslint/naming-convention': [
'error',
{
Expand All @@ -67,6 +69,10 @@ module.exports = {
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],

// Prefer for-of loop over for loop if index is only used to access array
Expand Down
8 changes: 4 additions & 4 deletions packages/node/src/integrations/onuncaughtexception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { logger } from '@sentry/utils';
import { NodeClient } from '../client';
import { logAndExitProcess } from './utils/errorhandling';

type OnFatalErrorHandler = (firstError: Error, secondError?: Error) => void;

/** Global Promise Rejection handler */
export class OnUncaughtException implements Integration {
/**
Expand Down Expand Up @@ -53,17 +55,15 @@ export class OnUncaughtException implements Integration {
let firstError: Error;

return (error: Error): void => {
type onFatalErrorHandlerType = (firstError: Error, secondError?: Error) => void;

let onFatalError: onFatalErrorHandlerType = logAndExitProcess;
let onFatalError: OnFatalErrorHandler = logAndExitProcess;
const client = getCurrentHub().getClient<NodeClient>();

if (this._options.onFatalError) {
// eslint-disable-next-line @typescript-eslint/unbound-method
onFatalError = this._options.onFatalError;
} else if (client && client.getOptions().onFatalError) {
// eslint-disable-next-line @typescript-eslint/unbound-method
onFatalError = client.getOptions().onFatalError as onFatalErrorHandlerType;
onFatalError = client.getOptions().onFatalError as OnFatalErrorHandler;
}

if (!caughtFirstError) {
Expand Down

0 comments on commit 6c5cd37

Please sign in to comment.