Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get rid of typings re-write main parts of the package in typescript #766

Merged
merged 2 commits into from
Jun 21, 2023
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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ module.exports = {
ecmaVersion: 2022,
},
overrides: [
{
files: ["*.ts"],
rules: {
"@typescript-eslint/explicit-function-return-type": "error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем хочешь обязательно тип указывать? TS ведь может самостоятельно корректно определить return type в большинстве кейсов.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне кажется явное задание возвращаемого типа в функциях — хорошая практика, такой код очень удобно и приятно читать, даже если это происходит в github или виме не надо анализировать, что тут вернется. Ну и кажется раньше в монорепе был такой конфиг у нас.

Могу убрать, конечно, но я считаю, что это очень полезное правило

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я тоже скорее склоняюсь к explicit аннотациям, именно по причине таких юз кейсов типа ревью, гит истории и тп

},
},
{
files: ["*.js"],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion bin/hermione
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
'use strict';

var cli = require('../build/cli').run();
var cli = require('../build/src/cli').run();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А для чего у нас внутри build создается папка src? Я бы ожидал, что она трансформируется в build.

Copy link
Member Author

@shadowusr shadowusr Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что в этом плохого? Рома тоже спрашивал этот момент. Такие поинты:

  • rootDir изменился с ./src на . из-за того, что у нас в коде есть импорты файлов вне src, например, из package.json у нас достается имя пакета и версия (ранее работало, т.к. импорты находились в js файлах)
  • build/src фигурирует всего в 2-х местах и по факту не влияет ни на пользователя, ни на разработчика. Не вижу в этом какой-то проблемы.

Поэтому оставил так. Однако я всегда открыт для предложений и готов поменять этот момент.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, src там появилась потому что появился импорт, который идет вне src. Разницы никакой нет, поэтому предлагаю не заморачиваться

98 changes: 84 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
"name": "hermione",
"version": "7.1.0",
"description": "Tests framework based on mocha and wdio",
"main": "build/hermione.js",
"main": "build/src/index.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут тоже странно, что src оказывается внутри build

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ответил выше

"files": [
"build",
"typings"
"build"
],
"types": "./typings/index.d.ts",
"scripts": {
"build": "tsc && copyfiles --up 1 'src/browser/client-scripts/*' build",
"build": "tsc && npm run copy-static",
"copy-static": "copyfiles 'src/browser/client-scripts/*' 'typings/*' build",
"check-types": "tsc --project tsconfig.spec.json",
"clean": "rimraf build/ *.tsbuildinfo",
"coverage": "nyc --reporter=text npm run test-unit",
Expand All @@ -23,7 +22,8 @@
"prepack": "npm run clean && npm run build",
"preversion": "npm run lint && npm test",
"commitmsg": "commitlint -e",
"release": "standard-version"
"release": "standard-version",
"watch": "npm run copy-static && tsc --watch"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -65,7 +65,7 @@
"looks-same": "^8.1.0",
"micromatch": "^4.0.5",
"mocha": "^10.2.0",
"plugins-loader": "^1.1.0",
"plugins-loader": "^1.2.0",
"png-validator": "1.1.0",
"sharp": "~0.30.7",
"sizzle": "^2.3.6",
Expand All @@ -81,6 +81,7 @@
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@swc/core": "^1.3.40",
"@types/bluebird": "^3.5.38",
"@types/chai": "^4.3.4",
"@types/chai-as-promised": "^7.1.5",
"@types/lodash": "^4.14.191",
Expand Down Expand Up @@ -111,6 +112,7 @@
"sinon-chai": "^2.12.0",
"standard-version": "^9.5.0",
"ts-node": "^10.9.1",
"type-fest": "^3.10.0",
"typescript": "^4.9.5"
},
"peerDependencies": {
Expand Down
62 changes: 0 additions & 62 deletions src/base-hermione.js

This file was deleted.

Loading