From f9092e0678a012fa5a87ea4c4b8bd2bcde97c57e Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 16 Oct 2024 17:21:41 -0400 Subject: [PATCH] Add eslint rules for consistent naming --- .eslintrc.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 1712568ac2..69cdcf0c60 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -273,6 +273,44 @@ module.exports = { __WEBPACK_SERVE__: 'readonly' }, rules: { + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'default', + format: [ 'camelCase', 'PascalCase' ], + leadingUnderscore: 'allow' + }, + { + selector: 'variable', + format: [ 'camelCase', 'PascalCase', 'UPPER_CASE' ], + leadingUnderscore: 'allowSingleOrDouble', + trailingUnderscore: 'allowSingleOrDouble' + }, + { + selector: 'typeLike', + format: [ 'PascalCase' ] + }, + { + selector: 'enumMember', + format: [ 'PascalCase', 'UPPER_CASE' ] + }, + { + selector: [ 'objectLiteralProperty', 'typeProperty' ], + format: [ 'camelCase', 'PascalCase' ], + leadingUnderscore: 'allowSingleOrDouble', + trailingUnderscore: 'allowSingleOrDouble' + }, + // Ignore numbers, locale strings (en-us), aria/data attributes, CSS selectors, + // and api_key parameter + { + selector: [ 'objectLiteralProperty', 'typeProperty' ], + format: null, + filter: { + regex: '[ &\\-]|^([0-9]+)$|^api_key$', + match: true + } + } + ], '@typescript-eslint/prefer-string-starts-ends-with': ['error'] } },