Skip to content

Commit

Permalink
Merge pull request #47 from codex-team/add-naming-convention
Browse files Browse the repository at this point in the history
chore[rules]: added filters for property selector of the naming-convention
  • Loading branch information
e11sy committed May 4, 2024
2 parents 2c1773e + ee1fdf7 commit 2516c22
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
25 changes: 24 additions & 1 deletion src/configs/typescript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions test/rules/typescript/naming-convention.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const response = {
'2xx': 'value',
205: 'value',
305: 'value',
'application/json': 'value',
};

0 comments on commit 2516c22

Please sign in to comment.