diff --git a/package.json b/package.json index 15d3983..58fdc93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-codex", - "version": "2.0.0", + "version": "2.0.1", "main": "index.js", "repository": "github:codex-team/eslint-config", "license": "MIT", diff --git a/src/configs/typescript.mjs b/src/configs/typescript.mjs index ec9d343..e51efe5 100644 --- a/src/configs/typescript.mjs +++ b/src/configs/typescript.mjs @@ -150,7 +150,30 @@ export default [ format: [ 'PascalCase', ], - }], + }, + /** + * Use camelCase for property names that dont satisfy regex + */ + { + selector: 'property', + format: ['camelCase'], + filter: { + regex: '^(?!(2xx|2[0-9][0-9]|application/json)$).*', + match: true, + }, + }, + /** + * Allows "2xx" (and similar) as a property name, used in the API response schema + */ + { + selector: 'property', + format: null, + filter: { + regex: '^(2xx|2[0-9][0-9]|application/json)$', + match: true, + }, + }, + ], 'no-shadow': 'off', '@typescript-eslint/no-shadow': 'error', '@typescript-eslint/consistent-type-imports': 'error', diff --git a/test/rules/typescript/naming-convention.ts b/test/rules/typescript/naming-convention.ts new file mode 100644 index 0000000..494069f --- /dev/null +++ b/test/rules/typescript/naming-convention.ts @@ -0,0 +1,6 @@ +const response = { + '2xx': 'value', + 205: 'value', + 305: 'value', + 'application/json': 'value', +};