Skip to content

Commit

Permalink
feat: fine tune naming conventions (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbredenberg committed Jul 27, 2023
1 parent 9fd9ad7 commit ae13be5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
21 changes: 19 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,23 @@ module.exports = {
format: [ 'snake_case' ],
leadingUnderscore: 'require',
},
{
selector: 'classProperty',
modifiers: [ 'private', 'readonly', 'static' ],
format: [ 'UPPER_CASE' ],
leadingUnderscore: 'require',
},
{
selector: 'classProperty',
modifiers: [ 'protected', 'readonly', 'static' ],
format: [ 'UPPER_CASE' ],
leadingUnderscore: 'require',
},
{
selector: 'classProperty',
modifiers: [ 'public', 'readonly', 'static' ],
format: [ 'UPPER_CASE' ],
},
{
selector: 'classProperty',
modifiers: [ 'protected', 'static' ],
Expand All @@ -344,11 +361,11 @@ module.exports = {
},
{
selector: 'variable',
format: [ 'camelCase' ],
format: [ 'camelCase', 'PascalCase' ],
},
{
selector: 'parameter',
format: [ 'camelCase' ],
format: [ 'camelCase', 'PascalCase' ],
leadingUnderscore: 'allow',
},
{
Expand Down
11 changes: 11 additions & 0 deletions test-cases/typescript/SmallClass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class SmallClass {
private readonly _helloThere: string;

public constructor(hello: string) {
this._helloThere = hello;
}

public sayHello(): string {
return this._helloThere;
}
}
14 changes: 14 additions & 0 deletions test-cases/typescript/TestClass.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { SmallClass } from './SmallClass';

/**
* Test class that adheres to our ESLint rules for TypeScript
* @param test
*/
export class TestClass {

public static readonly BANANA_SWEETNESS: string;

protected static readonly _BANANA_RIPENESS: string;

protected static _banana_sweetness: string;

private static _apple_type: string;

private static readonly _APPLE_COLOR: string;

private readonly _appleColor: string;

public constructor(appleColor: string, appleType: string, bananaSweetness: string) {
Expand All @@ -28,6 +36,12 @@ export class TestClass {
return TestClass.get_apple_type();
}

public provideSmallClass(Small: new (...args) => SmallClass): string {
const MySmallClass = new Small('Hello there!');

return MySmallClass.sayHello();
}

protected _getBananaSweetness(): string {
return TestClass._banana_sweetness;
}
Expand Down

0 comments on commit ae13be5

Please sign in to comment.