major cleanup (part 1) #66
9 changed files with 3 additions and 63 deletions
|
@ -4,7 +4,7 @@ module.exports = {
|
||||||
es2021: true,
|
es2021: true,
|
||||||
node: true,
|
node: true,
|
||||||
},
|
},
|
||||||
extends: ['eslint:recommended', 'plugin:import/recommended', 'prettier'],
|
extends: ['eslint:recommended', 'plugin:import/recommended'],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 'latest',
|
ecmaVersion: 'latest',
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
"lint:tsc:ci": "pnpm -r exec tsc --build",
|
"lint:tsc:ci": "pnpm -r exec tsc --build",
|
||||||
"lint:dpdm": "dpdm -T --no-warning --no-tree --exit-code circular:1 packages/*",
|
"lint:dpdm": "dpdm -T --no-warning --no-tree --exit-code circular:1 packages/*",
|
||||||
"lint:fix": "eslint --fix .",
|
"lint:fix": "eslint --fix .",
|
||||||
"format": "prettier --write \"packages/**/*.ts\"",
|
|
||||||
"publish-all": "node scripts/publish.js all",
|
"publish-all": "node scripts/publish.js all",
|
||||||
"docs": "typedoc --options .config/typedoc/config.cjs",
|
"docs": "typedoc --options .config/typedoc/config.cjs",
|
||||||
"build-package": "node scripts/build-package.js"
|
"build-package": "node scripts/build-package.js"
|
||||||
|
@ -61,14 +60,12 @@
|
||||||
"dpdm": "3.14.0",
|
"dpdm": "3.14.0",
|
||||||
"esbuild": "0.23.0",
|
"esbuild": "0.23.0",
|
||||||
"eslint": "8.47.0",
|
"eslint": "8.47.0",
|
||||||
"eslint-config-prettier": "8.8.0",
|
|
||||||
"eslint-import-resolver-typescript": "3.6.0",
|
"eslint-import-resolver-typescript": "3.6.0",
|
||||||
"eslint-plugin-ascii": "1.0.0",
|
"eslint-plugin-ascii": "1.0.0",
|
||||||
"eslint-plugin-import": "2.28.0",
|
"eslint-plugin-import": "2.28.0",
|
||||||
"eslint-plugin-simple-import-sort": "10.0.0",
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
||||||
"glob": "11.0.0",
|
"glob": "11.0.0",
|
||||||
"playwright": "1.42.1",
|
"playwright": "1.42.1",
|
||||||
"prettier": "3.0.3",
|
|
||||||
"rimraf": "6.0.1",
|
"rimraf": "6.0.1",
|
||||||
"semver": "7.5.1",
|
"semver": "7.5.1",
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.1",
|
||||||
|
@ -80,7 +77,6 @@
|
||||||
"vitest": "2.0.5"
|
"vitest": "2.0.5"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.0.6",
|
"packageManager": "pnpm@9.0.6",
|
||||||
"prettier": "./.config/prettier.cjs",
|
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": "./.config/eslint.cjs"
|
"extends": "./.config/eslint.cjs"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const ts = require('typescript')
|
const ts = require('typescript')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const prettier = require('prettier')
|
|
||||||
const updates = require('./generate-updates.cjs')
|
const updates = require('./generate-updates.cjs')
|
||||||
|
|
||||||
const schema = require('../../tl/api-schema.json')
|
const schema = require('../../tl/api-schema.json')
|
||||||
|
@ -185,16 +184,6 @@ function determineCommonAvailability(methods, resolver = (v) => v) {
|
||||||
return common
|
return common
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runPrettier(targetFile) {
|
|
||||||
const prettierConfig = await prettier.resolveConfig(targetFile)
|
|
||||||
let fullSource = await fs.promises.readFile(targetFile, 'utf-8')
|
|
||||||
fullSource = await prettier.format(fullSource, {
|
|
||||||
...(prettierConfig || {}),
|
|
||||||
filepath: targetFile,
|
|
||||||
})
|
|
||||||
await fs.promises.writeFile(targetFile, fullSource)
|
|
||||||
}
|
|
||||||
|
|
||||||
function runEslint(targetFile) {
|
function runEslint(targetFile) {
|
||||||
require('child_process').execSync(`pnpm exec eslint --fix ${targetFile}`, {
|
require('child_process').execSync(`pnpm exec eslint --fix ${targetFile}`, {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
|
@ -781,10 +770,6 @@ withParams(params: RpcCallOptions): this\n`)
|
||||||
await new Promise((resolve) => { outputMethods.end(resolve) })
|
await new Promise((resolve) => { outputMethods.end(resolve) })
|
||||||
await new Promise((resolve) => { output.end(resolve) })
|
await new Promise((resolve) => { output.end(resolve) })
|
||||||
|
|
||||||
// format the resulting files with prettier and eslint
|
|
||||||
runPrettier(targetFile)
|
|
||||||
runPrettier(targetFileMethods)
|
|
||||||
|
|
||||||
runEslint(targetFile)
|
runEslint(targetFile)
|
||||||
runEslint(targetFileMethods)
|
runEslint(targetFileMethods)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const prettier = require('prettier')
|
|
||||||
|
|
||||||
const snakeToCamel = (s) => {
|
const snakeToCamel = (s) => {
|
||||||
return s.replace(/(?<!^|_)(_[a-z0-9])/gi, ($1) => {
|
return s.replace(/(?<!^|_)(_[a-z0-9])/gi, ($1) => {
|
||||||
|
@ -65,17 +64,6 @@ function replaceSections(filename, sections, dir = __dirname) {
|
||||||
|
|
||||||
const types = parseUpdateTypes()
|
const types = parseUpdateTypes()
|
||||||
|
|
||||||
async function formatFile(filename, dir = __dirname) {
|
|
||||||
const targetFile = path.join(dir, '../src/', filename)
|
|
||||||
const prettierConfig = await prettier.resolveConfig(targetFile)
|
|
||||||
let fullSource = await fs.promises.readFile(targetFile, 'utf-8')
|
|
||||||
fullSource = await prettier.format(fullSource, {
|
|
||||||
...(prettierConfig || {}),
|
|
||||||
filepath: targetFile,
|
|
||||||
})
|
|
||||||
await fs.promises.writeFile(targetFile, fullSource)
|
|
||||||
}
|
|
||||||
|
|
||||||
function toSentence(type, stype = 'inline') {
|
function toSentence(type, stype = 'inline') {
|
||||||
const name = camelToSnake(type.handlerTypeName).toLowerCase().replace(/_/g, ' ')
|
const name = camelToSnake(type.handlerTypeName).toLowerCase().replace(/_/g, ' ')
|
||||||
|
|
||||||
|
@ -100,7 +88,7 @@ async function main() {
|
||||||
generateParsedUpdate()
|
generateParsedUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { types, toSentence, replaceSections, formatFile }
|
module.exports = { types, toSentence, replaceSections }
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
main().catch(console.error)
|
main().catch(console.error)
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
{{#if features.linters}}
|
{{#if features.linters}}
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint --fix .",
|
"lint:fix": "eslint --fix .",
|
||||||
"format": "prettier --write \"src/**/*.ts\"",
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (eq runtime "bun")}}
|
{{#if (eq runtime "bun")}}
|
||||||
{{#if features.typescript}}
|
{{#if features.typescript}}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { types, toSentence, replaceSections, formatFile } = require('../../core/scripts/generate-updates.cjs')
|
const { types, toSentence, replaceSections } = require('../../core/scripts/generate-updates.cjs')
|
||||||
|
|
||||||
function generateHandler() {
|
function generateHandler() {
|
||||||
const lines = []
|
const lines = []
|
||||||
|
@ -105,9 +105,6 @@ ${
|
||||||
async function main() {
|
async function main() {
|
||||||
generateHandler()
|
generateHandler()
|
||||||
generateDispatcher()
|
generateDispatcher()
|
||||||
|
|
||||||
await formatFile('handler.ts', __dirname)
|
|
||||||
await formatFile('dispatcher.ts', __dirname)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { types, toSentence }
|
module.exports = { types, toSentence }
|
||||||
|
|
|
@ -37,7 +37,6 @@ export const chat =
|
||||||
(msg) =>
|
(msg) =>
|
||||||
msg.chat.chatType === type
|
msg.chat.chatType === type
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
/**
|
/**
|
||||||
* Filter updates by marked chat ID(s) or username(s)
|
* Filter updates by marked chat ID(s) or username(s)
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,7 +32,6 @@ export const me: UpdateFilter<Message, { sender: User }> = (msg) =>
|
||||||
*/
|
*/
|
||||||
export const bot: UpdateFilter<Message, { sender: User }> = (msg) => msg.sender.constructor === User && msg.sender.isBot
|
export const bot: UpdateFilter<Message, { sender: User }> = (msg) => msg.sender.constructor === User && msg.sender.isBot
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
/**
|
/**
|
||||||
* Filter updates by user ID(s) or username(s)
|
* Filter updates by user ID(s) or username(s)
|
||||||
*
|
*
|
||||||
|
|
|
@ -59,9 +59,6 @@ importers:
|
||||||
eslint:
|
eslint:
|
||||||
specifier: 8.47.0
|
specifier: 8.47.0
|
||||||
version: 8.47.0
|
version: 8.47.0
|
||||||
eslint-config-prettier:
|
|
||||||
specifier: 8.8.0
|
|
||||||
version: 8.8.0(eslint@8.47.0)
|
|
||||||
eslint-import-resolver-typescript:
|
eslint-import-resolver-typescript:
|
||||||
specifier: 3.6.0
|
specifier: 3.6.0
|
||||||
version: 3.6.0(@typescript-eslint/parser@6.4.0(eslint@8.47.0)(typescript@5.4.3))(eslint-plugin-import@2.28.0)(eslint@8.47.0)
|
version: 3.6.0(@typescript-eslint/parser@6.4.0(eslint@8.47.0)(typescript@5.4.3))(eslint-plugin-import@2.28.0)(eslint@8.47.0)
|
||||||
|
@ -80,9 +77,6 @@ importers:
|
||||||
playwright:
|
playwright:
|
||||||
specifier: 1.42.1
|
specifier: 1.42.1
|
||||||
version: 1.42.1
|
version: 1.42.1
|
||||||
prettier:
|
|
||||||
specifier: 3.0.3
|
|
||||||
version: 3.0.3
|
|
||||||
rimraf:
|
rimraf:
|
||||||
specifier: 6.0.1
|
specifier: 6.0.1
|
||||||
version: 6.0.1
|
version: 6.0.1
|
||||||
|
@ -1801,12 +1795,6 @@ packages:
|
||||||
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
|
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
eslint-config-prettier@8.8.0:
|
|
||||||
resolution: {integrity: sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==}
|
|
||||||
hasBin: true
|
|
||||||
peerDependencies:
|
|
||||||
eslint: '>=7.0.0'
|
|
||||||
|
|
||||||
eslint-import-resolver-node@0.3.7:
|
eslint-import-resolver-node@0.3.7:
|
||||||
resolution: {integrity: sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==}
|
resolution: {integrity: sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==}
|
||||||
|
|
||||||
|
@ -2753,11 +2741,6 @@ packages:
|
||||||
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
|
|
||||||
prettier@3.0.3:
|
|
||||||
resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==}
|
|
||||||
engines: {node: '>=14'}
|
|
||||||
hasBin: true
|
|
||||||
|
|
||||||
pretty-format@27.5.1:
|
pretty-format@27.5.1:
|
||||||
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
|
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
|
||||||
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
|
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
|
||||||
|
@ -4852,10 +4835,6 @@ snapshots:
|
||||||
|
|
||||||
escape-string-regexp@5.0.0: {}
|
escape-string-regexp@5.0.0: {}
|
||||||
|
|
||||||
eslint-config-prettier@8.8.0(eslint@8.47.0):
|
|
||||||
dependencies:
|
|
||||||
eslint: 8.47.0
|
|
||||||
|
|
||||||
eslint-import-resolver-node@0.3.7:
|
eslint-import-resolver-node@0.3.7:
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 3.2.7
|
debug: 3.2.7
|
||||||
|
@ -5934,8 +5913,6 @@ snapshots:
|
||||||
|
|
||||||
prelude-ls@1.2.1: {}
|
prelude-ls@1.2.1: {}
|
||||||
|
|
||||||
prettier@3.0.3: {}
|
|
||||||
|
|
||||||
pretty-format@27.5.1:
|
pretty-format@27.5.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-regex: 5.0.1
|
ansi-regex: 5.0.1
|
||||||
|
|
Loading…
Reference in a new issue