Skip to content

Commit 415c4c1

Browse files
0618Kamil Sobol
andauthored
remove static (#1040)
* remove static * add changeset * update API.md * refactor BackendIdentifierConversions and ParameterPathConversions * update API.md * revert remove static changes * add rule to remove static * modify the error messsage * add lint rules to ban static method with exception * fix lint for DeployedBackendClientFactory * update API.md * update changeset * fix eslintrc lint * Update .changeset/tidy-readers-prove.md Co-authored-by: Kamil Sobol <[email protected]> * use comment to disable static rule * ignore getInstance * Revert "ignore getInstance" This reverts commit bcd9036. --------- Co-authored-by: Kamil Sobol <[email protected]>
1 parent a3447c8 commit 415c4c1

File tree

6 files changed

+21
-2
lines changed

6 files changed

+21
-2
lines changed

.changeset/tidy-readers-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/deployed-backend-client': minor
3+
---
4+
5+
remove static method

.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ module.exports = {
141141
'MethodDefinition[kind!=/[constructor|get]/]',
142142
'FunctionDeclaration',
143143
'VariableDeclarator > FunctionExpression',
144+
{
145+
selector: 'MethodDefinition[static=true]',
146+
message: 'Static methods are not allowed in classes.',
147+
},
144148
],
145149
'jsdoc/require-description': 'error',
146150
'jsdoc/require-jsdoc': [

packages/deployed-backend-client/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export type DeployedBackendClient = {
133133

134134
// @public
135135
export class DeployedBackendClientFactory {
136-
static getInstance(options: DeployedBackendClientFactoryOptions): DeployedBackendClient;
136+
getInstance(options: DeployedBackendClientFactoryOptions): DeployedBackendClient;
137137
}
138138

139139
// @public (undocumented)

packages/deployed-backend-client/src/deployed_backend_client_factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class DeployedBackendClientFactory {
128128
/**
129129
* Returns a single instance of DeploymentClient
130130
*/
131-
static getInstance(
131+
getInstance(
132132
options: DeployedBackendClientFactoryOptions
133133
): DeployedBackendClient {
134134
const stackStatusMapper = new StackStatusMapper();

packages/platform-core/src/backend_identifier_conversions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export class BackendIdentifierConversions {
1515
*
1616
* If the stack name is ambiguous, undefined is returned
1717
*/
18+
// It's fine to ignore the rule here because the anti-static rule is to ban the static function which should use constructor
19+
// eslint-disable-next-line no-restricted-syntax
1820
static fromStackName(stackName?: string): BackendIdentifier | undefined {
1921
if (!stackName) {
2022
return;
@@ -47,6 +49,8 @@ export class BackendIdentifierConversions {
4749
*
4850
* Changing this method will change how stack names are generated which could be a massive breaking change for existing Amplify stacks.
4951
*/
52+
// It's fine to ignore the rule here because the anti-static rule is to ban the static function which should use constructor
53+
// eslint-disable-next-line no-restricted-syntax
5054
static toStackName(backendId: BackendIdentifier): string {
5155
const hash = getHash(backendId);
5256

packages/platform-core/src/parameter_path_conversions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export class ParameterPathConversions {
1111
/**
1212
* Convert a BackendIdentifier to a parameter prefix.
1313
*/
14+
// It's fine to ignore the rule here because the anti-static rule is to ban the static function which should use constructor
15+
// eslint-disable-next-line no-restricted-syntax
1416
static toParameterPrefix(backendId: BackendIdentifier | AppId): string {
1517
if (typeof backendId === 'object') {
1618
return getBackendParameterPrefix(backendId);
@@ -21,6 +23,8 @@ export class ParameterPathConversions {
2123
/**
2224
* Convert a BackendIdentifier to a parameter full path.
2325
*/
26+
// It's fine to ignore the rule here because the anti-static rule is to ban the static function which should use constructor
27+
// eslint-disable-next-line no-restricted-syntax
2428
static toParameterFullPath(
2529
backendId: BackendIdentifier | AppId,
2630
parameterName: string
@@ -34,6 +38,8 @@ export class ParameterPathConversions {
3438
/**
3539
* Generate an SSM path for references to other backend resources
3640
*/
41+
// It's fine to ignore the rule here because the anti-static rule is to ban the static function which should use constructor
42+
// eslint-disable-next-line no-restricted-syntax
3743
static toResourceReferenceFullPath(
3844
backendId: BackendIdentifier,
3945
referenceName: string

0 commit comments

Comments
 (0)