-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from pbredenberg/PB/feat-snake-case-conventions
chore: add naming convention rules and test cases
- Loading branch information
Showing
4 changed files
with
134 additions
and
6 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,13 @@ | ||
'use strict'; | ||
|
||
class TestClass { | ||
constructor(age) { | ||
this.age = age; | ||
} | ||
|
||
getAge() { | ||
return this.age; | ||
} | ||
} | ||
|
||
module.exports = TestClass; |
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,56 @@ | ||
/** | ||
* Test class that adheres to our ESLint rules for TypeScript | ||
* @param test | ||
*/ | ||
export class TestClass { | ||
|
||
protected static _banana_sweetness: string; | ||
|
||
private static _apple_type: string; | ||
|
||
private readonly _appleColor: string; | ||
|
||
public constructor(appleColor: string, appleType: string, bananaSweetness: string) { | ||
this._appleColor = appleColor; | ||
TestClass._apple_type = appleType; | ||
TestClass._banana_sweetness = bananaSweetness; | ||
} | ||
|
||
public static get_apple_type(): string { | ||
return TestClass._apple_type; | ||
} | ||
|
||
public getOrange(): string { | ||
return this._headersContentTypeAsString(); | ||
} | ||
|
||
public getApple(): string { | ||
return TestClass.get_apple_type(); | ||
} | ||
|
||
protected _getBananaSweetness(): string { | ||
return TestClass._banana_sweetness; | ||
} | ||
|
||
protected get _getHeaders(): Record<string, unknown> { | ||
return { | ||
// This demonstrates how our rules allow for non-standard | ||
// object-literal property names, which are sometimes required | ||
// when working with 3rd party APIs that do not account for our | ||
// naming conventions. | ||
'Content-Type': 'application/json', | ||
'DC': 'test', | ||
TA: 'test', | ||
helloThere: 'test', | ||
HelloThere: 'test', | ||
MY_PROPERTY_NAME: 'test', | ||
'127.0.0.1': true, | ||
'aws:rep:deleting': true, | ||
'hello[a]': 'hello', | ||
}; | ||
} | ||
|
||
private _headersContentTypeAsString(): string { | ||
return `${this._getHeaders['Content-Type']}`; | ||
} | ||
} |
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,12 @@ | ||
const GLOBALLY_DEFINED = 'test'; | ||
|
||
/** | ||
* Test function that adheres to our ESLint rules for TypeScript | ||
* @param argument | ||
*/ | ||
export default function testFunction(argument: string): string { | ||
const locallyDefinedConst = 'test', | ||
returnValue = argument + locallyDefinedConst; | ||
|
||
return returnValue + GLOBALLY_DEFINED; | ||
} |