From 8991940b60162fe3a2536c55ea38b416aecf1c79 Mon Sep 17 00:00:00 2001 From: "Jing Xu(RainX)" Date: Sat, 12 Oct 2024 11:43:14 +0800 Subject: [PATCH] fix: resolve all ESLint issues caused by upgrading package --- .husky/commit-msg | 3 - package.json | 61 +++++----- src/index.ts | 114 +++++++++--------- .../ast/const-expr/const-expr-node.ts | 2 +- .../ast/node-visitor/cloning-visitor.ts | 1 + .../php-doc/assert-tag-method-value-node.ts | 2 +- .../php-doc/assert-tag-property-value-node.ts | 2 +- .../ast/php-doc/assert-tag-value-node.ts | 2 +- .../ast/php-doc/extends-tag-value-node.ts | 2 +- .../ast/php-doc/implements-tag-value-node.ts | 2 +- .../ast/php-doc/invalid-tag-value-node.ts | 2 +- .../ast/php-doc/method-tag-value-node.ts | 2 +- .../method-tag-value-parameter-node.ts | 2 +- .../ast/php-doc/mixin-tag-value-node.ts | 2 +- .../ast/php-doc/param-out-tag-value-node.ts | 2 +- .../ast/php-doc/param-tag-value-node.ts | 2 +- src/phpdoc-parser/ast/php-doc/php-doc-node.ts | 2 +- .../ast/php-doc/property-tag-value-node.ts | 2 +- .../ast/php-doc/return-tag-value-node.ts | 2 +- .../ast/php-doc/self-out-tag-value-node.ts | 2 +- .../ast/php-doc/template-tag-value-node.ts | 2 +- .../ast/php-doc/throws-tag-value-node.ts | 2 +- .../type-alias-import-tag-value-node.ts | 2 +- .../ast/php-doc/type-alias-tag-value-node.ts | 2 +- .../ast/php-doc/uses-tag-value-node.ts | 2 +- .../ast/php-doc/var-tag-value-node.ts | 2 +- .../ast/type/array-shape-item-node.ts | 4 +- src/phpdoc-parser/ast/type/const-type-node.ts | 2 +- .../ast/type/invalid-type-node.ts | 2 +- .../ast/type/object-shape-item-node.ts | 2 +- src/phpdoc-parser/ast/type/type-node.ts | 2 +- src/phpdoc-parser/parser/const-expr-parser.ts | 6 +- src/phpdoc-parser/parser/php-doc-parser.ts | 8 +- src/phpdoc-parser/parser/token-iterator.ts | 2 +- src/phpdoc-parser/parser/type-parser.ts | 9 +- src/phpdoc-parser/printer/printer.ts | 4 +- src/phpdoc-parser/transpiler/helpers.ts | 28 ++--- .../php-doc-to-typescript-type-transpiler.ts | 3 +- 38 files changed, 147 insertions(+), 148 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index c406c56..6958a68 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - pnpm commitlint --edit --config=commitlint.config.js diff --git a/package.json b/package.json index 2d27d9d..8f3974d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "@rightcapital/phpdoc-parser", "version": "0.4.72", + "description": "TypeScript version of PHPDoc parser with support for intersection types and generics", "keywords": [ "PHP", "PHPDoc", @@ -11,22 +12,34 @@ "AST", "Lexer" ], - "description": "TypeScript version of PHPDoc parser with support for intersection types and generics", - "main": "dist/index.js", "repository": "https://github.com/RightCapitalHQ/phpdoc-parser", - "author": "RightCapital Ecosystem team ", "license": "MIT", - "packageManager": "pnpm@9.12.1", - "publishConfig": { - "registry": "https://registry.npmjs.org" - }, - "engines": { - "node": ">=16.x", - "pnpm": ">=8.x" - }, + "author": "RightCapital Ecosystem team ", + "main": "dist/index.js", "files": [ "dist" ], + "scripts": { + "build": "pnpm run clean && tsc --project ./tsconfig.build.json", + "change": "beachball change --no-commit", + "check": "beachball check", + "clean": "tsc --build --clean ./tsconfig.build.json", + "commit": "cz", + "eslint": "eslint --report-unused-disable-directives 'src/**/*.ts*'", + "eslint:fix": "eslint --report-unused-disable-directives --fix 'src/**/*.ts*'", + "preinstall": "npx only-allow pnpm", + "test": "vitest" + }, + "config": { + "commitizen": { + "path": "@commitlint/cz-commitlint" + } + }, + "dependencies": { + "@types/node": "20.16.11", + "lodash": "4.17.21", + "typescript": "5.6.3" + }, "devDependencies": { "@babel/core": "7.25.8", "@babel/preset-env": "7.25.8", @@ -46,26 +59,12 @@ "prettier": "3.3.3", "vitest": "2.1.2" }, - "dependencies": { - "@types/node": "20.16.11", - "lodash": "4.17.21", - "typescript": "5.6.3" - }, - "scripts": { - "commit": "cz", - "clean": "tsc --build --clean ./tsconfig.build.json", - "change": "beachball change --no-commit", - "check": "beachball check", - "build": "pnpm run clean && tsc --project ./tsconfig.build.json", - "preinstall": "npx only-allow pnpm", - "prepare": "husky install", - "eslint": "eslint --report-unused-disable-directives 'src/**/*.ts*'", - "eslint:fix": "eslint --report-unused-disable-directives --fix 'src/**/*.ts*'", - "test": "vitest" + "packageManager": "pnpm@9.12.1", + "engines": { + "node": ">=16.x", + "pnpm": ">=8.x" }, - "config": { - "commitizen": { - "path": "@commitlint/cz-commitlint" - } + "publishConfig": { + "registry": "https://registry.npmjs.org" } } diff --git a/src/index.ts b/src/index.ts index b6c5601..b67586f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,76 +1,76 @@ -export { Lexer } from './phpdoc-parser/lexer/lexer'; -export { ConstExprParser } from './phpdoc-parser/parser/const-expr-parser'; -export { StringUnescaper } from './phpdoc-parser/parser/string-unescaper'; -export { ParserException } from './phpdoc-parser/parser/parser-exception'; -export { TokenIterator } from './phpdoc-parser/parser/token-iterator'; -export { PhpDocParser } from './phpdoc-parser/parser/php-doc-parser'; -export { TypeParser } from './phpdoc-parser/parser/type-parser'; -export { BaseNode } from './phpdoc-parser/ast/base-node'; -export type { Node } from './phpdoc-parser/ast/node'; -export { NodeTraverser } from './phpdoc-parser/ast/node-traverser'; -export { CloningVisitor } from './phpdoc-parser/ast/node-visitor/cloning-visitor'; -export type { NodeVisitor } from './phpdoc-parser/ast/node-visitor'; -export { NodeTraverserState, Attribute } from './phpdoc-parser/ast/types'; -export { IdentifierTypeNode } from './phpdoc-parser/ast/type/identifier-type-node'; -export { CallableTypeParameterNode } from './phpdoc-parser/ast/type/callable-type-parameter-node'; -export { OffsetAccessTypeNode } from './phpdoc-parser/ast/type/offset-access-type-node'; -export { ArrayShapeItemNode } from './phpdoc-parser/ast/type/array-shape-item-node'; -export { ConditionalTypeNode } from './phpdoc-parser/ast/type/conditional-type-node'; -export { ConditionalTypeForParameterNode } from './phpdoc-parser/ast/type/conditional-type-for-parameter-node'; -export { ThisTypeNode } from './phpdoc-parser/ast/type/this-type-node'; -export { IntersectionTypeNode } from './phpdoc-parser/ast/type/intersection-type-node'; -export { ObjectShapeItemNode } from './phpdoc-parser/ast/type/object-shape-item-node'; -export { UnionTypeNode } from './phpdoc-parser/ast/type/union-type-node'; -export { TypeNode } from './phpdoc-parser/ast/type/type-node'; -export { GenericTypeNode } from './phpdoc-parser/ast/type/generic-type-node'; -export { CallableTypeNode } from './phpdoc-parser/ast/type/callable-type-node'; -export { ArrayTypeNode } from './phpdoc-parser/ast/type/array-type-node'; -export { ArrayShapeNode } from './phpdoc-parser/ast/type/array-shape-node'; -export { InvalidTypeNode } from './phpdoc-parser/ast/type/invalid-type-node'; -export { ConstTypeNode } from './phpdoc-parser/ast/type/const-type-node'; -export { ObjectShapeNode } from './phpdoc-parser/ast/type/object-shape-node'; -export { NullableTypeNode } from './phpdoc-parser/ast/type/nullable-type-node'; export { AbstractNodeVisitor } from './phpdoc-parser/ast/abstract-node-visitor'; -export { ConstExprFloatNode } from './phpdoc-parser/ast/const-expr/const-expr-float-node'; +export { BaseNode } from './phpdoc-parser/ast/base-node'; export { ConstExprArrayItemNode } from './phpdoc-parser/ast/const-expr/const-expr-array-item-node'; +export { ConstExprArrayNode } from './phpdoc-parser/ast/const-expr/const-expr-array-node'; export { ConstExprFalseNode } from './phpdoc-parser/ast/const-expr/const-expr-false-node'; -export { QuoteAwareConstExprStringNode } from './phpdoc-parser/ast/const-expr/quote-aware-const-expr-string-node'; -export { ConstExprNullNode } from './phpdoc-parser/ast/const-expr/const-expr-null-node'; +export { ConstExprFloatNode } from './phpdoc-parser/ast/const-expr/const-expr-float-node'; export { ConstExprIntegerNode } from './phpdoc-parser/ast/const-expr/const-expr-integer-node'; export { ConstExprNode } from './phpdoc-parser/ast/const-expr/const-expr-node'; -export { ConstExprArrayNode } from './phpdoc-parser/ast/const-expr/const-expr-array-node'; +export { ConstExprNullNode } from './phpdoc-parser/ast/const-expr/const-expr-null-node'; export { ConstExprStringNode } from './phpdoc-parser/ast/const-expr/const-expr-string-node'; export { ConstExprTrueNode } from './phpdoc-parser/ast/const-expr/const-expr-true-node'; export { ConstFetchNode } from './phpdoc-parser/ast/const-expr/const-fetch-node'; -export { ParamOutTagValueNode } from './phpdoc-parser/ast/php-doc/param-out-tag-value-node'; -export { PhpDocNode } from './phpdoc-parser/ast/php-doc/php-doc-node'; +export { QuoteAwareConstExprStringNode } from './phpdoc-parser/ast/const-expr/quote-aware-const-expr-string-node'; +export type { Node } from './phpdoc-parser/ast/node'; +export { NodeTraverser } from './phpdoc-parser/ast/node-traverser'; +export type { NodeVisitor } from './phpdoc-parser/ast/node-visitor'; +export { CloningVisitor } from './phpdoc-parser/ast/node-visitor/cloning-visitor'; +export { AssertTagMethodValueNode } from './phpdoc-parser/ast/php-doc/assert-tag-method-value-node'; +export { AssertTagPropertyValueNode } from './phpdoc-parser/ast/php-doc/assert-tag-property-value-node'; export { AssertTagValueNode } from './phpdoc-parser/ast/php-doc/assert-tag-value-node'; -export { UsesTagValueNode } from './phpdoc-parser/ast/php-doc/uses-tag-value-node'; -export { InvalidTagValueNode } from './phpdoc-parser/ast/php-doc/invalid-tag-value-node'; -export { MethodTagValueNode } from './phpdoc-parser/ast/php-doc/method-tag-value-node'; export { DeprecatedTagValueNode } from './phpdoc-parser/ast/php-doc/deprecated-tag-value-node'; export { ExtendsTagValueNode } from './phpdoc-parser/ast/php-doc/extends-tag-value-node'; -export { ParamTagValueNode } from './phpdoc-parser/ast/php-doc/param-tag-value-node'; export { GenericTagValueNode } from './phpdoc-parser/ast/php-doc/generic-tag-value-node'; -export { TypeAliasTagValueNode } from './phpdoc-parser/ast/php-doc/type-alias-tag-value-node'; -export { AssertTagPropertyValueNode } from './phpdoc-parser/ast/php-doc/assert-tag-property-value-node'; -export { TypelessParamTagValueNode } from './phpdoc-parser/ast/php-doc/typeless-param-tag-value-node'; -export { VarTagValueNode } from './phpdoc-parser/ast/php-doc/var-tag-value-node'; -export { PhpDocTextNode } from './phpdoc-parser/ast/php-doc/php-doc-text-node'; -export { MethodTagValueParameterNode } from './phpdoc-parser/ast/php-doc/method-tag-value-parameter-node'; -export { AssertTagMethodValueNode } from './phpdoc-parser/ast/php-doc/assert-tag-method-value-node'; -export { TemplateTagValueNode } from './phpdoc-parser/ast/php-doc/template-tag-value-node'; +export * from './phpdoc-parser/ast/php-doc/helpers'; export { ImplementsTagValueNode } from './phpdoc-parser/ast/php-doc/implements-tag-value-node'; -export { ThrowsTagValueNode } from './phpdoc-parser/ast/php-doc/throws-tag-value-node'; -export { SelfOutTagValueNode } from './phpdoc-parser/ast/php-doc/self-out-tag-value-node'; -export { PropertyTagValueNode } from './phpdoc-parser/ast/php-doc/property-tag-value-node'; -export { TypeAliasImportTagValueNode } from './phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node'; -export { PhpDocChildNode } from './phpdoc-parser/ast/php-doc/php-doc-child-node'; +export { InvalidTagValueNode } from './phpdoc-parser/ast/php-doc/invalid-tag-value-node'; +export { MethodTagValueNode } from './phpdoc-parser/ast/php-doc/method-tag-value-node'; +export { MethodTagValueParameterNode } from './phpdoc-parser/ast/php-doc/method-tag-value-parameter-node'; export { MixinTagValueNode } from './phpdoc-parser/ast/php-doc/mixin-tag-value-node'; +export { ParamOutTagValueNode } from './phpdoc-parser/ast/php-doc/param-out-tag-value-node'; +export { ParamTagValueNode } from './phpdoc-parser/ast/php-doc/param-tag-value-node'; +export { PhpDocChildNode } from './phpdoc-parser/ast/php-doc/php-doc-child-node'; +export { PhpDocNode } from './phpdoc-parser/ast/php-doc/php-doc-node'; export { PhpDocTagNode } from './phpdoc-parser/ast/php-doc/php-doc-tag-node'; export { PhpDocTagValueNode } from './phpdoc-parser/ast/php-doc/php-doc-tag-value-node'; +export { PhpDocTextNode } from './phpdoc-parser/ast/php-doc/php-doc-text-node'; +export { PropertyTagValueNode } from './phpdoc-parser/ast/php-doc/property-tag-value-node'; export { ReturnTagValueNode } from './phpdoc-parser/ast/php-doc/return-tag-value-node'; +export { SelfOutTagValueNode } from './phpdoc-parser/ast/php-doc/self-out-tag-value-node'; +export { TemplateTagValueNode } from './phpdoc-parser/ast/php-doc/template-tag-value-node'; +export { ThrowsTagValueNode } from './phpdoc-parser/ast/php-doc/throws-tag-value-node'; +export { TypeAliasImportTagValueNode } from './phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node'; +export { TypeAliasTagValueNode } from './phpdoc-parser/ast/php-doc/type-alias-tag-value-node'; +export { TypelessParamTagValueNode } from './phpdoc-parser/ast/php-doc/typeless-param-tag-value-node'; +export { UsesTagValueNode } from './phpdoc-parser/ast/php-doc/uses-tag-value-node'; +export { VarTagValueNode } from './phpdoc-parser/ast/php-doc/var-tag-value-node'; +export { ArrayShapeItemNode } from './phpdoc-parser/ast/type/array-shape-item-node'; +export { ArrayShapeNode } from './phpdoc-parser/ast/type/array-shape-node'; +export { ArrayTypeNode } from './phpdoc-parser/ast/type/array-type-node'; +export { CallableTypeNode } from './phpdoc-parser/ast/type/callable-type-node'; +export { CallableTypeParameterNode } from './phpdoc-parser/ast/type/callable-type-parameter-node'; +export { ConditionalTypeForParameterNode } from './phpdoc-parser/ast/type/conditional-type-for-parameter-node'; +export { ConditionalTypeNode } from './phpdoc-parser/ast/type/conditional-type-node'; +export { ConstTypeNode } from './phpdoc-parser/ast/type/const-type-node'; +export { GenericTypeNode } from './phpdoc-parser/ast/type/generic-type-node'; +export { IdentifierTypeNode } from './phpdoc-parser/ast/type/identifier-type-node'; +export { IntersectionTypeNode } from './phpdoc-parser/ast/type/intersection-type-node'; +export { InvalidTypeNode } from './phpdoc-parser/ast/type/invalid-type-node'; +export { NullableTypeNode } from './phpdoc-parser/ast/type/nullable-type-node'; +export { ObjectShapeItemNode } from './phpdoc-parser/ast/type/object-shape-item-node'; +export { ObjectShapeNode } from './phpdoc-parser/ast/type/object-shape-node'; +export { OffsetAccessTypeNode } from './phpdoc-parser/ast/type/offset-access-type-node'; +export { ThisTypeNode } from './phpdoc-parser/ast/type/this-type-node'; +export { TypeNode } from './phpdoc-parser/ast/type/type-node'; +export { UnionTypeNode } from './phpdoc-parser/ast/type/union-type-node'; +export { Attribute, NodeTraverserState } from './phpdoc-parser/ast/types'; +export { Lexer } from './phpdoc-parser/lexer/lexer'; +export { ConstExprParser } from './phpdoc-parser/parser/const-expr-parser'; +export { ParserException } from './phpdoc-parser/parser/parser-exception'; +export { PhpDocParser } from './phpdoc-parser/parser/php-doc-parser'; +export { StringUnescaper } from './phpdoc-parser/parser/string-unescaper'; +export { TokenIterator } from './phpdoc-parser/parser/token-iterator'; +export { TypeParser } from './phpdoc-parser/parser/type-parser'; export { Printer } from './phpdoc-parser/printer/printer'; -export * from './phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler'; -export * from './phpdoc-parser/ast/php-doc/helpers'; export * from './phpdoc-parser/transpiler/helpers'; +export * from './phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler'; diff --git a/src/phpdoc-parser/ast/const-expr/const-expr-node.ts b/src/phpdoc-parser/ast/const-expr/const-expr-node.ts index ef107ec..ac2de5a 100644 --- a/src/phpdoc-parser/ast/const-expr/const-expr-node.ts +++ b/src/phpdoc-parser/ast/const-expr/const-expr-node.ts @@ -1,3 +1,4 @@ +import { BaseNode } from '../base-node'; import type { ConstExprArrayItemNode } from './const-expr-array-item-node'; import type { ConstExprArrayNode } from './const-expr-array-node'; import type { ConstExprFalseNode } from './const-expr-false-node'; @@ -8,7 +9,6 @@ import type { ConstExprStringNode } from './const-expr-string-node'; import type { ConstExprTrueNode } from './const-expr-true-node'; import type { ConstFetchNode } from './const-fetch-node'; import type { QuoteAwareConstExprStringNode } from './quote-aware-const-expr-string-node'; -import { BaseNode } from '../base-node'; export class ConstExprNode extends BaseNode { public getNodeType(): string { diff --git a/src/phpdoc-parser/ast/node-visitor/cloning-visitor.ts b/src/phpdoc-parser/ast/node-visitor/cloning-visitor.ts index f05121e..e79c94a 100644 --- a/src/phpdoc-parser/ast/node-visitor/cloning-visitor.ts +++ b/src/phpdoc-parser/ast/node-visitor/cloning-visitor.ts @@ -1,4 +1,5 @@ import { cloneDeep } from 'lodash'; + import { AbstractNodeVisitor } from '../abstract-node-visitor'; import type { Node } from '../node'; import { Attribute } from '../types'; diff --git a/src/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.ts b/src/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.ts index 8cee195..a60c156 100644 --- a/src/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class AssertTagMethodValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.ts b/src/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.ts index 57d8c20..3b32844 100644 --- a/src/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class AssertTagPropertyValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/assert-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/assert-tag-value-node.ts index d86a60a..9e3af07 100644 --- a/src/phpdoc-parser/ast/php-doc/assert-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/assert-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class AssertTagValueNode extends PhpDocTagValueNode { // Defining Types -- Types are set explicitly for public variables diff --git a/src/phpdoc-parser/ast/php-doc/extends-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/extends-tag-value-node.ts index c5a788b..e2767ca 100644 --- a/src/phpdoc-parser/ast/php-doc/extends-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/extends-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { GenericTypeNode } from '../type/generic-type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class ExtendsTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/implements-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/implements-tag-value-node.ts index 61e4b28..9f99e03 100644 --- a/src/phpdoc-parser/ast/php-doc/implements-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/implements-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { GenericTypeNode } from '../type/generic-type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class ImplementsTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/invalid-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/invalid-tag-value-node.ts index 940717f..24ee515 100644 --- a/src/phpdoc-parser/ast/php-doc/invalid-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/invalid-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import { ParserException } from '../../parser/parser-exception'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class InvalidTagValueNode extends PhpDocTagValueNode { private exceptionArgs: ConstructorParameters; diff --git a/src/phpdoc-parser/ast/php-doc/method-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/method-tag-value-node.ts index 223c223..026c06f 100644 --- a/src/phpdoc-parser/ast/php-doc/method-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/method-tag-value-node.ts @@ -1,7 +1,7 @@ +import type { TypeNode } from '../type/type-node'; import type { MethodTagValueParameterNode } from './method-tag-value-parameter-node'; import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TemplateTagValueNode } from './template-tag-value-node'; -import type { TypeNode } from '../type/type-node'; export class MethodTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.ts b/src/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.ts index 47ab1ff..a3bb99f 100644 --- a/src/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.ts +++ b/src/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.ts @@ -1,6 +1,6 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { ConstExprNode } from '../const-expr/const-expr-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class MethodTagValueParameterNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/mixin-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/mixin-tag-value-node.ts index 88e75d3..21114ca 100644 --- a/src/phpdoc-parser/ast/php-doc/mixin-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/mixin-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class MixinTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/param-out-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/param-out-tag-value-node.ts index 2aa5e66..a803905 100644 --- a/src/phpdoc-parser/ast/php-doc/param-out-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/param-out-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class ParamOutTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/param-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/param-tag-value-node.ts index 578ed95..f36cbd6 100644 --- a/src/phpdoc-parser/ast/php-doc/param-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/param-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class ParamTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/php-doc-node.ts b/src/phpdoc-parser/ast/php-doc/php-doc-node.ts index 1b0bf13..0e8dac4 100644 --- a/src/phpdoc-parser/ast/php-doc/php-doc-node.ts +++ b/src/phpdoc-parser/ast/php-doc/php-doc-node.ts @@ -1,3 +1,4 @@ +import { BaseNode } from '../base-node'; import { DeprecatedTagValueNode } from './deprecated-tag-value-node'; import { ExtendsTagValueNode } from './extends-tag-value-node'; import { ImplementsTagValueNode } from './implements-tag-value-node'; @@ -13,7 +14,6 @@ import { ThrowsTagValueNode } from './throws-tag-value-node'; import { TypelessParamTagValueNode } from './typeless-param-tag-value-node'; import { UsesTagValueNode } from './uses-tag-value-node'; import { VarTagValueNode } from './var-tag-value-node'; -import { BaseNode } from '../base-node'; export class PhpDocNode extends BaseNode { constructor(public children: PhpDocChildNode[]) { diff --git a/src/phpdoc-parser/ast/php-doc/property-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/property-tag-value-node.ts index 0ca67b1..a65894c 100644 --- a/src/phpdoc-parser/ast/php-doc/property-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/property-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class PropertyTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/return-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/return-tag-value-node.ts index 7f4795a..a3590de 100644 --- a/src/phpdoc-parser/ast/php-doc/return-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/return-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class ReturnTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/self-out-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/self-out-tag-value-node.ts index 79ab6cf..35635c1 100644 --- a/src/phpdoc-parser/ast/php-doc/self-out-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/self-out-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class SelfOutTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/template-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/template-tag-value-node.ts index 7bb28e0..836261c 100644 --- a/src/phpdoc-parser/ast/php-doc/template-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/template-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class TemplateTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/throws-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/throws-tag-value-node.ts index ef6024c..233929c 100644 --- a/src/phpdoc-parser/ast/php-doc/throws-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/throws-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class ThrowsTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.ts index b319dc1..24183ec 100644 --- a/src/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { IdentifierTypeNode } from '../type/identifier-type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class TypeAliasImportTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.ts index eafbd9b..0c62df6 100644 --- a/src/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class TypeAliasTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/uses-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/uses-tag-value-node.ts index 7b73a74..1bc5218 100644 --- a/src/phpdoc-parser/ast/php-doc/uses-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/uses-tag-value-node.ts @@ -1,6 +1,6 @@ // Import statements, adjusted as per your TypeScript project setup -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { GenericTypeNode } from '../type/generic-type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class UsesTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/php-doc/var-tag-value-node.ts b/src/phpdoc-parser/ast/php-doc/var-tag-value-node.ts index fb4db9b..f368926 100644 --- a/src/phpdoc-parser/ast/php-doc/var-tag-value-node.ts +++ b/src/phpdoc-parser/ast/php-doc/var-tag-value-node.ts @@ -1,5 +1,5 @@ -import { PhpDocTagValueNode } from './php-doc-tag-value-node'; import type { TypeNode } from '../type/type-node'; +import { PhpDocTagValueNode } from './php-doc-tag-value-node'; export class VarTagValueNode extends PhpDocTagValueNode { constructor( diff --git a/src/phpdoc-parser/ast/type/array-shape-item-node.ts b/src/phpdoc-parser/ast/type/array-shape-item-node.ts index 5dbaedb..abe7e44 100644 --- a/src/phpdoc-parser/ast/type/array-shape-item-node.ts +++ b/src/phpdoc-parser/ast/type/array-shape-item-node.ts @@ -1,7 +1,7 @@ -import type { IdentifierTypeNode } from './identifier-type-node'; -import { TypeNode } from './type-node'; import type { ConstExprIntegerNode } from '../const-expr/const-expr-integer-node'; import type { ConstExprStringNode } from '../const-expr/const-expr-string-node'; +import type { IdentifierTypeNode } from './identifier-type-node'; +import { TypeNode } from './type-node'; export class ArrayShapeItemNode extends TypeNode { constructor( diff --git a/src/phpdoc-parser/ast/type/const-type-node.ts b/src/phpdoc-parser/ast/type/const-type-node.ts index 8039e1a..f049cff 100644 --- a/src/phpdoc-parser/ast/type/const-type-node.ts +++ b/src/phpdoc-parser/ast/type/const-type-node.ts @@ -1,5 +1,5 @@ -import { TypeNode } from './type-node'; import type { ConstExprNode } from '../const-expr/const-expr-node'; +import { TypeNode } from './type-node'; export class ConstTypeNode extends TypeNode { constructor(public constExpr: ConstExprNode) { diff --git a/src/phpdoc-parser/ast/type/invalid-type-node.ts b/src/phpdoc-parser/ast/type/invalid-type-node.ts index 6a3b5c0..c521406 100644 --- a/src/phpdoc-parser/ast/type/invalid-type-node.ts +++ b/src/phpdoc-parser/ast/type/invalid-type-node.ts @@ -1,5 +1,5 @@ -import { TypeNode } from './type-node'; import { ParserException } from '../../parser/parser-exception'; +import { TypeNode } from './type-node'; export class InvalidTypeNode extends TypeNode { public exceptionArgs: ConstructorParameters; diff --git a/src/phpdoc-parser/ast/type/object-shape-item-node.ts b/src/phpdoc-parser/ast/type/object-shape-item-node.ts index b95b528..962b8bb 100644 --- a/src/phpdoc-parser/ast/type/object-shape-item-node.ts +++ b/src/phpdoc-parser/ast/type/object-shape-item-node.ts @@ -1,6 +1,6 @@ +import type { ConstExprStringNode } from '../const-expr/const-expr-string-node'; import type { IdentifierTypeNode } from './identifier-type-node'; import { TypeNode } from './type-node'; -import type { ConstExprStringNode } from '../const-expr/const-expr-string-node'; export class ObjectShapeItemNode extends TypeNode { constructor( diff --git a/src/phpdoc-parser/ast/type/type-node.ts b/src/phpdoc-parser/ast/type/type-node.ts index f531ece..7e20ac8 100644 --- a/src/phpdoc-parser/ast/type/type-node.ts +++ b/src/phpdoc-parser/ast/type/type-node.ts @@ -1,3 +1,4 @@ +import { BaseNode } from '../base-node'; import type { ArrayShapeItemNode } from './array-shape-item-node'; import type { ArrayShapeNode } from './array-shape-node'; import type { ArrayTypeNode } from './array-type-node'; @@ -16,7 +17,6 @@ import type { ObjectShapeNode } from './object-shape-node'; import type { OffsetAccessTypeNode } from './offset-access-type-node'; import type { ThisTypeNode } from './this-type-node'; import type { UnionTypeNode } from './union-type-node'; -import { BaseNode } from '../base-node'; /** * TypeNode is a abstract Node for containing other nodes diff --git a/src/phpdoc-parser/parser/const-expr-parser.ts b/src/phpdoc-parser/parser/const-expr-parser.ts index a1d916e..3b04f52 100644 --- a/src/phpdoc-parser/parser/const-expr-parser.ts +++ b/src/phpdoc-parser/parser/const-expr-parser.ts @@ -1,6 +1,3 @@ -import { ParserException } from './parser-exception'; -import { StringUnescaper } from './string-unescaper'; -import type { TokenIterator } from './token-iterator'; import { ConstExprArrayItemNode } from '../ast/const-expr/const-expr-array-item-node'; import { ConstExprArrayNode } from '../ast/const-expr/const-expr-array-node'; import { ConstExprFalseNode } from '../ast/const-expr/const-expr-false-node'; @@ -14,6 +11,9 @@ import { ConstFetchNode } from '../ast/const-expr/const-fetch-node'; import { QuoteAwareConstExprStringNode } from '../ast/const-expr/quote-aware-const-expr-string-node'; import { Attribute } from '../ast/types'; import { Lexer } from '../lexer/lexer'; +import { ParserException } from './parser-exception'; +import { StringUnescaper } from './string-unescaper'; +import type { TokenIterator } from './token-iterator'; export class ConstExprParser { private useLinesAttributes: boolean; diff --git a/src/phpdoc-parser/parser/php-doc-parser.ts b/src/phpdoc-parser/parser/php-doc-parser.ts index 0bce192..7b9d8b3 100644 --- a/src/phpdoc-parser/parser/php-doc-parser.ts +++ b/src/phpdoc-parser/parser/php-doc-parser.ts @@ -1,7 +1,3 @@ -import type { ConstExprParser } from './const-expr-parser'; -import type { ParserException } from './parser-exception'; -import type { TokenIterator } from './token-iterator'; -import type { TypeParser } from './type-parser'; import type { BaseNode } from '../ast/base-node'; import type { ConstExprNode } from '../ast/const-expr/const-expr-node'; import { AssertTagMethodValueNode } from '../ast/php-doc/assert-tag-method-value-node'; @@ -37,6 +33,10 @@ import { InvalidTypeNode } from '../ast/type/invalid-type-node'; import type { TypeNode } from '../ast/type/type-node'; import { Attribute } from '../ast/types'; import { Lexer } from '../lexer/lexer'; +import type { ConstExprParser } from './const-expr-parser'; +import type { ParserException } from './parser-exception'; +import type { TokenIterator } from './token-iterator'; +import type { TypeParser } from './type-parser'; const DISALLOWED_DESCRIPTION_START_TOKENS = [ Lexer.TOKEN_UNION, diff --git a/src/phpdoc-parser/parser/token-iterator.ts b/src/phpdoc-parser/parser/token-iterator.ts index b70c19e..853d2d6 100644 --- a/src/phpdoc-parser/parser/token-iterator.ts +++ b/src/phpdoc-parser/parser/token-iterator.ts @@ -1,5 +1,5 @@ -import { ParserException } from './parser-exception'; import { Lexer } from '../lexer/lexer'; +import { ParserException } from './parser-exception'; export class TokenIterator { private tokens: Array<[string, string, number]>; diff --git a/src/phpdoc-parser/parser/type-parser.ts b/src/phpdoc-parser/parser/type-parser.ts index 5643f75..237c3db 100644 --- a/src/phpdoc-parser/parser/type-parser.ts +++ b/src/phpdoc-parser/parser/type-parser.ts @@ -1,7 +1,3 @@ -import type { ConstExprParser } from './const-expr-parser'; -import { ParserException } from './parser-exception'; -import { StringUnescaper } from './string-unescaper'; -import type { TokenIterator } from './token-iterator'; import type { BaseNode } from '../ast/base-node'; import { ConstExprArrayNode } from '../ast/const-expr/const-expr-array-node'; import { ConstExprIntegerNode } from '../ast/const-expr/const-expr-integer-node'; @@ -33,6 +29,10 @@ import type { TypeNode } from '../ast/type/type-node'; import { UnionTypeNode } from '../ast/type/union-type-node'; import { Attribute } from '../ast/types'; import { Lexer } from '../lexer/lexer'; +import type { ConstExprParser } from './const-expr-parser'; +import { ParserException } from './parser-exception'; +import { StringUnescaper } from './string-unescaper'; +import type { TokenIterator } from './token-iterator'; export class TypeParser { private useLinesAttributes: boolean; @@ -212,6 +212,7 @@ export class TypeParser { startIndex, ); } catch (error) { + exception.cause = error; throw exception; } } diff --git a/src/phpdoc-parser/printer/printer.ts b/src/phpdoc-parser/printer/printer.ts index db59b44..dff69f9 100644 --- a/src/phpdoc-parser/printer/printer.ts +++ b/src/phpdoc-parser/printer/printer.ts @@ -1,5 +1,3 @@ -import { DiffElemType } from './diff-elem'; -import { Differ } from './differ'; import { BaseNode } from '../ast/base-node'; import { ConstExprArrayNode } from '../ast/const-expr/const-expr-array-node'; import { ConstExprNode } from '../ast/const-expr/const-expr-node'; @@ -49,6 +47,8 @@ import { UnionTypeNode } from '../ast/type/union-type-node'; import { Attribute } from '../ast/types'; import { Lexer } from '../lexer/lexer'; import type { TokenIterator } from '../parser/token-iterator'; +import { DiffElemType } from './diff-elem'; +import { Differ } from './differ'; export class Printer { private differ: Differ; diff --git a/src/phpdoc-parser/transpiler/helpers.ts b/src/phpdoc-parser/transpiler/helpers.ts index 23f5f75..3d15995 100644 --- a/src/phpdoc-parser/transpiler/helpers.ts +++ b/src/phpdoc-parser/transpiler/helpers.ts @@ -1,24 +1,24 @@ import { - type ImportDeclaration, - factory, + addSyntheticLeadingComment, + createPrinter, + createSourceFile, + EmitHint, + type EnumDeclaration, type ExportDeclaration, - type TypeElement, - type TypeParameterDeclaration, + factory, type HeritageClause, + type ImportDeclaration, type InterfaceDeclaration, - SyntaxKind, + type ModifierSyntaxKind, + NewLineKind, + type Node, + ScriptKind, ScriptTarget, type SourceFile, - createSourceFile, - ScriptKind, type Statement, - addSyntheticLeadingComment, - type EnumDeclaration, - type ModifierSyntaxKind, - type Node, - createPrinter, - NewLineKind, - EmitHint, + SyntaxKind, + type TypeElement, + type TypeParameterDeclaration, } from 'typescript'; /** diff --git a/src/phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler.ts b/src/phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler.ts index 0451d24..cddc3b0 100644 --- a/src/phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler.ts +++ b/src/phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler.ts @@ -1,9 +1,10 @@ import { + factory, type ImportDeclaration, SyntaxKind, type TypeNode, - factory, } from 'typescript'; + import type { ArrayShapeItemNode } from '../ast/type/array-shape-item-node'; import { ArrayShapeNode } from '../ast/type/array-shape-node'; import { ArrayTypeNode } from '../ast/type/array-type-node';