diff --git a/.gitignore b/.gitignore index 3830620a8..e64af622b 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ fsevents-patch-*.zip @esbuild-*-npm-*.zip @rollup-rollup-*-*-npm-*.zip .idea +.vim diff --git a/.pnp.cjs b/.pnp.cjs index 7547da769..e22795f09 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -339,7 +339,7 @@ const RAW_RUNTIME_STATE = ["@atls/code-commit", ["workspace:code/code-commit"]],\ ["@atls/code-configuration", ["workspace:code/code-configuration"]],\ ["@atls/code-format", ["workspace:code/code-format"]],\ - ["@atls/code-github", ["workspace:code/code-github"]],\ + ["@atls/code-github", ["virtual:bbcc09757fc2c8fe1988d3f27a93dfa46b1ad5c7cff2c229f3479d029379bde7a751f5aa608d45793b48a3281bd52e78a80f3bd1410fde26592afacb695b2ad3#workspace:code/code-github", "workspace:code/code-github"]],\ ["@atls/code-icons", ["workspace:code/code-icons"]],\ ["@atls/code-jsr", ["workspace:code/code-jsr"]],\ ["@atls/code-lint", ["virtual:0bee91e20275b56da8822b92f0e07382082a4fb81d3ac954c05d4bb97d3e85b3a7bbfeaf8b8c9f0277fd5b2807a701685833b298edd77100361656dd4e9c2e63#workspace:code/code-lint", "workspace:code/code-lint"]],\ @@ -1538,12 +1538,27 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["@atls/code-github", [\ + ["virtual:bbcc09757fc2c8fe1988d3f27a93dfa46b1ad5c7cff2c229f3479d029379bde7a751f5aa608d45793b48a3281bd52e78a80f3bd1410fde26592afacb695b2ad3#workspace:code/code-github", {\ + "packageLocation": "./.yarn/__virtual__/@atls-code-github-virtual-1acb0bbcc8/1/code/code-github/",\ + "packageDependencies": [\ + ["@atls/code-github", "virtual:bbcc09757fc2c8fe1988d3f27a93dfa46b1ad5c7cff2c229f3479d029379bde7a751f5aa608d45793b48a3281bd52e78a80f3bd1410fde26592afacb695b2ad3#workspace:code/code-github"],\ + ["@octokit/auth-action", "npm:5.1.1"],\ + ["@octokit/rest", "npm:21.0.2"],\ + ["@octokit/types", "npm:13.5.0"],\ + ["@types/octokit__types", null]\ + ],\ + "packagePeers": [\ + "@types/octokit__types"\ + ],\ + "linkType": "SOFT"\ + }],\ ["workspace:code/code-github", {\ "packageLocation": "./code/code-github/",\ "packageDependencies": [\ ["@atls/code-github", "workspace:code/code-github"],\ ["@octokit/auth-action", "npm:5.1.1"],\ - ["@octokit/rest", "npm:21.0.2"]\ + ["@octokit/rest", "npm:21.0.2"],\ + ["@octokit/types", "npm:13.5.0"]\ ],\ "linkType": "SOFT"\ }]\ @@ -1655,6 +1670,7 @@ const RAW_RUNTIME_STATE = ["@atls/code-schematics", "workspace:code/code-schematics"],\ ["@angular-devkit/core", "virtual:4714d233331a06d9fd78f898e63666063fd535bf16c82e792f40caac5e79c8b8c761072796520e293fe924361727ee6a861f4093b71ee28a7a5bfc51b23e3ce3#npm:18.2.2"],\ ["@angular-devkit/schematics", "npm:18.2.2"],\ + ["@types/node", "npm:22.9.0"],\ ["rxjs", "npm:7.8.1"]\ ],\ "linkType": "SOFT"\ @@ -2684,7 +2700,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["@atls/yarn-plugin-release", "virtual:c7c9eb0e73da0d3b08e1c93a487175d4550637edc7803e366cfe4f5b03b5ee4396f9e6450b2b2bb67fc7215840222e691bb10d7e4ff124152da2c00403c18d78#workspace:yarn/plugin-release"],\ ["@atls/code-changelog", "workspace:code/code-changelog"],\ - ["@atls/code-github", "workspace:code/code-github"],\ + ["@atls/code-github", "virtual:bbcc09757fc2c8fe1988d3f27a93dfa46b1ad5c7cff2c229f3479d029379bde7a751f5aa608d45793b48a3281bd52e78a80f3bd1410fde26592afacb695b2ad3#workspace:code/code-github"],\ ["@types/yarnpkg__cli", null],\ ["@types/yarnpkg__core", null],\ ["@yarnpkg/builder", "patch:@yarnpkg/builder@npm%3A4.1.2#~/.yarn/patches/@yarnpkg-builder-npm-4.1.2-2648882e59.patch::version=4.1.2&hash=a711a8"],\ @@ -2705,7 +2721,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["@atls/yarn-plugin-release", "workspace:yarn/plugin-release"],\ ["@atls/code-changelog", "workspace:code/code-changelog"],\ - ["@atls/code-github", "workspace:code/code-github"],\ + ["@atls/code-github", "virtual:bbcc09757fc2c8fe1988d3f27a93dfa46b1ad5c7cff2c229f3479d029379bde7a751f5aa608d45793b48a3281bd52e78a80f3bd1410fde26592afacb695b2ad3#workspace:code/code-github"],\ ["@yarnpkg/builder", "patch:@yarnpkg/builder@npm%3A4.1.2#~/.yarn/patches/@yarnpkg-builder-npm-4.1.2-2648882e59.patch::version=4.1.2&hash=a711a8"],\ ["@yarnpkg/cli", "virtual:cc0a970534b499add0064d8eb1fc3286f3c9be4bf3080c3e6e508964ea5232777f3e0009913a6a066796387e6b8a4b9e488b8a0d642735fad9419dc069d9dbde#npm:4.5.1"],\ ["@yarnpkg/core", "npm:4.1.4"],\ diff --git a/.yarn/unplugged/@esbuild-darwin-arm64-npm-0.23.1-1d26281f3d/node_modules/@esbuild/darwin-arm64/.ready b/.yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/.ready similarity index 100% rename from .yarn/unplugged/@esbuild-darwin-arm64-npm-0.23.1-1d26281f3d/node_modules/@esbuild/darwin-arm64/.ready rename to .yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/.ready diff --git a/.yarn/unplugged/@esbuild-darwin-arm64-npm-0.23.1-1d26281f3d/node_modules/@esbuild/darwin-arm64/bin/esbuild b/.yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/bin/esbuild similarity index 55% rename from .yarn/unplugged/@esbuild-darwin-arm64-npm-0.23.1-1d26281f3d/node_modules/@esbuild/darwin-arm64/bin/esbuild rename to .yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/bin/esbuild index df590846e..4ca0436d9 100755 Binary files a/.yarn/unplugged/@esbuild-darwin-arm64-npm-0.23.1-1d26281f3d/node_modules/@esbuild/darwin-arm64/bin/esbuild and b/.yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/bin/esbuild differ diff --git a/.yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/package.json b/.yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/package.json new file mode 100644 index 000000000..66cd89635 --- /dev/null +++ b/.yarn/unplugged/@esbuild-linux-x64-npm-0.23.1-e5d2d8764d/node_modules/@esbuild/linux-x64/package.json @@ -0,0 +1,20 @@ +{ + "name": "@esbuild/linux-x64", + "version": "0.23.1", + "description": "The Linux 64-bit binary for esbuild, a JavaScript bundler.", + "repository": { + "type": "git", + "url": "git+https://github.com/evanw/esbuild.git" + }, + "license": "MIT", + "preferUnplugged": true, + "engines": { + "node": ">=18" + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ] +} diff --git a/.yarn/unplugged/@rollup-rollup-darwin-arm64-npm-4.21.2-4afb0af697/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node b/.yarn/unplugged/@rollup-rollup-darwin-arm64-npm-4.21.2-4afb0af697/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node deleted file mode 100644 index 73b0821b6..000000000 Binary files a/.yarn/unplugged/@rollup-rollup-darwin-arm64-npm-4.21.2-4afb0af697/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node and /dev/null differ diff --git a/.yarn/unplugged/@rollup-rollup-darwin-arm64-npm-4.21.2-4afb0af697/node_modules/@rollup/rollup-darwin-arm64/.ready b/.yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/.ready similarity index 100% rename from .yarn/unplugged/@rollup-rollup-darwin-arm64-npm-4.21.2-4afb0af697/node_modules/@rollup/rollup-darwin-arm64/.ready rename to .yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/.ready diff --git a/.yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/package.json b/.yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/package.json new file mode 100644 index 000000000..2e8b4c044 --- /dev/null +++ b/.yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-linux-x64-gnu", + "version": "4.21.2", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.linux-x64-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": "rollup/rollup", + "libc": [ + "glibc" + ], + "main": "./rollup.linux-x64-gnu.node" +} \ No newline at end of file diff --git a/.yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node b/.yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node new file mode 100644 index 000000000..1fbcc469f Binary files /dev/null and b/.yarn/unplugged/@rollup-rollup-linux-x64-gnu-npm-4.21.2-65bebf97f0/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node differ diff --git a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/.ready b/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/.ready deleted file mode 100644 index e69de29bb..000000000 diff --git a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/LICENSE b/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/LICENSE deleted file mode 100644 index 5d70441c3..000000000 --- a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License ------------ - -Copyright (C) 2010-2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.d.ts b/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.d.ts deleted file mode 100644 index 2723c048a..000000000 --- a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -declare type Event = "created" | "cloned" | "modified" | "deleted" | "moved" | "root-changed" | "unknown"; -declare type Type = "file" | "directory" | "symlink"; -declare type FileChanges = { - inode: boolean; - finder: boolean; - access: boolean; - xattrs: boolean; -}; -declare type Info = { - event: Event; - path: string; - type: Type; - changes: FileChanges; - flags: number; -}; -declare type WatchHandler = (path: string, flags: number, id: string) => void; -export declare function watch(path: string, handler: WatchHandler): () => Promise; -export declare function watch(path: string, since: number, handler: WatchHandler): () => Promise; -export declare function getInfo(path: string, flags: number): Info; -export declare const constants: { - None: 0x00000000; - MustScanSubDirs: 0x00000001; - UserDropped: 0x00000002; - KernelDropped: 0x00000004; - EventIdsWrapped: 0x00000008; - HistoryDone: 0x00000010; - RootChanged: 0x00000020; - Mount: 0x00000040; - Unmount: 0x00000080; - ItemCreated: 0x00000100; - ItemRemoved: 0x00000200; - ItemInodeMetaMod: 0x00000400; - ItemRenamed: 0x00000800; - ItemModified: 0x00001000; - ItemFinderInfoMod: 0x00002000; - ItemChangeOwner: 0x00004000; - ItemXattrMod: 0x00008000; - ItemIsFile: 0x00010000; - ItemIsDir: 0x00020000; - ItemIsSymlink: 0x00040000; - ItemIsHardlink: 0x00100000; - ItemIsLastHardlink: 0x00200000; - OwnEvent: 0x00080000; - ItemCloned: 0x00400000; -}; -export {}; diff --git a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.js b/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.js deleted file mode 100644 index a8bb92d35..000000000 --- a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - ** © 2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller - ** Licensed under MIT License. - */ - -/* jshint node:true */ -"use strict"; - -if (process.platform !== "darwin") { - throw new Error(`Module 'fsevents' is not compatible with platform '${process.platform}'`); -} - -const Native = require("./fsevents.node"); -const events = Native.constants; - -function watch(path, since, handler) { - if (typeof path !== "string") { - throw new TypeError(`fsevents argument 1 must be a string and not a ${typeof path}`); - } - if ("function" === typeof since && "undefined" === typeof handler) { - handler = since; - since = Native.flags.SinceNow; - } - if (typeof since !== "number") { - throw new TypeError(`fsevents argument 2 must be a number and not a ${typeof since}`); - } - if (typeof handler !== "function") { - throw new TypeError(`fsevents argument 3 must be a function and not a ${typeof handler}`); - } - - let VFS = require('./vfs'); - let vfs = new VFS(path); - let instance = Native.start(Native.global, vfs.resolvedPath, since, vfs.wrap(handler)); - if (!instance) throw new Error(`could not watch: ${path}`); - return () => { - const result = instance ? Promise.resolve(instance).then(Native.stop) : Promise.resolve(undefined); - instance = undefined; - return result; - }; -} - -function getInfo(path, flags) { - return { - path, - flags, - event: getEventType(flags), - type: getFileType(flags), - changes: getFileChanges(flags), - }; -} - -function getFileType(flags) { - if (events.ItemIsFile & flags) return "file"; - if (events.ItemIsDir & flags) return "directory"; - if (events.MustScanSubDirs & flags) return "directory"; - if (events.ItemIsSymlink & flags) return "symlink"; -} -function anyIsTrue(obj) { - for (let key in obj) { - if (obj[key]) return true; - } - return false; -} -function getEventType(flags) { - if (events.ItemRemoved & flags) return "deleted"; - if (events.ItemRenamed & flags) return "moved"; - if (events.ItemCreated & flags) return "created"; - if (events.ItemModified & flags) return "modified"; - if (events.RootChanged & flags) return "root-changed"; - if (events.ItemCloned & flags) return "cloned"; - if (anyIsTrue(flags)) return "modified"; - return "unknown"; -} -function getFileChanges(flags) { - return { - inode: !!(events.ItemInodeMetaMod & flags), - finder: !!(events.ItemFinderInfoMod & flags), - access: !!(events.ItemChangeOwner & flags), - xattrs: !!(events.ItemXattrMod & flags), - }; -} - -exports.watch = watch; -exports.getInfo = getInfo; -exports.constants = events; diff --git a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.node b/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.node deleted file mode 100755 index 1cc3345ea..000000000 Binary files a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/fsevents.node and /dev/null differ diff --git a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/vfs.js b/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/vfs.js deleted file mode 100644 index 34199122d..000000000 --- a/.yarn/unplugged/fsevents-patch-6b67494872/node_modules/fsevents/vfs.js +++ /dev/null @@ -1,76 +0,0 @@ -const path = require(`path`); - -let pnpApi = null; -try { - pnpApi = require(`pnpapi`); -} catch { -} - -function getVirtualLookupFn(pnpApi) { - const reverseMap = new Map(); - - for (const locator of pnpApi.getAllLocators()) { - const pkg = pnpApi.getPackageInformation(locator); - console.assert(pkg, `The package information should be available`); - - const resolvedLocation = pnpApi.resolveVirtual(pkg.packageLocation); - if (resolvedLocation === null) - continue; - - const aliases = reverseMap.get(resolvedLocation) || [resolvedLocation]; - reverseMap.set(resolvedLocation, aliases); - aliases.push(pkg.packageLocation); - } - - const keys = [...reverseMap.keys()].sort((a, b) => { - return b.length - a.length; - }); - - return p => { - const prefix = keys.find(candidate => p.startsWith(candidate)); - if (typeof prefix === `undefined`) - return [p]; - - const sub = p.substr(prefix.length); - return reverseMap.get(prefix).map(alias => { - return alias + sub; - }); - }; -} - -if (pnpApi != null) { - const resolveVirtualAliases = getVirtualLookupFn(pnpApi); - - module.exports = class FsePnp { - constructor(p) { - this.normalizedPath = path.resolve(p); - this.resolvedPath = pnpApi.resolveVirtual(this.normalizedPath) || this.normalizedPath; - } - - transpose(p) { - if (this.resolvedPath !== null) { - return this.normalizedPath + p.substr(this.resolvedPath.length); - } else { - return p; - } - } - - wrap(fn) { - return (path, ...args) => { - for (const entry of resolveVirtualAliases(path)) { - fn(this.transpose(entry), ...args); - } - }; - } - }; -} else { - module.exports = class FsePnp { - constructor(p) { - this.resolvedPath = p; - } - - wrap(fn) { - return fn; - } - }; -} diff --git a/.yarnrc.yml b/.yarnrc.yml index cdcaf5057..7cb4717cb 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -3,6 +3,9 @@ compressionLevel: mixed enableGlobalCache: false packageExtensions: + '@octokit/auth-action@*': + dependencies: + '@octokit/types': '*' '@actions/github@*': dependencies: undici: '*' @@ -100,4 +103,4 @@ defaultSemverRangePrefix: '' preferReuse: true yarnPath: yarn/cli/src/cli.dev.mjs -#yarnPath: .yarn/releases/yarn-4.5.1.cjs +# yarnPath: .yarn/releases/yarn-4.5.1.cjs diff --git a/cli/cli-ui-schematics-component/src/request-project-information/request-project-information.component.tsx b/cli/cli-ui-schematics-component/src/request-project-information/request-project-information.component.tsx index c43703024..0e462c479 100644 --- a/cli/cli-ui-schematics-component/src/request-project-information/request-project-information.component.tsx +++ b/cli/cli-ui-schematics-component/src/request-project-information/request-project-information.component.tsx @@ -9,7 +9,11 @@ import React from 'react' import { ProjectType } from '@atls/schematics' -const Submit = ({ onSubmit, ...props }: any) => { +interface SubmitProps { + onSubmit: (props: ProjectInformationProperties) => void +} + +const Submit = ({ onSubmit, ...props }: ProjectInformationProperties & SubmitProps): null => { useEffect(() => { onSubmit(props) }, [props, onSubmit]) @@ -27,6 +31,7 @@ interface RequestProjectInformationProps { // TODO: refactor for usage in new plugin export const RequestProjectInformation: FC = ({ onSubmit }) => { const [type, setType] = useState() + if (!type) { return ( @@ -48,7 +53,6 @@ export const RequestProjectInformation: FC = ({ ]} // eslint-disable-next-line onSelect={(v) => setType(v.value)} - indicatorComponent={IndicatorComponent} /> ) diff --git a/code/code-changelog/src/changelog.ts b/code/code-changelog/src/changelog.ts index aad9934f4..e0f51cd07 100644 --- a/code/code-changelog/src/changelog.ts +++ b/code/code-changelog/src/changelog.ts @@ -31,7 +31,9 @@ export class Changelog { const config: Options = { lernaPackage: `${packageName}`, tagPrefix, + // eslint-disable-next-line no-console debug: debug ? console.debug : undefined, + // eslint-disable-next-line no-console warn: console.warn, append: true, releaseCount, @@ -42,7 +44,7 @@ export class Changelog { } if (file) { - return await this.generateToFile(config, path) + return this.generateToFile(config, path) } return this.generateToStdOut(config) @@ -55,12 +57,16 @@ export class Changelog { }) let newChangelog = '' - changelogStream.on('data', (chunk) => { + changelogStream.on('data', (chunk: Buffer) => { newChangelog += chunk.toString() }) - changelogStream.on('end', () => resolve(newChangelog)) - changelogStream.on('error', (error) => reject(error)) + changelogStream.on('end', () => { + resolve(newChangelog) + }) + changelogStream.on('error', (error) => { + reject(error) + }) }) } @@ -73,7 +79,8 @@ export class Changelog { try { existingData = await readFile(outFile, 'utf8') - } catch (error: any) { + } catch (e: unknown) { + const error = e as Error & { code: string } if (error.code !== 'ENOENT') throw error } @@ -82,6 +89,7 @@ export class Changelog { return updatedData } catch (error) { + // eslint-disable-next-line no-console console.error('Error generating changelog:', error) throw error } diff --git a/code/code-commit/src/commit.linter.ts b/code/code-commit/src/commit.linter.ts index b5fdf27b1..a2afefb3b 100644 --- a/code/code-commit/src/commit.linter.ts +++ b/code/code-commit/src/commit.linter.ts @@ -1,9 +1,13 @@ +/* eslint-disable @typescript-eslint/no-shadow */ + import type { FormattableReport } from '@commitlint/types' +import type { RuleConfigQuality } from '@commitlint/types' +import type { RulesConfig } from '@commitlint/types' import type { LintOptions } from '@commitlint/types' +import type { LintOutcome } from '@commitlint/types' +import type { QualifiedRules } from '@commitlint/types' import { RuleConfigSeverity } from '@commitlint/types' -import { LintOutcome } from '@commitlint/types' -import { QualifiedRules } from '@commitlint/types' import { format } from '@commitlint/format/lib/format.js' import commitlint from '@commitlint/lint' @@ -55,7 +59,7 @@ export class CommitLinter { /** * Prepares config, including scopes */ - private prepareConfig(rules: QualifiedRules) { + private prepareConfig(rules: QualifiedRules): Partial> { const allowedScopes = [] if (this.scopes) { @@ -67,6 +71,7 @@ export class CommitLinter { } const possibleScopeValuesArray = ['common', 'github', ...allowedScopes] + // eslint-disable-next-line no-param-reassign rules['scope-enum'] = [RuleConfigSeverity.Error, 'always', possibleScopeValuesArray] return rules diff --git a/code/code-format/src/formatter.ts b/code/code-format/src/formatter.ts index 8cd78713a..05d375ce4 100644 --- a/code/code-format/src/formatter.ts +++ b/code/code-format/src/formatter.ts @@ -1,24 +1,24 @@ -import EventEmitter from 'node:events' -import { writeFile } from 'node:fs/promises' -import { readFile } from 'node:fs/promises' -import { relative } from 'node:path' -import { join } from 'node:path' - -import * as babel from 'prettier/plugins/babel' -import * as estree from 'prettier/plugins/estree' -import * as graphql from 'prettier/plugins/graphql' -import * as markdown from 'prettier/plugins/markdown' -import * as typescript from 'prettier/plugins/typescript' -import * as yaml from 'prettier/plugins/yaml' -import { globby } from 'globby' -import { format } from 'prettier/standalone' -import ignorer from 'ignore' - -import config from '@atls/config-prettier' -import plugin from '@atls/prettier-plugin' - -import { ignore } from './formatter.patterns.js' -import { createPatterns } from './formatter.patterns.js' +import EventEmitter from 'node:events' +import { writeFile } from 'node:fs/promises' +import { readFile } from 'node:fs/promises' +import { relative } from 'node:path' +import { join } from 'node:path' + +import * as babel from 'prettier/plugins/babel' +import * as estree from 'prettier/plugins/estree' +import * as graphql from 'prettier/plugins/graphql' +import * as markdown from 'prettier/plugins/markdown' +import * as typescript from 'prettier/plugins/typescript' +import * as yaml from 'prettier/plugins/yaml' +import { globby } from 'globby' +import { format } from 'prettier/standalone' +import ignorer from 'ignore' + +import { getPrettierPlugin } from '@atls/prettier-plugin' +import config from '@atls/config-prettier' + +import { ignore } from './formatter.patterns.js' +import { createPatterns } from './formatter.patterns.js' export class Formatter extends EventEmitter { constructor(private readonly cwd: string) { @@ -38,6 +38,8 @@ export class Formatter extends EventEmitter { } protected async formatFiles(files: Array = []): Promise { + const prettierPlugin = await getPrettierPlugin() + const formatFiles = ignorer .default() .add(ignore) @@ -54,8 +56,8 @@ export class Formatter extends EventEmitter { const output = await format(input, { ...config, filepath: filename, - // @ts-expect-error any - plugins: [estree, yaml, markdown, graphql, babel, typescript, plugin], + // @ts-expect-error type not assignable + plugins: [estree, yaml, markdown, graphql, babel, typescript, prettierPlugin], }) if (output !== input && output) { diff --git a/code/code-github/package.json b/code/code-github/package.json index f5d5bfd95..0d64e80ff 100644 --- a/code/code-github/package.json +++ b/code/code-github/package.json @@ -20,6 +20,12 @@ "@octokit/auth-action": "5.1.1", "@octokit/rest": "21.0.2" }, + "devDependencies": { + "@octokit/types": "13.5.0" + }, + "peerDependencies": { + "@octokit/types": "*" + }, "publishConfig": { "access": "public", "exports": { @@ -32,5 +38,6 @@ }, "main": "dist/index.js", "types": "dist/index.d.ts" - } + }, + "typecheckSkipLibCheck": true } diff --git a/code/code-github/src/release.ts b/code/code-github/src/release.ts index f2de256c8..6f0675e14 100644 --- a/code/code-github/src/release.ts +++ b/code/code-github/src/release.ts @@ -26,14 +26,14 @@ export class Release { } async create(options: CreateOptions): Promise { - const { owner, repo, tag_name, name, make_latest, draft, body } = options + const { owner, repo, tag_name: tagName, name, make_latest: makeLatest, draft, body } = options const result = await this.client.repos.createRelease({ owner, repo, - tag_name, + tag_name: tagName, draft, - make_latest: make_latest ? 'true' : 'false', + make_latest: makeLatest ? 'true' : 'false', name, body, }) diff --git a/code/code-jsr/src/jsr.ts b/code/code-jsr/src/jsr.ts index 178158612..fc0bbb074 100644 --- a/code/code-jsr/src/jsr.ts +++ b/code/code-jsr/src/jsr.ts @@ -5,7 +5,7 @@ import { publish } from 'jsr' export class JSR { constructor(private readonly cwd: string) {} - async publish(options: PublishOptions) { + async publish(options: PublishOptions): Promise { await publish(this.cwd, options) } } diff --git a/code/code-lint/src/linter.ts b/code/code-lint/src/linter.ts index 933a3eaac..c3d773211 100644 --- a/code/code-lint/src/linter.ts +++ b/code/code-lint/src/linter.ts @@ -124,7 +124,7 @@ export class Linter extends EventEmitter { return this.lintFiles(finalFiles, options) } - private async lintWithCache(files: Array = []): Promise { + private async lintWithCache(files: Array = []): Promise> { this.emit('start', { files }) const results = await this.cacheLinter?.lintFiles(files) @@ -139,10 +139,11 @@ export class Linter extends EventEmitter { } private getProjectIgnorePatterns(): Array { + // eslint-disable-next-line n/no-sync const content = readFileSync(join(this.cwd, 'package.json'), 'utf-8') const { linterIgnorePatterns = [] } = JSON.parse(content) - return linterIgnorePatterns + return linterIgnorePatterns as Array } } diff --git a/code/code-pack/src/index.ts b/code/code-pack/src/index.ts index 4374c48c5..fc9e7e3c7 100644 --- a/code/code-pack/src/index.ts +++ b/code/code-pack/src/index.ts @@ -1,6 +1,6 @@ import * as tagUtils from './tag.utils.js' -export * from './pack.interfaces.js' +export type * from './pack.interfaces.js' export * from './tag.utils.js' export * from './pack.js' diff --git a/code/code-pack/src/pack.interfaces.ts b/code/code-pack/src/pack.interfaces.ts index ebbccfb60..469199c81 100644 --- a/code/code-pack/src/pack.interfaces.ts +++ b/code/code-pack/src/pack.interfaces.ts @@ -1,4 +1,4 @@ -import { PortablePath } from '@yarnpkg/fslib' +import type { PortablePath } from '@yarnpkg/fslib' export interface PackOptions { workspace: string diff --git a/code/code-pack/src/pack.ts b/code/code-pack/src/pack.ts index c242dd315..963759a11 100644 --- a/code/code-pack/src/pack.ts +++ b/code/code-pack/src/pack.ts @@ -70,6 +70,7 @@ export const pack = async ( await xfs.writeFilePromise(descriptorPath, stringify(descriptor)) + // eslint-disable-next-line no-console, n/no-sync console.debug('project.toml', readFileSync(descriptorPath, 'utf8')) const args = [ @@ -96,6 +97,7 @@ export const pack = async ( args.push('--platform', platform) } + // eslint-disable-next-line no-console console.debug(`Packing with args:`, args) await installPack({ cwd, context }) diff --git a/code/code-pack/src/pack.utils.ts b/code/code-pack/src/pack.utils.ts index ae3599dad..c4a31d0f7 100644 --- a/code/code-pack/src/pack.utils.ts +++ b/code/code-pack/src/pack.utils.ts @@ -1,10 +1,12 @@ -import { platform } from 'node:os' -import { arch } from 'node:os' +import type { PortablePath } from '@yarnpkg/fslib' -import { PortablePath } from '@yarnpkg/fslib' -import { execUtils } from '@yarnpkg/core' +import { platform } from 'node:os' +import { arch } from 'node:os' + +import { execUtils } from '@yarnpkg/core' interface InstallPackOptions { + // eslint-disable-next-line @typescript-eslint/no-explicit-any context: any cwd?: PortablePath } @@ -33,6 +35,7 @@ export const installPack: InstallPack = async ({ context, cwd }) => { } if (!isPackInstalled) { + // eslint-disable-next-line no-console console.log('Buildpack CLI (pack) is not installed. Installing it...') let downloadUrl = 'https://github.com/buildpacks/pack/releases/download/v0.36.2/pack-v0.36.2-' @@ -51,9 +54,8 @@ export const installPack: InstallPack = async ({ context, cwd }) => { downloadUrl += 'macos.tgz' } break - } - - if (currentPlatform === 'linux') { + default: + break } const tempFile = `${cwd ?? context.cwd}/pack.tgz` @@ -76,6 +78,7 @@ export const installPack: InstallPack = async ({ context, cwd }) => { end: execUtils.EndStrategy.ErrorCode, }) + // eslint-disable-next-line no-console console.log('Buildpack CLI (pack) has been installed.') } } diff --git a/code/code-pack/src/tag.utils.ts b/code/code-pack/src/tag.utils.ts index be8ae820d..cc2799dd6 100644 --- a/code/code-pack/src/tag.utils.ts +++ b/code/code-pack/src/tag.utils.ts @@ -12,7 +12,8 @@ export const getPullRequestSha = (): string => { process.env.GITHUB_PULL_REQUST_HEAD_SHA || (event.after as string) || (event.pull_request?.head?.sha as string) || - process.env.GITHUB_SHA! + // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style + (process.env.GITHUB_SHA as string) ) } @@ -53,6 +54,7 @@ export const getContext = async (): Promise => { export const getTag = async (tagPolicy: TagPolicy): Promise => { const revision = await getRevision() + // eslint-disable-next-line @typescript-eslint/no-deprecated const hash = revision.substr(0, 7) if (tagPolicy === 'hash-timestamp') { diff --git a/code/code-schematics/package.json b/code/code-schematics/package.json index f876bf385..5d718e62e 100644 --- a/code/code-schematics/package.json +++ b/code/code-schematics/package.json @@ -20,6 +20,7 @@ "@angular-devkit/schematics": "18.2.2" }, "devDependencies": { + "@types/node": "22.9.0", "rxjs": "7.8.1" }, "publishConfig": { @@ -32,5 +33,6 @@ } }, "typings": "dist/index.d.ts" - } + }, + "typecheckSkipLibCheck": true } diff --git a/code/code-schematics/src/node-pnp-engine.host.ts b/code/code-schematics/src/node-pnp-engine.host.ts index b8920ecce..0a8031798 100644 --- a/code/code-schematics/src/node-pnp-engine.host.ts +++ b/code/code-schematics/src/node-pnp-engine.host.ts @@ -2,6 +2,8 @@ import type { RuleFactory } from '@angular-devkit/schemat import type { FileSystemSchematicDesc } from '@angular-devkit/schematics/tools' import type { FileSystemCollectionDesc } from '@angular-devkit/schematics/tools' +import type { ResolveReferenceStringReturn } from './node-pnp-engine.interfaces.js' + import { dirname } from 'node:path' import { join } from 'node:path' import { resolve } from 'node:path' @@ -12,7 +14,7 @@ import { CollectionMissingSchematicsMapException } from '@angular-devkit/schemat import { FileSystemEngineHostBase } from '@angular-devkit/schematics/tools' import { SchematicMissingFieldsException } from '@angular-devkit/schematics/tools' import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools' -// @ts-expect-error any +// @ts-expect-error cannot find module type declaration import { readJsonFile } from '@angular-devkit/schematics/tools/file-system-utility' // TODO: refactor @@ -21,6 +23,56 @@ export class NodePnpEngineHost extends FileSystemEngineHostBase { super() } + // eslint-disable-next-line no-underscore-dangle + protected _resolveCollectionPath(name: string, requester?: string): string { + const collectionPath = this.resolve(name, requester) + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + readJsonFile(collectionPath) + + return collectionPath + } + + // eslint-disable-next-line no-underscore-dangle + protected _resolveReferenceString( + refString: string, + parentPath: string + ): ResolveReferenceStringReturn { + const ref = new ExportStringRef>(refString, parentPath) + if (!ref.ref) { + return null + } + + return { ref: ref.ref, path: ref.module } + } + + // eslint-disable-next-line no-underscore-dangle + protected _transformCollectionDescription( + name: string, + desc: Partial + ): FileSystemCollectionDesc { + if (!desc.schematics || typeof desc.schematics !== 'object') { + throw new CollectionMissingSchematicsMapException(name) + } + + return { + ...desc, + name, + } as FileSystemCollectionDesc + } + + // eslint-disable-next-line no-underscore-dangle + protected _transformSchematicDescription( + name: string, + _collection: FileSystemCollectionDesc, + desc: Partial + ): FileSystemSchematicDesc { + if (!desc.factoryFn || !desc.path || !desc.description) { + throw new SchematicMissingFieldsException(name) + } + + return desc as FileSystemSchematicDesc + } + private resolve(name: string, requester?: string, references = new Set()): string { if (requester) { if (references.has(requester)) { @@ -51,6 +103,7 @@ export class NodePnpEngineHost extends FileSystemEngineHostBase { try { const packageJsonPath = require.resolve(join(name, 'package.json'), resolveOptions) + // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, security/detect-non-literal-require const { schematics } = require(packageJsonPath) if (!schematics || typeof schematics !== 'string') { @@ -58,8 +111,9 @@ export class NodePnpEngineHost extends FileSystemEngineHostBase { } collectionPath = this.resolve(schematics, packageJsonPath, references) - } catch (e: any) { - if (e.code !== 'MODULE_NOT_FOUND') { + } catch (e: unknown) { + const error = e as Error & { code: string } + if (error.code !== 'MODULE_NOT_FOUND') { throw e } } @@ -67,8 +121,9 @@ export class NodePnpEngineHost extends FileSystemEngineHostBase { if (!collectionPath) { try { collectionPath = require.resolve(name, resolveOptions) - } catch (e: any) { - if (e.code !== 'MODULE_NOT_FOUND') { + } catch (e: unknown) { + const error = e as Error & { code: string } + if (error.code !== 'MODULE_NOT_FOUND') { throw e } } @@ -80,50 +135,4 @@ export class NodePnpEngineHost extends FileSystemEngineHostBase { return collectionPath } - - // eslint-disable-next-line no-underscore-dangle - protected _resolveCollectionPath(name: string, requester?: string): string { - const collectionPath = this.resolve(name, requester) - readJsonFile(collectionPath) - - return collectionPath - } - - // eslint-disable-next-line no-underscore-dangle - protected _resolveReferenceString(refString: string, parentPath: string) { - const ref = new ExportStringRef>(refString, parentPath) - if (!ref.ref) { - return null - } - - return { ref: ref.ref, path: ref.module } - } - - // eslint-disable-next-line no-underscore-dangle - protected _transformCollectionDescription( - name: string, - desc: Partial - ): FileSystemCollectionDesc { - if (!desc.schematics || typeof desc.schematics !== 'object') { - throw new CollectionMissingSchematicsMapException(name) - } - - return { - ...desc, - name, - } as FileSystemCollectionDesc - } - - // eslint-disable-next-line no-underscore-dangle - protected _transformSchematicDescription( - name: string, - _collection: FileSystemCollectionDesc, - desc: Partial - ): FileSystemSchematicDesc { - if (!desc.factoryFn || !desc.path || !desc.description) { - throw new SchematicMissingFieldsException(name) - } - - return desc as FileSystemSchematicDesc - } } diff --git a/code/code-schematics/src/node-pnp-engine.interfaces.ts b/code/code-schematics/src/node-pnp-engine.interfaces.ts new file mode 100644 index 000000000..ba1e99e1b --- /dev/null +++ b/code/code-schematics/src/node-pnp-engine.interfaces.ts @@ -0,0 +1,6 @@ +import type { RuleFactory } from '@angular-devkit/schematics/' + +export type ResolveReferenceStringReturn = { + ref: RuleFactory + path: string +} | null diff --git a/code/code-schematics/src/schematics.ts b/code/code-schematics/src/schematics.ts index efcdae952..44ce9f71b 100644 --- a/code/code-schematics/src/schematics.ts +++ b/code/code-schematics/src/schematics.ts @@ -1,3 +1,5 @@ +/* eslint-disable */ + import type { Path } from '@angular-devkit/core' import type { DryRunEvent } from '@angular-devkit/schematics' @@ -90,7 +92,6 @@ export class Schematics { 'migrations.json' ) - // eslint-disable-next-line security/detect-non-literal-require const data = require(migrationsPath) return Object.keys(data.schematics) @@ -104,7 +105,6 @@ export class Schematics { .flat() for (const migration of migrations) { - // eslint-disable-next-line no-await-in-loop await lastValueFrom( workflow.execute({ collection: migration.collection, diff --git a/code/code-schematics/src/utils/resolve.utils.ts b/code/code-schematics/src/utils/resolve.utils.ts index 1199066a1..0e40d1564 100644 --- a/code/code-schematics/src/utils/resolve.utils.ts +++ b/code/code-schematics/src/utils/resolve.utils.ts @@ -1,34 +1,30 @@ +/* eslint-disable */ + import { dirname } from 'node:path' import { join } from 'node:path' -const dynamicRequire = eval('require') // eslint-disable-line no-eval +const dynamicRequire = eval('require') const findPnpApiPath = (cwd?: string) => { if (process.versions.pnp) { - // eslint-disable-next-line return require('module').findPnpApi(__filename).resolveRequest('pnpapi', null) } return join(cwd || process.cwd(), '.pnp.cjs') } -// eslint-disable-next-line const setupPnp = (cwd?: string) => { const pnpPath = findPnpApiPath(cwd) - // eslint-disable-next-line dynamicRequire(pnpPath).setup() } -// eslint-disable-next-line export const resolveSchematics = (cwd?: string) => { try { - // eslint-disable-next-line return join(dirname(dynamicRequire.resolve('@atls/schematics')), '..') - } catch (error) { + } catch { setupPnp(cwd) - // eslint-disable-next-line return join(dirname(dynamicRequire.resolve('@atls/schematics')), '..') } } diff --git a/code/code-service/src/index.ts b/code/code-service/src/index.ts index 0a6e1d208..2431e93fd 100644 --- a/code/code-service/src/index.ts +++ b/code/code-service/src/index.ts @@ -1,4 +1,4 @@ -export * from './service.interfaces.js' -export * from './webpack.interfaces.js' +export type * from './service.interfaces.js' +export type * from './webpack.interfaces.js' export * from './webpack.config.js' export * from './service.js' diff --git a/code/code-service/src/webpack.config.ts b/code/code-service/src/webpack.config.ts index 563aad096..7cc249d2a 100644 --- a/code/code-service/src/webpack.config.ts +++ b/code/code-service/src/webpack.config.ts @@ -118,13 +118,16 @@ export class WebpackConfig { const content = await readFile(join(this.cwd, 'package.json'), 'utf-8') const { type = 'commonjs' } = JSON.parse(content) - return type + return type as string } catch { return 'module' } } - private createPlugins(environment: string, additionalPlugins: Array) { + private createPlugins( + environment: string, + additionalPlugins: Array + ): Array { const plugins: Array = [ new this.webpack.IgnorePlugin({ checkResource: (resource: string): boolean => { @@ -140,7 +143,7 @@ export class WebpackConfig { require.resolve(resource, { paths: [this.cwd], }) - } catch (err) { + } catch { return true } diff --git a/code/code-service/src/webpack.externals.ts b/code/code-service/src/webpack.externals.ts index d7a22a06a..1893f43dc 100644 --- a/code/code-service/src/webpack.externals.ts +++ b/code/code-service/src/webpack.externals.ts @@ -43,8 +43,8 @@ export class WebpackExternals { private externals = ( { request }: webpack.ExternalItemFunctionData, callback: ( - error?: Error | undefined, - result?: string | undefined, + error?: Error, + result?: string, type?: webpack.Configuration['externalsType'] ) => void ): void => { diff --git a/code/code-service/src/webpack.interfaces.ts b/code/code-service/src/webpack.interfaces.ts index 86f48cbae..208dade95 100644 --- a/code/code-service/src/webpack.interfaces.ts +++ b/code/code-service/src/webpack.interfaces.ts @@ -10,13 +10,15 @@ export type WebpackEnvironment = 'development' | 'production' export interface WebpackConfigPlugin { name: string + // eslint-disable-next-line @typescript-eslint/no-explicit-any use: any + // eslint-disable-next-line @typescript-eslint/no-explicit-any args: Array } -const ModuleType = { - commonjs: 'commonjs', - module: 'module', -} as const +type ModuleType = { + commonjs: 'commonjs' + module: 'module' +} -export type ModuleTypes = (typeof ModuleType)[keyof typeof ModuleType] +export type ModuleTypes = ModuleType[keyof ModuleType] diff --git a/code/code-test/src/tester.ts b/code/code-test/src/tester.ts index e6758ff6d..0345bbc43 100644 --- a/code/code-test/src/tester.ts +++ b/code/code-test/src/tester.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/member-ordering */ + import type { TestEvent } from 'node:test/reporters' import EventEmitter from 'node:events' @@ -17,84 +19,11 @@ type TestOptions = { } export class Tester extends EventEmitter { + // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor() { super() } - static async initialize(): Promise { - return new Tester() - } - - private async collectTestFiles( - cwd: string, - type: 'integration' | 'unit' | undefined, - patterns: Array | undefined - ) { - let folderPattern = '*' - if (type !== undefined) { - folderPattern = type === 'unit' ? '!(integration)' : 'integration' - } - - if (!patterns || patterns.length < 1) { - return globby([`**/${folderPattern}/*.test.{ts,tsx,js,jsx}`], { - cwd, - dot: true, - absolute: true, - ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'], - }) - } - - return globby( - patterns.map((pattern) => { - if (this.isFilename(pattern)) { - return `**/${folderPattern}/*${pattern}*.test.{ts,tsx,js,jsx}` - } - - if (this.isRootPath(pattern)) { - return pattern - } - - return `**/${pattern}` - }), - { - cwd, - dot: true, - absolute: true, - ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'], - } - ) - } - - private isFilename(pattern: string): boolean { - const hasPathSeparator = pattern.includes('/') || pattern.includes('\\') - - const hasValidExtension = /\.(js|jsx|ts|tsx)$/.test(pattern) - - return !hasPathSeparator && !hasValidExtension - } - - private isRootPath(pattern: string): boolean { - return pattern.startsWith('/') || pattern.startsWith('\\') - } - - async unit(cwd: string, options?: TestOptions): Promise> { - const testFiles = await this.collectTestFiles(cwd, 'unit', options?.files) - - return this.run(testFiles, 25_000, true, options?.watch, options?.testReporter) - } - - async integration(cwd: string, options?: TestOptions): Promise> { - const testFiles = await this.collectTestFiles(cwd, 'integration', options?.files) - - return this.run(testFiles, 240_000, false, options?.watch, options?.testReporter) - } - - async general(cwd: string, options?: TestOptions): Promise> { - const testFiles = await this.collectTestFiles(cwd, undefined, options?.files) - - return this.run(testFiles, 240_000, true, options?.watch, options?.testReporter) - } - protected async run( files: Array, timeout: number, @@ -113,6 +42,7 @@ export class Tester extends EventEmitter { result.pipe(process.stdout) // @ts-expect-error toArray is missing + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return return result.toArray() } @@ -159,4 +89,78 @@ export class Tester extends EventEmitter { testsStream.off('test:stderr', onStderr) } } + + static async initialize(): Promise { + return new Tester() + } + + async unit(cwd: string, options?: TestOptions): Promise> { + const testFiles = await this.collectTestFiles(cwd, 'unit', options?.files) + + return this.run(testFiles, 25_000, true, options?.watch, options?.testReporter) + } + + async integration(cwd: string, options?: TestOptions): Promise> { + const testFiles = await this.collectTestFiles(cwd, 'integration', options?.files) + + return this.run(testFiles, 240_000, false, options?.watch, options?.testReporter) + } + + async general(cwd: string, options?: TestOptions): Promise> { + const testFiles = await this.collectTestFiles(cwd, undefined, options?.files) + + return this.run(testFiles, 240_000, true, options?.watch, options?.testReporter) + } + + private async collectTestFiles( + cwd: string, + type: 'integration' | 'unit' | undefined, + patterns: Array | undefined + ): Promise> { + let folderPattern = '*' + if (type !== undefined) { + folderPattern = type === 'unit' ? '!(integration)' : 'integration' + } + + if (!patterns || patterns.length < 1) { + return globby([`**/${folderPattern}/*.test.{ts,tsx,js,jsx}`], { + cwd, + dot: true, + absolute: true, + ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'], + }) + } + + return globby( + patterns.map((pattern) => { + if (this.isFilename(pattern)) { + return `**/${folderPattern}/*${pattern}*.test.{ts,tsx,js,jsx}` + } + + if (this.isRootPath(pattern)) { + return pattern + } + + return `**/${pattern}` + }), + { + cwd, + dot: true, + absolute: true, + ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'], + } + ) + } + + private isFilename(pattern: string): boolean { + const hasPathSeparator = pattern.includes('/') || pattern.includes('\\') + + const hasValidExtension = /\.(js|jsx|ts|tsx)$/.test(pattern) + + return !hasPathSeparator && !hasValidExtension + } + + private isRootPath(pattern: string): boolean { + return pattern.startsWith('/') || pattern.startsWith('\\') + } } diff --git a/code/code-typescript/src/transformers/transform-jsx-to-js-extension.transformer.ts b/code/code-typescript/src/transformers/transform-jsx-to-js-extension.transformer.ts index 72941bfa7..a3d94045a 100644 --- a/code/code-typescript/src/transformers/transform-jsx-to-js-extension.transformer.ts +++ b/code/code-typescript/src/transformers/transform-jsx-to-js-extension.transformer.ts @@ -1,3 +1,5 @@ +/* eslint-disable */ + import type { ts as typescript } from '@atls/code-runtime/typescript' export const transformJsxToJsExtension = (ts: typeof typescript) => diff --git a/code/code-typescript/src/typescript.ts b/code/code-typescript/src/typescript.ts index 32d52f76d..6ae102632 100644 --- a/code/code-typescript/src/typescript.ts +++ b/code/code-typescript/src/typescript.ts @@ -1,3 +1,5 @@ +/* eslint-disable n/no-sync, @typescript-eslint/no-shadow */ + import type { ts as typescript } from '@atls/code-runtime/typescript' import EventEmitter from 'node:events' @@ -148,7 +150,7 @@ export class TypeScript extends EventEmitter { const { typecheckIgnorePatterns = [] } = JSON.parse(content) - return typecheckIgnorePatterns + return typecheckIgnorePatterns as Array } private getLibCheckOption(): boolean { @@ -156,6 +158,6 @@ export class TypeScript extends EventEmitter { const { typecheckSkipLibCheck = false } = JSON.parse(content) - return typecheckSkipLibCheck + return typecheckSkipLibCheck as boolean } } diff --git a/prettier/plugin/src/getters/index.ts b/prettier/plugin/src/getters/index.ts new file mode 100644 index 000000000..f936171c9 --- /dev/null +++ b/prettier/plugin/src/getters/index.ts @@ -0,0 +1 @@ +export * from './prettier-plugin.getter.js' diff --git a/prettier/plugin/src/getters/prettier-plugin.getter.ts b/prettier/plugin/src/getters/prettier-plugin.getter.ts new file mode 100644 index 000000000..88583416f --- /dev/null +++ b/prettier/plugin/src/getters/prettier-plugin.getter.ts @@ -0,0 +1,15 @@ +import type { GetPrettierPluginReturn } from '../interfaces/index.js' + +import { parsers } from '../parsers.js' +import { getPrinters } from './printers.getter.js' + +export const getPrettierPlugin = async (): GetPrettierPluginReturn => { + const printers = await getPrinters() + + const plugin = { + printers, + parsers, + } + + return plugin +} diff --git a/prettier/plugin/src/getters/printers.getter.ts b/prettier/plugin/src/getters/printers.getter.ts new file mode 100644 index 000000000..6caf4412f --- /dev/null +++ b/prettier/plugin/src/getters/printers.getter.ts @@ -0,0 +1,94 @@ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ + +import type { Node } from '@babel/types' +import type { ImportDeclaration } from '@babel/types' +import type { Printer } from 'prettier' +import type { AST } from 'prettier' + +import type { GetPrintersReturn } from '../interfaces/index.js' + +import { extractPrinter } from '../patch.js' + +const nodeImportSize = (node: ImportDeclaration): number => { + if (node.specifiers.length === 0) { + return 0 + } + + const specifier = node.specifiers[node.specifiers.length - 1] + + // @ts-expect-error does not exist + const offset = specifier.imported ? 8 : 6 + + // @ts-expect-error possibly null + return specifier.loc.end.column + offset +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const print: Printer['print'] = (path, options, prnt): any => { + const node = path.getNode() + + const plugin = options.plugins.find((p) => typeof p !== 'string' && p.printers?.estree) + + // @ts-expect-error possibly undefined + let result = plugin.printers.estree.print(path, options, prnt) + + if (node?.type === 'ImportDeclaration') { + // @ts-expect-error explicit any type + result = result.map((part) => { + // @ts-expect-error type does not exist + if (Array.isArray(part) && part[0] === ' from' && node.alignOffset > 0) { + // @ts-expect-error type does not exist + const fill = Array.apply(0, Array(node.alignOffset)).fill(' ').join('') + + part[0] = `${fill} from` // eslint-disable-line no-param-reassign + } + + return part + }) + } + + return result +} + +export const preprocess = async (ast: AST): Promise => { + const imports = ast.body.filter( + (node: Node) => + node.type === 'ImportDeclaration' && node.loc && node.loc.end.line === node.loc.start.line + ) + + const importsLengths: Array = imports.map((node: ImportDeclaration): number => + nodeImportSize(node)) + const maxAlignLength = imports.length > 0 ? Math.max(...importsLengths) : 0 + + ast.body.forEach((node: Node & { alignOffset: number }) => { + if ( + node.type === 'ImportDeclaration' && + node.loc && + node.loc.end.line === node.loc.start.line + ) { + node.alignOffset = 0 // eslint-disable-line + + const nodeLength = nodeImportSize(node) + + // eslint-disable-next-line + node.alignOffset = nodeLength < maxAlignLength ? maxAlignLength - nodeLength : 0 + } + }) + + return ast +} + +export const getPrinters = async (): GetPrintersReturn => { + const printer = await extractPrinter() + + const printers = { + 'typescript-custom': { + ...printer, + preprocess, + print, + }, + } + + return printers +} diff --git a/prettier/plugin/src/import-sort/import-sort-typescript.parser.ts b/prettier/plugin/src/import-sort/import-sort-typescript.parser.ts index a6e40e628..5d6866da8 100644 --- a/prettier/plugin/src/import-sort/import-sort-typescript.parser.ts +++ b/prettier/plugin/src/import-sort/import-sort-typescript.parser.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-call */ - import type { Node } from '@babel/types' import type { Comment } from '@babel/types' import type { ImportDeclaration } from '@babel/types' @@ -12,14 +10,19 @@ export class ImportSortTypeScriptParser implements IParser { constructor(private readonly program: AST) {} parseImports(code: string): Array { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call const imports: Array = this.program.body .filter((node: Node) => node.type === 'ImportDeclaration') .map((node: ImportDeclaration) => { const imp: IImport = { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion start: node.range![0], + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion end: node.range![1], + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion importStart: node.range![0], + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion importEnd: node.range![1], type: node.importKind === 'type' ? 'import-type' : 'import', @@ -37,16 +40,19 @@ export class ImportSortTypeScriptParser implements IParser { namedMembers: node.specifiers .filter((specifier) => specifier.type === 'ImportSpecifier') .map((specifier) => ({ - // @ts-expect-error + // @ts-expect-error property does not exist name: specifier.imported.name, alias: specifier.local.name, type: node.importKind === 'type', })), } + // eslint-disable-next-line @typescript-eslint/no-unsafe-call const lineComment = this.program.comments.find( (comment: Comment) => + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion comment.loc!.start.line === node.loc!.start.line && + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion comment.loc!.end.line === node.loc!.end.line ) @@ -56,7 +62,9 @@ export class ImportSortTypeScriptParser implements IParser { } const findLeadingComments = (position: number): typeof this.program.comments => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call const leadingComment = this.program.comments.find( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion (comment: Comment) => comment.loc!.start.line === position ) @@ -69,9 +77,11 @@ export class ImportSortTypeScriptParser implements IParser { return [...parents, leadingComment] } + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion const leadingComments: Array = findLeadingComments(node.loc!.start.line - 1) if (leadingComments.length > 0) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call imp.start = leadingComments.at(0).range.at(0) } @@ -99,7 +109,7 @@ export class ImportSortTypeScriptParser implements IParser { let prefix: string | undefined if (useMultipleLines) { - ;[prefix] = namedMembersString.split(eol)[1].match(/^\s*/)! + ;[prefix] = namedMembersString.split(eol)[1].match(/^\s*/) } const useSpaces = namedMembersString.charAt(1) === ' ' diff --git a/prettier/plugin/src/import-sort/import-sort.api.ts b/prettier/plugin/src/import-sort/import-sort.api.ts index abeb10ddd..1560354b3 100644 --- a/prettier/plugin/src/import-sort/import-sort.api.ts +++ b/prettier/plugin/src/import-sort/import-sort.api.ts @@ -10,10 +10,12 @@ const loadWorkspaces = (): Array => { try { const { workspaces }: { workspaces: Array } = JSON.parse( + // eslint-disable-next-line n/no-sync readFileSync(join(process.cwd(), '/package.json'), 'utf-8') ) if (workspaces?.length > 0) { + // eslint-disable-next-line n/no-sync const folders = globbySync(workspaces, { cwd: process.cwd(), onlyDirectories: true, @@ -27,6 +29,7 @@ const loadWorkspaces = (): Array => { folders.forEach((folder) => { try { const { name }: { name: string } = JSON.parse( + // eslint-disable-next-line n/no-sync readFileSync(join(folder, 'package.json'), 'utf-8') ) diff --git a/prettier/plugin/src/import-sort/import-sort.preprocess.ts b/prettier/plugin/src/import-sort/import-sort.preprocess.ts index 48f96aab0..09f5328b2 100644 --- a/prettier/plugin/src/import-sort/import-sort.preprocess.ts +++ b/prettier/plugin/src/import-sort/import-sort.preprocess.ts @@ -8,7 +8,8 @@ import { sortImports } from 'import-sort' import { ImportSortTypeScriptParser } from './import-sort-typescript.parser.js' import { style } from './import-sort.style.js' -const findTypeScriptParser = (plugins: Array>): Parser => { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const findTypeScriptParser = (plugins: Array>): Parser | null => { const plugin = plugins.find((p) => { if (typeof p === 'string') { return false @@ -21,14 +22,15 @@ const findTypeScriptParser = (plugins: Array>): Parser => { return p.parsers.typescript }) - return plugin!.parsers!.typescript + return plugin?.parsers?.typescript || null } -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types export const preprocess = (source: string, { plugins }: any): string => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const typescript = findTypeScriptParser(plugins as Array>) - // @ts-expect-error + // @ts-expect-error expected 2 arguments, but got 1 const parser = new ImportSortTypeScriptParser(typescript.parse(source)) const { code } = sortImports(source, parser, style) diff --git a/prettier/plugin/src/index.ts b/prettier/plugin/src/index.ts index 68e7622da..111e5ffde 100644 --- a/prettier/plugin/src/index.ts +++ b/prettier/plugin/src/index.ts @@ -7,3 +7,4 @@ const plugin = { } export default plugin +export * from './getters/index.js' diff --git a/prettier/plugin/src/interfaces/index.ts b/prettier/plugin/src/interfaces/index.ts new file mode 100644 index 000000000..ff834a8a9 --- /dev/null +++ b/prettier/plugin/src/interfaces/index.ts @@ -0,0 +1 @@ +export type * from './prettier-plugin.interfaces.js' diff --git a/prettier/plugin/src/interfaces/prettier-plugin.interfaces.ts b/prettier/plugin/src/interfaces/prettier-plugin.interfaces.ts new file mode 100644 index 000000000..27d2099da --- /dev/null +++ b/prettier/plugin/src/interfaces/prettier-plugin.interfaces.ts @@ -0,0 +1,13 @@ +import type { Printer } from 'prettier' +import type { Parser } from 'prettier' + +export type PrintersType = Record +export type ParsersType = Record + +export type GetPrettierPluginReturn = Promise<{ + printers: PrintersType + parsers: ParsersType +}> + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type GetPrintersReturn = Promise> diff --git a/prettier/plugin/src/parsers.ts b/prettier/plugin/src/parsers.ts index 956254eb5..6e9d7f5bb 100644 --- a/prettier/plugin/src/parsers.ts +++ b/prettier/plugin/src/parsers.ts @@ -8,13 +8,13 @@ import sortPackageJson from 'sort-package-json' import { preprocess as importSortPreprocess } from './import-sort/index.js' -// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments -const preprocess: Parser['preprocess'] = (source, options): string => +const preprocess: Parser['preprocess'] = (source, options): string => importSortPreprocess(source, options) const parse: Parser['parse'] = async (source, { plugins }) => { - const plugin: any = plugins.find((p: any) => p.parsers?.typescript) + const plugin = plugins.find((p) => typeof p !== 'string' && p.parsers?.typescript) + // @ts-expect-error possibly undefined const program = plugin.parsers.typescript.parse(source) const bodyLength = program.body.length diff --git a/prettier/plugin/src/patch.ts b/prettier/plugin/src/patch.ts index a3d6fb090..79776e5bd 100644 --- a/prettier/plugin/src/patch.ts +++ b/prettier/plugin/src/patch.ts @@ -5,12 +5,13 @@ import * as estree from 'prettier/plugins/estree' import * as typescript from 'prettier/plugins/typescript' import { format } from 'prettier/standalone' +// eslint-disable-next-line @typescript-eslint/no-explicit-any export const extractPrinter = async (): Promise => { let printer await format('const n = 5;', { plugins: [ - // @ts-expect-error any + // @ts-expect-error is not assignable estree, babel, { @@ -20,6 +21,7 @@ export const extractPrinter = async (): Promise => { typescript: { ...typescript.parsers.typescript, parse(text, options) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const plugin: any = options.plugins.find((x: any) => x.printers?.estree) printer = plugin.printers.estree diff --git a/prettier/plugin/src/printers.ts b/prettier/plugin/src/printers.ts index cfef3bbee..729318043 100644 --- a/prettier/plugin/src/printers.ts +++ b/prettier/plugin/src/printers.ts @@ -8,7 +8,7 @@ import type { AST } from 'prettier' import { extractPrinter } from './patch.js' -const printer = await extractPrinter() +const printer = extractPrinter() const nodeImportSize = (node: ImportDeclaration): number => { if (node.specifiers.length === 0) { @@ -17,25 +17,28 @@ const nodeImportSize = (node: ImportDeclaration): number => { const specifier = node.specifiers[node.specifiers.length - 1] - // @ts-expect-error + // @ts-expect-error does not exist const offset = specifier.imported ? 8 : 6 - return specifier.loc!.end.column + offset + // @ts-expect-error possibly null + return specifier.loc.end.column + offset } +// eslint-disable-next-line @typescript-eslint/no-explicit-any export const print: Printer['print'] = (path, options, prnt): any => { const node = path.getNode() - const plugin: any = options.plugins.find((p: any) => p?.printers?.estree) + const plugin = options.plugins.find((p) => typeof p !== 'string' && p.printers?.estree) + // @ts-expect-error possibly undefined let result = plugin.printers.estree.print(path, options, prnt) if (node?.type === 'ImportDeclaration') { - // @ts-expect-error + // @ts-expect-error explicit any type result = result.map((part) => { - // @ts-expect-error + // @ts-expect-error type does not exist if (Array.isArray(part) && part[0] === ' from' && node.alignOffset > 0) { - // @ts-expect-error + // @ts-expect-error type does not exist const fill = Array.apply(0, Array(node.alignOffset)).fill(' ').join('') part[0] = `${fill} from` // eslint-disable-line no-param-reassign @@ -78,6 +81,7 @@ export const preprocess = async (ast: AST): Promise => { export const printers: Record = { 'typescript-custom': { + // eslint-disable-next-line @typescript-eslint/no-misused-promises ...printer, preprocess, print, diff --git a/schematics/schematics-utils/package.json b/schematics/schematics-utils/package.json index b16c1fc37..b995487fb 100644 --- a/schematics/schematics-utils/package.json +++ b/schematics/schematics-utils/package.json @@ -38,5 +38,6 @@ } }, "typings": "dist/index.d.ts" - } + }, + "typecheckSkipLibCheck": true } diff --git a/schematics/schematics-utils/src/file.utils.ts b/schematics/schematics-utils/src/file.utils.ts index fa66ed476..f1e8c4a7e 100644 --- a/schematics/schematics-utils/src/file.utils.ts +++ b/schematics/schematics-utils/src/file.utils.ts @@ -8,6 +8,7 @@ export const updateFileInTree = ( ): Rule => (host: Tree, context: SchematicContext): Tree => { if (host.exists(path)) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion host.overwrite(path, callback(host.read(path)!.toString('utf-8'), context)) } diff --git a/schematics/schematics-utils/src/gitignore.utils.ts b/schematics/schematics-utils/src/gitignore.utils.ts index 467ee3392..8130ecceb 100644 --- a/schematics/schematics-utils/src/gitignore.utils.ts +++ b/schematics/schematics-utils/src/gitignore.utils.ts @@ -12,7 +12,11 @@ export const updateGitIgnoreInTree = ( host.create(GITIGNORE_PATH, '') } - const content: Array = host.read(GITIGNORE_PATH)!.toString('utf-8').split('\n') + const gitignoreBuffer = host.read(GITIGNORE_PATH) + + if (!gitignoreBuffer) return host + + const content: Array = gitignoreBuffer.toString('utf-8').split('\n') host.overwrite(GITIGNORE_PATH, Array.from(callback(content, context)).join('\n')) diff --git a/schematics/schematics-utils/src/json.utils.ts b/schematics/schematics-utils/src/json.utils.ts index 2e8f5a0e5..04cf5eb99 100644 --- a/schematics/schematics-utils/src/json.utils.ts +++ b/schematics/schematics-utils/src/json.utils.ts @@ -1,23 +1,23 @@ +/* eslint-disable */ import type { Rule } from '@angular-devkit/schematics' import type { SchematicContext } from '@angular-devkit/schematics' import type { Tree } from '@angular-devkit/schematics' import stripJsonComments from 'strip-json-comments' -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -export const serializeJson = (json: any): string => `${JSON.stringify(json, null, 2)}\n` +export const serializeJson = (json: string): string => `${JSON.stringify(json, null, 2)}\n` -export const readJsonInTree = (host: Tree, path: string): T => { +export const readJsonInTree = (host: Tree, path: string): void => { if (!host.exists(path)) { throw new Error(`Cannot find ${path}`) } - const contents = stripJsonComments(host.read(path)!.toString('utf-8')) + const contents = stripJsonComments(host.read(path)?.toString('utf-8') || '') try { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return return JSON.parse(contents) - } catch (error: any) { + } catch (e: unknown) { + const error = e as Error throw new Error(`Cannot parse ${path}: ${error.message}`) } } @@ -28,12 +28,17 @@ export const updateJsonInTree = ( ): Rule => (host: Tree, context: SchematicContext): Tree => { if (!host.exists(path)) { - host.create(path, serializeJson(callback({} as T, context))) + // TODO types + host.create(path, serializeJson(callback({} as T, context) as string)) return host } - host.overwrite(path, serializeJson(callback(readJsonInTree(host, path), context))) + // TODO types + host.overwrite( + path, + serializeJson(callback(readJsonInTree(host, path) as T, context) as string) + ) return host } diff --git a/schematics/schematics-utils/src/tsconfig.utils.ts b/schematics/schematics-utils/src/tsconfig.utils.ts index 59be9287b..19d2da322 100644 --- a/schematics/schematics-utils/src/tsconfig.utils.ts +++ b/schematics/schematics-utils/src/tsconfig.utils.ts @@ -1,8 +1,8 @@ +/* eslint-disable */ + import { updateJsonInTree } from './json.utils.js' -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export const updateTsConfigInTree = (compilerOptions: object) => - // eslint-disable-next-line @typescript-eslint/no-unsafe-return updateJsonInTree('tsconfig.json', (tsconfig) => ({ ...tsconfig, compilerOptions, diff --git a/schematics/schematics-utils/src/yaml.utils.ts b/schematics/schematics-utils/src/yaml.utils.ts index 00674a338..7ee44656f 100644 --- a/schematics/schematics-utils/src/yaml.utils.ts +++ b/schematics/schematics-utils/src/yaml.utils.ts @@ -1,3 +1,5 @@ +/* eslint-disable */ + import type { Rule } from '@angular-devkit/schematics' import type { SchematicContext } from '@angular-devkit/schematics' import type { Tree } from '@angular-devkit/schematics' @@ -24,7 +26,10 @@ export const updateYamlInTree = ( host.overwrite( path, - dump(callback(readYamlInTree(host, path), context), { noArrayIndent: true, lineWidth: -1 }) + dump(callback(readYamlInTree(host, path), context), { + noArrayIndent: true, + lineWidth: -1, + }) ) return host diff --git a/schematics/schematics/package.json b/schematics/schematics/package.json index d07cd8db3..0e5b2f492 100644 --- a/schematics/schematics/package.json +++ b/schematics/schematics/package.json @@ -38,5 +38,6 @@ }, "typings": "dist/index.d.ts" }, - "schematics": "./src/collection.json" + "schematics": "./dist/collection.json", + "typecheckSkipLibCheck": true } diff --git a/schematics/schematics/scripts/postpack.mjs b/schematics/schematics/scripts/postpack.mjs index 693b7d003..10a54b37b 100644 --- a/schematics/schematics/scripts/postpack.mjs +++ b/schematics/schematics/scripts/postpack.mjs @@ -1,3 +1,5 @@ +/* eslint-disable n/no-sync */ + import { join } from 'node:path' import { writeFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' diff --git a/schematics/schematics/scripts/prepack.mjs b/schematics/schematics/scripts/prepack.mjs index 4648b2378..7d5443ca6 100644 --- a/schematics/schematics/scripts/prepack.mjs +++ b/schematics/schematics/scripts/prepack.mjs @@ -1,3 +1,5 @@ +/* eslint-disable n/no-sync */ + import copydir from 'copy-dir' import { globbySync } from 'globby' import { join } from 'path' @@ -5,7 +7,7 @@ import { copyFileSync } from 'node:fs' import { writeFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' -import pkg from '../package.json' assert { type: 'json' } +import pkg from '../package.json' with { type: 'json' } const dirname = fileURLToPath(new URL('.', import.meta.url)) diff --git a/schematics/schematics/src/project/project.factory.ts b/schematics/schematics/src/project/project.factory.ts index 8aae18b7b..f6bf01d7e 100644 --- a/schematics/schematics/src/project/project.factory.ts +++ b/schematics/schematics/src/project/project.factory.ts @@ -1,3 +1,5 @@ +/* eslint-disable */ + import type { Source } from '@angular-devkit/schematics' import { readFileSync } from 'node:fs' @@ -31,10 +33,8 @@ const generateCommon = (options: any): Source => ]) const generateProjectSpecifiec = (options: any): Source => { - // eslint-disable-next-line const { name: projectName } = JSON.parse(readFileSync(join(options.cwd, 'package.json'), 'utf-8')) - // eslint-disable-next-line return apply(url(join('./files', options.type)), [ template({ ...strings, @@ -46,7 +46,6 @@ const generateProjectSpecifiec = (options: any): Source => { ]) } -// eslint-disable-next-line export const main = (options: any) => chain([ mergeWith(generateCommon(options), MergeStrategy.Overwrite), diff --git a/webpack/webpack-proto-imports-loader/src/proto-imports.loader.ts b/webpack/webpack-proto-imports-loader/src/proto-imports.loader.ts index 37296464c..2abdd6f89 100644 --- a/webpack/webpack-proto-imports-loader/src/proto-imports.loader.ts +++ b/webpack/webpack-proto-imports-loader/src/proto-imports.loader.ts @@ -3,13 +3,13 @@ import path from 'node:path' import { parse } from 'protocol-buffers-schema' import fileLoader from 'file-loader' -export const getProtoFileName = (resourcePath: string) => { +export const getProtoFileName = (resourcePath: string): string => { const hash = Buffer.from(path.dirname(resourcePath)).toString('hex') return `./${hash.slice(hash.length - 20)}-${path.basename(resourcePath)}` } -export const resolvePackageImportPath = (packageName: string, importPath: string) => { +export const resolvePackageImportPath = (packageName: string, importPath: string): string => { const packagePath = packageName.replace(/\./g, '/') if (importPath.startsWith(packagePath)) { @@ -19,26 +19,30 @@ export const resolvePackageImportPath = (packageName: string, importPath: string return importPath } -export default function protoImportsLoader(source: string | Buffer): string { +export default function protoImportsLoader(source: Buffer | string): string { const { imports, package: packageName } = parse(source) const dependencies: Array = [] imports.forEach((importPath) => { - if (!path.isAbsolute(importPath)) { - // @ts-expect-error null + if (!path.isAbsolute(importPath) && typeof packageName === 'string') { const resolvedImportPath = resolvePackageImportPath(packageName, importPath) // @ts-expect-error this is undefined + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const importAbsolutePath = path.join(path.dirname(this.resourcePath), resolvedImportPath) const targetPath = getProtoFileName(importAbsolutePath) + if (Buffer.isBuffer(source)) { + // eslint-disable-next-line no-param-reassign + source = source.toString() + } // eslint-disable-next-line no-param-reassign - // @ts-expect-error source can be buffer source = source.replace(importPath, targetPath) dependencies.push(`require('${importAbsolutePath}')`) // @ts-expect-error this is undefined + // eslint-disable-next-line @typescript-eslint/no-unsafe-call this.addDependency(importAbsolutePath) } }) @@ -49,8 +53,9 @@ export default function protoImportsLoader(source: string | Buffer): string { ...this, query: { postTransformPublicPath: (p: string) => `__non_webpack_require__.resolve(${p})`, + // TODO (as string) // @ts-expect-error this is undefined - name: getProtoFileName(this.resourcePath), + name: getProtoFileName(this.resourcePath as string), }, }, source diff --git a/webpack/webpack-start-server-plugin/src/start-server.plugin.ts b/webpack/webpack-start-server-plugin/src/start-server.plugin.ts index b048e050d..32e572c2b 100644 --- a/webpack/webpack-start-server-plugin/src/start-server.plugin.ts +++ b/webpack/webpack-start-server-plugin/src/start-server.plugin.ts @@ -48,14 +48,17 @@ export class StartServerPlugin { private startServer = (compilation: webpack.Compilation, callback: () => void): void => { this.logger.info('Starting server...') + const { path } = compilation.compiler.options.output - this.entryFile = join(compilation.compiler.options.output.path!, 'index.js') + if (path) { + this.entryFile = join(path, 'index.js') - this.runWorker(this.entryFile, (worker) => { - this.worker = worker + this.runWorker(this.entryFile, (worker) => { + this.worker = worker - callback() - }) + callback() + }) + } } private runWorker(entryFile: string, callback: (arg0: ChildProcess) => void): void { diff --git a/yarn.lock b/yarn.lock index 8ad6519d8..ceb2ad4da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -665,6 +665,9 @@ __metadata: dependencies: "@octokit/auth-action": "npm:5.1.1" "@octokit/rest": "npm:21.0.2" + "@octokit/types": "npm:13.5.0" + peerDependencies: + "@octokit/types": "*" languageName: unknown linkType: soft @@ -751,6 +754,7 @@ __metadata: dependencies: "@angular-devkit/core": "npm:18.2.2" "@angular-devkit/schematics": "npm:18.2.2" + "@types/node": "npm:22.9.0" rxjs: "npm:7.8.1" languageName: unknown linkType: soft diff --git a/yarn/cli/patches/version-postfix-toggle.mjs b/yarn/cli/patches/version-postfix-toggle.mjs index 29e2cc1bf..48b07d41f 100644 --- a/yarn/cli/patches/version-postfix-toggle.mjs +++ b/yarn/cli/patches/version-postfix-toggle.mjs @@ -8,9 +8,11 @@ const POSTFIX = '-atls' * @param {Record} packageJson * @param {string} postfix */ +// eslint-disable-next-line @typescript-eslint/no-shadow export const addPostfix = (packageJson, postfix = POSTFIX) => { if (!packageJson.version.endsWith(postfix)) { const initialVersion = packageJson.version + // eslint-disable-next-line no-param-reassign packageJson.version = `${initialVersion}${postfix}` } @@ -21,9 +23,11 @@ export const addPostfix = (packageJson, postfix = POSTFIX) => { * @param {Record} packageJson * @param {string} postfix */ +// eslint-disable-next-line @typescript-eslint/no-shadow export const removePostfix = (packageJson, postfix = POSTFIX) => { if (packageJson.version.endsWith(postfix)) { const splitted = packageJson.version.split(postfix) + // eslint-disable-next-line prefer-destructuring, no-param-reassign packageJson.version = splitted[0] } @@ -35,6 +39,7 @@ export const removePostfix = (packageJson, postfix = POSTFIX) => { * @param {Record} data */ export const updatePackageJsonFile = (path, data) => { + // eslint-disable-next-line n/no-sync writeFileSync(path, JSON.stringify(data, undefined, 2)) } diff --git a/yarn/plugin-badges/sources/badges.command.ts b/yarn/plugin-badges/sources/badges.command.ts index ec865cc21..8c5601f8f 100644 --- a/yarn/plugin-badges/sources/badges.command.ts +++ b/yarn/plugin-badges/sources/badges.command.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { LocatorHash } from '@yarnpkg/core' import type { Package } from '@yarnpkg/core' import type { Workspace } from '@yarnpkg/core' @@ -31,7 +32,7 @@ class BadgesCommand extends BaseCommand { static REGISTRY_PACKAGE_PATH = '/package' - async execute() { + async execute(): Promise<0 | 1> { const configuration = await Configuration.find(this.context.cwd, this.context.plugins) const { project, workspace: projectWorkspace } = await Project.find( configuration, @@ -53,42 +54,44 @@ class BadgesCommand extends BaseCommand { progress.start() - const traverseWorkspace = (workspace: Workspace) => { + const traverseWorkspace = (workspace: Workspace): IterableIterator => { const initialHash = workspace.anchoredLocator.locatorHash const seen = new Map() const pass = [initialHash] while (pass.length > 0) { - const hash = pass.shift()! - // eslint-disable-next-line no-continue - if (seen.has(hash)) continue + const hash = pass.shift() + if (hash) { + // eslint-disable-next-line no-continue + if (seen.has(hash)) continue - const pkg = project.storedPackages.get(hash) - if (typeof pkg === `undefined`) - throw new Error(`Assertion failed: Expected the package to be registered`) + const pkg = project.storedPackages.get(hash) + if (typeof pkg === `undefined`) + throw new Error(`Assertion failed: Expected the package to be registered`) - seen.set(hash, pkg) + seen.set(hash, pkg) - if (structUtils.isVirtualLocator(pkg)) - pass.push(structUtils.devirtualizeLocator(pkg).locatorHash) + if (structUtils.isVirtualLocator(pkg)) + pass.push(structUtils.devirtualizeLocator(pkg).locatorHash) - // eslint-disable-next-line no-continue - if (hash !== initialHash) continue + // eslint-disable-next-line no-continue, security/detect-possible-timing-attacks + if (hash !== initialHash) continue - for (const dependency of pkg.dependencies.values()) { - const resolution = project.storedResolutions.get(dependency.descriptorHash) - if (typeof resolution === `undefined`) - throw new Error(`Assertion failed: Expected the resolution to be registered`) + for (const dependency of pkg.dependencies.values()) { + const resolution = project.storedResolutions.get(dependency.descriptorHash) + if (typeof resolution === `undefined`) + throw new Error(`Assertion failed: Expected the resolution to be registered`) - pass.push(resolution) + pass.push(resolution) + } } } return seen.values() } - const traverseAllWorkspaces = () => { + const traverseAllWorkspaces = (): IterableIterator => { const aggregate = new Map() for (const workspace of project.workspaces) @@ -101,7 +104,7 @@ class BadgesCommand extends BaseCommand { const sortedLookup = miscUtils.sortMap([...lookupSet], (pkg) => structUtils.stringifyLocator(pkg)) - const getVersion = async (name: any) => { + const getVersion = async (name: string): Promise => { const expectedDescriptor = structUtils.parseDescriptor(name) const selection = sortedLookup.filter( @@ -110,13 +113,14 @@ class BadgesCommand extends BaseCommand { ) if (selection.length > 0) { - return selection.shift()!.version + return selection.shift()?.version || '' } return '' } const readmePath = join(process.cwd(), 'README.md') + // eslint-disable-next-line n/no-sync const readme = readFileSync(readmePath).toString('utf-8') const parts = readme.split(BadgesCommand.VERSIONS_SEPARATOR) @@ -128,14 +132,17 @@ class BadgesCommand extends BaseCommand { })) ) - const versionsReducer = (badges: any, pkg: any) => { - const getColors = () => { - const extractColors = (colors: any) => ({ + const versionsReducer = (badges: any, pkg: any): any => { + const getColors = (): any => { + const extractColors = (colors: any): any => ({ + // eslint-disable-next-line @typescript-eslint/no-unsafe-call labelColor: colors.labelColor.replace('#', ''), + // eslint-disable-next-line @typescript-eslint/no-unsafe-call color: colors.color.replace('#', ''), }) const pair = Object.entries(COLORS).find( + // eslint-disable-next-line @typescript-eslint/no-unsafe-call ([pattern]) => pkg.name.search(pattern) !== -1 ) @@ -150,20 +157,29 @@ class BadgesCommand extends BaseCommand { if (pkg.version) { const packageLink = `${BadgesCommand.REGISTRY_URL}${BadgesCommand.REGISTRY_PACKAGE_PATH}/${pkg.name}` - join(BadgesCommand.REGISTRY_URL, BadgesCommand.REGISTRY_PACKAGE_PATH, pkg.name) + join( + BadgesCommand.REGISTRY_URL, + BadgesCommand.REGISTRY_PACKAGE_PATH, + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + pkg.name + ) - const newQueryStringParams = new URLSearchParams({ - style: BadgesCommand.BADGE_STYLE, - label: pkg.name, - message: pkg.version, - ...getColors(), - }) + const newQueryStringParams = new URLSearchParams( + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + { + style: BadgesCommand.BADGE_STYLE, + label: pkg.name, + message: pkg.version, + ...getColors(), + } + ) const badge = `badge` - const wrapWithLink = (content: string, link: string) => `[${content}](${link})` + const wrapWithLink = (content: string, link: string): string => + `[${content}](${link})` return `${badges}${wrapWithLink(badge, packageLink)} ` } @@ -174,6 +190,7 @@ class BadgesCommand extends BaseCommand { parts[1] = atlsVersions.reduce(versionsReducer, '') parts[1] = `\n\n${parts[1]}\n\n` + // eslint-disable-next-line n/no-sync writeFileSync(readmePath, parts.join('[//]: # (VERSIONS)')) progress.end() diff --git a/yarn/plugin-changelog/sources/changelog-generate.command.ts b/yarn/plugin-changelog/sources/changelog-generate.command.ts index ef5ef6299..99931b6da 100644 --- a/yarn/plugin-changelog/sources/changelog-generate.command.ts +++ b/yarn/plugin-changelog/sources/changelog-generate.command.ts @@ -53,6 +53,7 @@ export class ChangelogGenerateCommand extends BaseCommand { }) if (this.stdOut) { + // eslint-disable-next-line no-console console.log(result) } }) diff --git a/yarn/plugin-check/sources/check.command.ts b/yarn/plugin-check/sources/check.command.ts index c44f1827f..7a5f9507c 100644 --- a/yarn/plugin-check/sources/check.command.ts +++ b/yarn/plugin-check/sources/check.command.ts @@ -3,7 +3,7 @@ import { BaseCommand } from '@yarnpkg/cli' export class CheckCommand extends BaseCommand { static paths = [['check']] - async execute() { + async execute(): Promise { await this.cli.run(['format']) await this.cli.run(['typecheck']) await this.cli.run(['lint']) diff --git a/yarn/plugin-checks/sources/checks-release.command.ts b/yarn/plugin-checks/sources/checks-release.command.ts index 0610dc2f4..a0e23633a 100644 --- a/yarn/plugin-checks/sources/checks-release.command.ts +++ b/yarn/plugin-checks/sources/checks-release.command.ts @@ -66,7 +66,8 @@ class ChecksReleaseCommand extends BaseCommand { if (workspace.manifest.scripts.get('build')) { const context = new PassThroughRunContext() - const outputWriter = (data: Buffer) => this.context.stdout.write(data) + const outputWriter = (data: Buffer): ReturnType => + this.context.stdout.write(data) context.stdout.on('data', outputWriter) context.stderr.on('data', outputWriter) @@ -79,7 +80,9 @@ class ChecksReleaseCommand extends BaseCommand { if (code > 0) { annotations.push({ annotation_level: AnnotationLevel.Failure, - title: `Error release workspace ${workspace.manifest.raw.name ?? workspace.relativeCwd}`, + title: `Error release workspace ${ + workspace.manifest.raw.name ?? workspace.relativeCwd + }`, message: `Exit code ${code}`, raw_details: stripAnsi(context.output), path: ppath.join(workspace.relativeCwd, 'package.json'), diff --git a/yarn/plugin-checks/sources/github.checks.ts b/yarn/plugin-checks/sources/github.checks.ts index 597fdead9..9f1c93b68 100644 --- a/yarn/plugin-checks/sources/github.checks.ts +++ b/yarn/plugin-checks/sources/github.checks.ts @@ -31,7 +31,12 @@ export class GitHubChecks { } async create( - params: RequestParameters & { owner: string; repo: string; name: string; head_sha: string } + params: RequestParameters & { + owner: string + repo: string + name: string + head_sha: string + } ): Promise> { const response = await this.octokit.rest.checks.create(params) @@ -46,7 +51,11 @@ export class GitHubChecks { return this.create({ ...context.repo, name: this.name, - head_sha: payload.after || payload.pull_request?.head.sha || (process.env.GITHUB_SHA as any), + head_sha: + payload.after || + payload.pull_request?.head.sha || + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + process.env.GITHUB_SHA!, started_at: new Date().toISOString(), status: 'in_progress', }) @@ -62,7 +71,11 @@ export class GitHubChecks { ...context.repo, check_run_id: id, name: this.name, - head_sha: payload.after || payload.pull_request?.head.sha || (process.env.GITHUB_SHA as any), + head_sha: + payload.after || + payload.pull_request?.head.sha || + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + process.env.GITHUB_SHA!, completed_at: new Date().toISOString(), status: 'completed', conclusion: output.annotations.length > 0 ? 'failure' : 'success', @@ -86,7 +99,11 @@ export class GitHubChecks { return this.create({ ...context.repo, name: this.name, - head_sha: payload.after || payload.pull_request?.head.sha || (process.env.GITHUB_SHA as any), + head_sha: + payload.after || + payload.pull_request?.head.sha || + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + process.env.GITHUB_SHA!, completed_at: new Date().toISOString(), status: 'completed', conclusion: 'failure', diff --git a/yarn/plugin-commit/sources/commit-message-lint.command.ts b/yarn/plugin-commit/sources/commit-message-lint.command.ts index 4a1730b55..c1f660bb1 100644 --- a/yarn/plugin-commit/sources/commit-message-lint.command.ts +++ b/yarn/plugin-commit/sources/commit-message-lint.command.ts @@ -23,7 +23,7 @@ class CommitMessageLintCommand extends BaseCommand { }) const messages = await read({ edit: true }) - const results = await Promise.all(messages.map((message) => linter.lint(message))) + const results = await Promise.all(messages.map(async (message) => linter.lint(message))) const output = linter.format({ results }) diff --git a/yarn/plugin-essentials/sources/commands/set-version.command.ts b/yarn/plugin-essentials/sources/commands/set-version.command.ts index d9ff5bb76..fc3b33178 100644 --- a/yarn/plugin-essentials/sources/commands/set-version.command.ts +++ b/yarn/plugin-essentials/sources/commands/set-version.command.ts @@ -23,7 +23,7 @@ export class SetVersionCommand extends BaseCommand { const configuration = await Configuration.find(this.context.cwd, this.context.plugins) await configuration.triggerHook( - // eslint-disable-next-line @typescript-eslint/no-unsafe-return + // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any (hooks) => (hooks as any).afterYarnVersionSet, configuration, this.context diff --git a/yarn/plugin-files/sources/changed-files.util.ts b/yarn/plugin-files/sources/changed-files.util.ts index 0ab5d4e9e..a3285d094 100644 --- a/yarn/plugin-files/sources/changed-files.util.ts +++ b/yarn/plugin-files/sources/changed-files.util.ts @@ -12,6 +12,7 @@ export const getEventCommmits = async (): Promise< GetCommitResponseData | GetCommitsResponseData > => { if (context.eventName === 'push') { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return context.payload.commits } @@ -41,9 +42,13 @@ export const getCommitData = async (ref: string): Promise export const getChangedCommmits = async (): Promise> => { const eventCommits = await getEventCommmits() + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return Promise.all( - // @ts-expect-error types - eventCommits.map(async (commit: any) => getCommitData(commit.id || commit.sha)) + // @ts-expect-error property does not exist + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + eventCommits.map(async (commit) => + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + getCommitData(commit.id || commit.sha)) ) } diff --git a/yarn/plugin-image/sources/image-pack.command.ts b/yarn/plugin-image/sources/image-pack.command.ts index b321c615c..d20473f37 100644 --- a/yarn/plugin-image/sources/image-pack.command.ts +++ b/yarn/plugin-image/sources/image-pack.command.ts @@ -62,6 +62,7 @@ class ImagePackCommand extends BaseCommand { } to ${destination}` ) + // eslint-disable-next-line n/no-sync const content = readFileSync(join(this.context.cwd, 'package.json'), 'utf-8') const { packConfiguration = {} } = JSON.parse(content) const buildpackVersion = packConfiguration.buildpackVersion ?? '0.1.1' diff --git a/yarn/plugin-library/sources/before-workspace-packing.hook.ts b/yarn/plugin-library/sources/before-workspace-packing.hook.ts index f57027649..9554f1bda 100644 --- a/yarn/plugin-library/sources/before-workspace-packing.hook.ts +++ b/yarn/plugin-library/sources/before-workspace-packing.hook.ts @@ -1,9 +1,11 @@ import type { Workspace } from '@yarnpkg/core' export interface RawManifest { + // eslint-disable-next-line @typescript-eslint/no-explicit-any exports: Record publishConfig: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any exports: Record } } diff --git a/yarn/plugin-pnp-patch/src/esm-loader/hooks/loader.utils.ts b/yarn/plugin-pnp-patch/src/esm-loader/hooks/loader.utils.ts index ccccdf854..b0ac48b9d 100644 --- a/yarn/plugin-pnp-patch/src/esm-loader/hooks/loader.utils.ts +++ b/yarn/plugin-pnp-patch/src/esm-loader/hooks/loader.utils.ts @@ -36,7 +36,6 @@ export const getFileFormat = (filepath: string): string | null => { } export const transformSource = (source: string, format: string, ext: 'ts' | 'tsx'): string => { - // eslint-disable-next-line n/no-sync const { transformSync } = require('esbuild') // eslint-disable-next-line @typescript-eslint/no-unsafe-call, n/no-sync diff --git a/yarn/plugin-release/sources/release-create.command.ts b/yarn/plugin-release/sources/release-create.command.ts index fb2c58340..ea2d69c2a 100644 --- a/yarn/plugin-release/sources/release-create.command.ts +++ b/yarn/plugin-release/sources/release-create.command.ts @@ -42,14 +42,18 @@ export class ReleaseCreateCommand extends BaseCommand { const workspaceName = workspace.manifest.name?.name assert.ok(workspaceName, 'Missing workspace name') - const version = workspace.manifest.version + const { version } = workspace.manifest assert.ok(version, 'Missing version') packageName += `${workspaceName}` const changelog = new Changelog() - const body = await changelog.generate({ packageName, version, path: this.context.cwd }) + const body = await changelog.generate({ + packageName, + version, + path: this.context.cwd, + }) const release = new Release({ token }) @@ -57,6 +61,7 @@ export class ReleaseCreateCommand extends BaseCommand { let repo = '' try { ;({ repository: repo, organization: owner } = parseGitHubUrl( + // eslint-disable-next-line n/no-sync execSync('git remote get-url origin', { encoding: 'utf-8' }) )) } catch { diff --git a/yarn/plugin-release/sources/utils/parse-git-url.ts b/yarn/plugin-release/sources/utils/parse-git-url.ts index 5ff42e1bb..8da9f5514 100644 --- a/yarn/plugin-release/sources/utils/parse-git-url.ts +++ b/yarn/plugin-release/sources/utils/parse-git-url.ts @@ -1,8 +1,12 @@ import assert from 'node:assert/strict' -type ParseGitHubUrl = (repositoryUrl: string) => { organization: string; repository: string } +type ParseGitHubUrl = (repositoryUrl: string) => { + organization: string + repository: string +} export const parseGitHubUrl: ParseGitHubUrl = (repositoryUrl) => { + // eslint-disable-next-line no-console console.debug('Repository URL:', repositoryUrl) const match = repositoryUrl.match(/github\.com[/:](.+?)\/(.+?)(?:\.git|$)/) diff --git a/yarn/plugin-renderer/sources/commands/renderer-build.command.ts b/yarn/plugin-renderer/sources/commands/renderer-build.command.ts index cb0987299..36ef53f04 100644 --- a/yarn/plugin-renderer/sources/commands/renderer-build.command.ts +++ b/yarn/plugin-renderer/sources/commands/renderer-build.command.ts @@ -70,7 +70,9 @@ export class RendererBuildCommand extends BaseCommand { await report.startTimerPromise('Copy standalone files', async () => { if (await xfs.existsPromise(ppath.join(this.context.cwd, 'dist'))) { - await xfs.rmdirPromise(ppath.join(this.context.cwd, 'dist'), { recursive: true }) + await xfs.rmdirPromise(ppath.join(this.context.cwd, 'dist'), { + recursive: true, + }) } await xfs.copyPromise( @@ -78,7 +80,7 @@ export class RendererBuildCommand extends BaseCommand { ppath.join( this.context.cwd, 'src/.next/standalone', - this.context.cwd.replace(`${configuration.projectCwd!}/`, '') as PortablePath, + this.context.cwd.replace(`${configuration.projectCwd || ''}/`, '') as PortablePath, 'src' ) ) diff --git a/yarn/plugin-schematics/sources/generate-project.command.tsx b/yarn/plugin-schematics/sources/generate-project.command.tsx index dda34d3cf..98068607d 100644 --- a/yarn/plugin-schematics/sources/generate-project.command.tsx +++ b/yarn/plugin-schematics/sources/generate-project.command.tsx @@ -1,3 +1,5 @@ +/* eslint-disable */ + import type { ProjectInformationProperties } from '@atls/cli-ui-schematics-component' import { BaseCommand } from '@yarnpkg/cli' @@ -72,7 +74,9 @@ class GenerateProjectCommand extends BaseCommand { return 1 } - const schematics = new SchematicsWorker(project.cwd) + // TODO component + const schematics = 'bla' as any + // const schematics = new SchematicsWorker(project.cwd) const commandReport = await StreamReport.start( { @@ -90,7 +94,7 @@ class GenerateProjectCommand extends BaseCommand { progress.end() - events.forEach((event) => { + events.forEach((event: any) => { const eventPath = event.path.startsWith('/') ? event.path.slice(1) : event.path if (event.kind === 'error') { @@ -119,7 +123,7 @@ class GenerateProjectCommand extends BaseCommand { } catch (error) { progress.end() - renderStatic(, process.stdout.columns - 12) + renderStatic() .split('\n') .forEach((line) => { report.reportError(MessageName.UNNAMED, line) diff --git a/yarn/plugin-schematics/sources/migration-up.command.tsx b/yarn/plugin-schematics/sources/migration-up.command.tsx index 29530fe5b..8c4b1be76 100644 --- a/yarn/plugin-schematics/sources/migration-up.command.tsx +++ b/yarn/plugin-schematics/sources/migration-up.command.tsx @@ -1,3 +1,5 @@ +/* eslint-disable */ + import { BaseCommand } from '@yarnpkg/cli' import { Configuration } from '@yarnpkg/core' import { Project } from '@yarnpkg/core' @@ -18,7 +20,8 @@ class MigrationUpCommand extends BaseCommand { const configuration = await Configuration.find(this.context.cwd, this.context.plugins) const { project, workspace } = await Project.find(configuration, this.context.cwd) - const schematics = new SchematicsWorker(project.cwd) + const schematics = 'bla' as any + // const schematics = new SchematicsWorker(project.cwd) const commandReport = await StreamReport.start( { @@ -39,7 +42,7 @@ class MigrationUpCommand extends BaseCommand { progress.end() - events.forEach((event) => { + events.forEach((event: any) => { const eventPath = event.path.startsWith('/') ? event.path.slice(1) : event.path if (event.kind === 'error') { @@ -54,11 +57,11 @@ class MigrationUpCommand extends BaseCommand { npath.join(npath.fromPortablePath(workspace!.cwd), 'package.json') ), { - ...workspace!.manifest.raw, + ...workspace?.manifest.raw, tools: { - ...workspace!.manifest.raw.tools, + ...workspace?.manifest.raw.tools, schematic: { - ...workspace!.manifest.raw.tools.schematic, + ...workspace?.manifest.raw.tools.schematic, migration: String(Date.now()), }, }, @@ -67,8 +70,12 @@ class MigrationUpCommand extends BaseCommand { } catch (error) { progress.end() - // @ts-expect-error any - renderStatic(, process.stdout.columns - 12) + // renderStatic(, process.stdout.columns - 12) + renderStatic( + <>PLUGIN SCHEMATICS ERROR INFO, + // @ts-expect-error expected 1 argument, but got 2 + process.stdout.columns - 12 + ) .split('\n') .forEach((line) => { report.reportError(MessageName.UNNAMED, line) diff --git a/yarn/plugin-test/sources/abstract-test.command.tsx b/yarn/plugin-test/sources/abstract-test.command.tsx index cfa2d5b51..30de1b207 100644 --- a/yarn/plugin-test/sources/abstract-test.command.tsx +++ b/yarn/plugin-test/sources/abstract-test.command.tsx @@ -29,14 +29,6 @@ import { Tester } from '@atls/code-test' import { renderStatic } from '@atls/cli-ui-renderer-static-component' export abstract class AbstractTestCommand extends BaseCommand { - target = Option.String('-t,--target') - - watch: boolean = Option.Boolean('-w,--watch', false) - - files: Array = Option.Rest({ required: 0 }) - - testReporter = Option.String('--test-reporter', { validator: isEnum(['tap']) }) - static override usage = Command.Usage({ description: 'Run tests', details: ` @@ -57,6 +49,16 @@ export abstract class AbstractTestCommand extends BaseCommand { ], }) + target = Option.String('-t,--target') + + watch: boolean = Option.Boolean('-w,--watch', false) + + files: Array = Option.Rest({ required: 0 }) + + testReporter = Option.String('--test-reporter', { + validator: isEnum(['tap']), + }) + private std = new Map>() private bufferedStdTimeout: NodeJS.Timeout | undefined @@ -67,7 +69,7 @@ export abstract class AbstractTestCommand extends BaseCommand { const args: Array = [] - if (this.files && this.files.length) { + if (this.files?.length) { args.push(this.files.join(' ')) } @@ -94,7 +96,9 @@ export abstract class AbstractTestCommand extends BaseCommand { if (!env.NODE_OPTIONS?.includes('@atls/code-runtime/ts-node-register')) { env.NODE_OPTIONS = `${env.NODE_OPTIONS} --loader @atls/code-runtime/ts-node-register` - env.NODE_OPTIONS = `${env.NODE_OPTIONS} --loader ${pathToFileURL(npath.fromPortablePath(ppath.join(project.cwd, Filename.pnpEsmLoader))).href}` + env.NODE_OPTIONS = `${env.NODE_OPTIONS} --loader ${ + pathToFileURL(npath.fromPortablePath(ppath.join(project.cwd, Filename.pnpEsmLoader))).href + }` env.NODE_OPTIONS = `${env.NODE_OPTIONS} --loader @atls/code-runtime/ts-ext-register` } @@ -162,7 +166,10 @@ export abstract class AbstractTestCommand extends BaseCommand { files: this.files, watch: this.watch, }) - : await tester.unit(this.target ?? project.cwd, { files: this.files, watch: this.watch }) + : await tester.unit(this.target ?? project.cwd, { + files: this.files, + watch: this.watch, + }) return results.find((result) => result.type === 'test:fail') ? 1 : 0 } catch (error) { diff --git a/yarn/plugin-test/sources/test.command.ts b/yarn/plugin-test/sources/test.command.ts index ad4c9c74f..49ff165d8 100644 --- a/yarn/plugin-test/sources/test.command.ts +++ b/yarn/plugin-test/sources/test.command.ts @@ -34,7 +34,7 @@ export class TestCommand extends AbstractTestCommand { return results.some((result) => { if (result.includes('# fail ')) { - const failedNumber = parseInt(result.split('# fail ')[1]) + const failedNumber = parseInt(result.split('# fail ')[1], 2) return failedNumber > 0 } diff --git a/yarn/plugin-tools/sources/commands/sync/tools-sync-tsconfig.command.ts b/yarn/plugin-tools/sources/commands/sync/tools-sync-tsconfig.command.ts index b68281c2d..ba1fe376b 100644 --- a/yarn/plugin-tools/sources/commands/sync/tools-sync-tsconfig.command.ts +++ b/yarn/plugin-tools/sources/commands/sync/tools-sync-tsconfig.command.ts @@ -15,14 +15,17 @@ import tsconfig from '@atls/config-typescript' import { AbstractToolsCommand } from './abstract-tools.command.js' const combineMerge = ( + /* eslint-disable @typescript-eslint/no-explicit-any */ target: Array, + /* eslint-disable @typescript-eslint/no-explicit-any */ source: Array, options?: deepmerge.ArrayMergeOptions + /* eslint-disable @typescript-eslint/no-explicit-any */ ): Array => { const destination = target.slice() /* eslint-disable @typescript-eslint/no-unsafe-argument */ - source.forEach((item: any, index: number) => { + source.forEach((item, index: number) => { if (typeof destination[index] === 'undefined') { destination[index] = options?.cloneUnlessOtherwiseSpecified(item, options) } else if (options?.isMergeableObject(item)) { @@ -86,11 +89,10 @@ export class ToolsSyncTSConfigCommand extends AbstractToolsCommand { '/// \n' ) - const config = deepmerge( - exists, - { compilerOptions: tsconfig.compilerOptions }, - { arrayMerge: combineMerge } - ) + const config = deepmerge< + typeof exists & { include: any }, + { compilerOptions: typeof tsconfig.compilerOptions } + >(exists, { compilerOptions: tsconfig.compilerOptions }, { arrayMerge: combineMerge }) const includes: Array = ( (project.topLevelWorkspace.manifest.raw.workspaces as Array) || [] @@ -98,9 +100,7 @@ export class ToolsSyncTSConfigCommand extends AbstractToolsCommand { const created = { ...config, - include: Array.from( - new Set(['project.types.d.ts', ...((config as any).include || []), ...includes]) - ), + include: Array.from(new Set(['project.types.d.ts', ...config.include, ...includes])), } try { diff --git a/yarn/plugin-tools/sources/commands/sync/tools-sync-typescript.command.ts b/yarn/plugin-tools/sources/commands/sync/tools-sync-typescript.command.ts index a2ffaaa49..ebc75ce60 100644 --- a/yarn/plugin-tools/sources/commands/sync/tools-sync-typescript.command.ts +++ b/yarn/plugin-tools/sources/commands/sync/tools-sync-typescript.command.ts @@ -24,8 +24,11 @@ export class ToolsSyncTypeScriptCommand extends AbstractToolsCommand { const configuration = await Configuration.find(this.context.cwd, this.context.plugins) const { project } = await Project.find(configuration, this.context.cwd) - const runtime = (await import('@atls/code-runtime/package.json', { with: { type: 'json' } })) - .default + const runtime = ( + await import('@atls/code-runtime/package.json', { + with: { type: 'json' }, + }) + ).default const commandReport = await StreamReport.start( { @@ -51,8 +54,8 @@ export class ToolsSyncTypeScriptCommand extends AbstractToolsCommand { ) { if ( !semver.eq( - semver.coerce(descriptor.range)!, - semver.coerce(runtime.dependencies.typescript)! + semver.coerce(descriptor.range) || '', + semver.coerce(runtime.dependencies.typescript) || '' ) ) { descriptor.range = runtime.dependencies.typescript diff --git a/yarn/plugin-tools/sources/hooks/after-all-installed.hook.ts b/yarn/plugin-tools/sources/hooks/after-all-installed.hook.ts index 28287f235..741c6cb63 100644 --- a/yarn/plugin-tools/sources/hooks/after-all-installed.hook.ts +++ b/yarn/plugin-tools/sources/hooks/after-all-installed.hook.ts @@ -9,56 +9,44 @@ import { xfs } from '@yarnpkg/fslib' const hook = (command: string): string => `${command}` const git = (args: Array): SpawnSyncReturns => + // eslint-disable-next-line n/no-sync spawnSync('git', args, { encoding: 'utf-8' }) -const hooksExists = (): boolean => { - const { error, output } = git(['config', 'core.hooksPath']) - - if (error) { - return false - } - - return Boolean(output.at(1)) -} - export const afterAllInstalled = async (project: Project): Promise => { if (process.env.GITHUB_ACTIONS) { + // eslint-disable-next-line no-console console.log('AFTER INSTALL HOOK: Execution in GitHub Action') return } if (process.env.IMAGE_PACK) return - try { - const target = ppath.join(project.cwd, '.config/husky') - const legacyTarget = ppath.join(target, '_') + const target = ppath.join(project.cwd, '.config/husky') + const legacyTarget = ppath.join(target, '_') - if (await xfs.existsPromise(legacyTarget)) { - await xfs.removePromise(target) - } + if (await xfs.existsPromise(legacyTarget)) { + await xfs.removePromise(target) + } - if (!(await xfs.existsPromise(target))) { - await xfs.mkdirPromise(target, { recursive: true }) - } + if (!(await xfs.existsPromise(target))) { + await xfs.mkdirPromise(target, { recursive: true }) + } - await xfs.writeFilePromise(ppath.join(target, 'commit-msg'), hook('yarn commit message lint'), { - mode: 0o755, - }) + await xfs.writeFilePromise(ppath.join(target, 'commit-msg'), hook('yarn commit message lint'), { + mode: 0o755, + }) - await xfs.writeFilePromise(ppath.join(target, 'pre-commit'), hook('yarn commit staged'), { - mode: 0o755, - }) + await xfs.writeFilePromise(ppath.join(target, 'pre-commit'), hook('yarn commit staged'), { + mode: 0o755, + }) - await xfs.writeFilePromise( - ppath.join(target, 'prepare-commit-msg'), - hook('yarn commit message $@'), - { mode: 0o755 } - ) + await xfs.writeFilePromise( + ppath.join(target, 'prepare-commit-msg'), + hook('yarn commit message $@'), + { mode: 0o755 } + ) - const { error } = git(['config', 'core.hooksPath', target]) + const { error } = git(['config', 'core.hooksPath', target]) - if (error) throw error - } catch (error) { - throw error - } + if (error) throw error } diff --git a/yarn/plugin-workspaces/sources/workspaces-changed-list.command.ts b/yarn/plugin-workspaces/sources/workspaces-changed-list.command.ts index d6ac41777..9e1de4d00 100644 --- a/yarn/plugin-workspaces/sources/workspaces-changed-list.command.ts +++ b/yarn/plugin-workspaces/sources/workspaces-changed-list.command.ts @@ -30,13 +30,13 @@ class WorkspacesChangedListCommand extends BaseCommand { stdout: this.context.stdout, }, - async (report) => { + async (streamReport) => { const files = await getChangedFiles(project) const workspaces = getChangedWorkspaces(project, files) for (const ws of workspaces) { - report.reportInfo(null, ws.relativeCwd) - report.reportJson({ + streamReport.reportInfo(null, ws.relativeCwd) + streamReport.reportJson({ name: ws.manifest.name ? structUtils.stringifyIdent(ws.manifest.name) : null, location: ws.relativeCwd, })