Skip to content

Commit

Permalink
Merge pull request #976 from gleb-urvanov/feature/naming-convention
Browse files Browse the repository at this point in the history
Naming conventions altered for typescript code
  • Loading branch information
mnaamani authored Jul 22, 2020
2 parents 5a49611 + 82dff64 commit 832f039
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cli/src/base/ApiCommandBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,16 @@ export default abstract class ApiCommandBase extends StateAwareCommandBase {
}

async promptForJsonBytes(
JsonStruct: Constructor<Struct>,
jsonStruct: Constructor<Struct>,
argName?: string,
defaultValue?: Bytes,
schemaValidator?: ajv.ValidateFunction
) {
const rawType = new JsonStruct().toRawType()
const rawType = new jsonStruct().toRawType()
const typeDef = getTypeDef(rawType)

const defaultStruct =
defaultValue && new JsonStruct(JSON.parse(Buffer.from(defaultValue.toHex().replace('0x', ''), 'hex').toString()))
defaultValue && new jsonStruct(JSON.parse(Buffer.from(defaultValue.toHex().replace('0x', ''), 'hex').toString()))

if (argName) {
typeDef.name = argName
Expand Down
30 changes: 30 additions & 0 deletions devops/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,36 @@ module.exports = {
// should prefer using 'debug' package at least to allow control of
// output verbosity if logging to console.
'no-console': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/class-name-casing': 'off',
"@typescript-eslint/naming-convention": [
"error",
{
selector: 'default',
format: ['camelCase'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
},
{
selector: 'property',
format: [] // Don't force format of object properties, so they can be ie.: { "Some thing": 123 }, { some_thing: 123 } etc.
},
{
selector: 'accessor',
format: ['camelCase', 'snake_case']
},
{
selector: 'enumMember',
format: ['PascalCase']
},
{
selector: 'typeLike',
format: [],
custom: { regex: '^([A-Z][a-z0-9]*_?)+', match: true }, // combined PascalCase and snake_case to allow ie. OpeningType_Worker
}
],
},
plugins: [
'standard',
Expand Down
3 changes: 2 additions & 1 deletion types/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/class-name-casing': 'off',
'no-unused-vars': 'off', // Required by the typescript rule below
'@typescript-eslint/no-unused-vars': ['error']
'@typescript-eslint/no-unused-vars': ['error'],
"@typescript-eslint/naming-convention": 'off'
}
}

0 comments on commit 832f039

Please sign in to comment.