Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/no-extra-parens": "off"
}
"@typescript-eslint/no-extra-parens": "off",

"no-shadow": "off"
},
"overrides": [
{
"files": ["**/*.ts"],
"rules": {
"no-undef": "off"
}
}
]
}
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"clear": "rimraf dist/*",
"build": "yarn clear && tsc",
"watch": "yarn clear && tsc --watch",
"test": "tsc --noEmit && eslint src --ext .ts"
"test": "jest && tsc --noEmit && eslint src --ext .ts"
},
"pre-commit": [
"test"
Expand All @@ -43,15 +43,18 @@
"chalk": "4.1.0"
},
"devDependencies": {
"@types/jest": "^28.1.5",
"@types/node": "^14.0.13",
"@typescript-eslint/eslint-plugin": "2.34.0",
"@typescript-eslint/parser": "2.0.0",
"@vkontakte/eslint-config": "2.5.0",
"eslint": "6.8.0",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "3.0.0",
"@typescript-eslint/eslint-plugin": "5.30.6",
"@typescript-eslint/parser": "5.30.6",
"@vkontakte/eslint-config": "3.1.0",
"eslint": "8.19.0",
"eslint-plugin-react": "7.30.1",
"eslint-plugin-react-hooks": "4.6.0",
"jest": "28.1.3",
"pre-commit": "1.2.2",
"rimraf": "^3.0.2",
"typescript": "3.9.5"
"ts-jest": "^28.0.6",
"typescript": "4.3.5"
}
}
1 change: 1 addition & 0 deletions src/generators/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function normalizeMethodInfo(method: Schema.Method): NormalizeMethodInfoR
// For method params "boolean" type means 1 or 0
// Real "false" boolean value will be detected by API as true
if (parameter.type === 'boolean') {
// @ts-expect-error
delete parameter.type;
parameter.$ref = baseBoolIntRef;
}
Expand Down
12 changes: 12 additions & 0 deletions src/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { areQuotesNeededForProperty } from './helpers';

test('areQuotesNeededForProperty', () => {
expect(areQuotesNeededForProperty('user_id')).toBe(false);
expect(areQuotesNeededForProperty('uuid4')).toBe(false);
expect(areQuotesNeededForProperty('_foo')).toBe(false);

expect(areQuotesNeededForProperty('4uuid')).toBe(true);
expect(areQuotesNeededForProperty('user-id')).toBe(true);
expect(areQuotesNeededForProperty('user&id')).toBe(true);
expect(areQuotesNeededForProperty('идентификатор')).toBe(true);
});
3 changes: 2 additions & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ export function areQuotesNeededForProperty(name: string | number): boolean {
return false;
}

if (/[&]/.test(name)) {
if (/[&-]/.test(name)) {
return true;
}

return !(/^[a-z_]([a-z0-9_])+$/i.test(name) || /^[a-z_]/i.test(name));
}

Expand Down
Loading