Homework 1. Basic project template and console calculator#1
Homework 1. Basic project template and console calculator#1ILyaCyclone wants to merge 8 commits into
Conversation
Project template contains basic configuration for typescript, jest, babel and webpack. Console calculator implements simple binary operators: + - * / ^ %.
|
На данный момент проведена базовая настройка проекта и реализованы простые выражения в калькуляторе. |
Webpack now builds console calculator.
calc.ts needs refactoring to lower code complexity.
Also format table spacer rows in README.md for github flavor.
| "printWidth": 140, | ||
| "tabWidth": 4, | ||
| "semi": true, | ||
| "trailingComma": "none", | ||
| "singleQuote": false, | ||
| "quoteProps": "preserve" |
There was a problem hiding this comment.
зачем ? printWidth я могу понять, а остальное?
| "husky": { | ||
| "hooks": { | ||
| "pre-commit": "npm run check", | ||
| "pre-push": "npm run check" |
There was a problem hiding this comment.
а смысл? если ты это уже прогнал перед коммитом
| }, | ||
| "husky": { | ||
| "hooks": { | ||
| "pre-commit": "npm run check", |
There was a problem hiding this comment.
в проекте 1000 файлов
ты поменял 100
в коммит добавил 10
сколько файлов проверит твоя настройка?
| import { evaluate } from "./calc"; | ||
|
|
||
| describe("calc basic expressions", () => { | ||
| test("1 + 2 = 3", () => { |
There was a problem hiding this comment.
https://jestjs.io/docs/en/api#testeachtablename-fn-timeout
ну или forEach какой-нибудь
не лень было столько однотипного кода писать?
| * Evaluates expression into array of tokens. | ||
| * @param {string} expression Expression string in form of numbers, operators and groups, e.g. `5 * (1 + 2)`. | ||
| * @throws Error if invalid expression or unsupported operation. | ||
| * @returns {number} Calculation result. |
There was a problem hiding this comment.
зачем тут jsdoc? типы же в коде описаны
| if (isOperator(token) && priorityLevel.includes(token as string)) { | ||
| const operator: string = token as string; | ||
|
|
||
| if (isMathBinaryOperator(operator)) return calculateBinaryOperation(tokens, i); |
There was a problem hiding this comment.
я бы не стал злоупотреблять однострочными if
| @@ -0,0 +1,12 @@ | |||
| { | |||
| "compilerOptions": { | |||
There was a problem hiding this comment.
хорошо бы конфиги через инит комманды создавать (и jest тоже)
Homework 1 task