소스 검색

Merge pull request #976 from gleb-urvanov/feature/naming-convention

Naming conventions altered for typescript code
Mokhtar Naamani 4 년 전
부모
커밋
832f039775
3개의 변경된 파일35개의 추가작업 그리고 4개의 파일을 삭제
  1. 3 3
      cli/src/base/ApiCommandBase.ts
  2. 30 0
      devops/eslint-config/index.js
  3. 2 1
      types/.eslintrc.js

+ 3 - 3
cli/src/base/ApiCommandBase.ts

@@ -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

+ 30 - 0
devops/eslint-config/index.js

@@ -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',

+ 2 - 1
types/.eslintrc.js

@@ -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'
   }
 }