Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: add ast-spec, type-utils docs with docusaurus-plugin-typedoc#9293

New issue

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

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

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
1ea3573
docs: add type-utils docs with docusaurus-plugin-typedoc
JoshuaKGoldbergJun 6, 2024
9b6b2e2
Well, it works now
JoshuaKGoldbergJun 6, 2024
0924498
Wow, single page actually works well
JoshuaKGoldbergJun 6, 2024
584df32
Add back comment
JoshuaKGoldbergJun 6, 2024
d0c8ce7
chore: update knip.ts
JoshuaKGoldbergJun 6, 2024
0db3d52
Add ast-spec underneath typescript-estree
JoshuaKGoldbergJun 7, 2024
f958009
Internal ast-spec cleanups
JoshuaKGoldbergJun 7, 2024
1698570
Forked typedoc-plugin-no-inherit
JoshuaKGoldbergJun 7, 2024
dda405a
Undo unnecessary Linter.ts change
JoshuaKGoldbergJun 7, 2024
cf490b1
Fix up some examples to be true code blocks
JoshuaKGoldbergJun 7, 2024
9fe7448
fix lint for some reason
JoshuaKGoldbergJun 7, 2024
3021816
Split up variable multiline examples
JoshuaKGoldbergJun 22, 2024
7185b7e
Merge branch 'main'
JoshuaKGoldbergJun 22, 2024
15c0870
Remove utils TypeDoc generation
JoshuaKGoldbergJun 25, 2024
258419e
Merge branch 'main'
JoshuaKGoldbergJun 25, 2024
fa89b9e
one example
JoshuaKGoldbergJul 20, 2024
0e8f79d
Merge branch 'main' into docusaurus-plugin-typedoc
JoshuaKGoldbergJul 29, 2024
dd17e7a
Fixed remaining example tags
JoshuaKGoldbergJul 29, 2024
e73bc3f
Fixed remaining example tags
JoshuaKGoldbergJul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ yarn-debug.log*
yarn-error.log*

# Website
docs/packages/*/generated
packages/website/.docusaurus
packages/website/.cache-loader
packages/website/build
Expand Down
17 changes: 14 additions & 3 deletionsdocs/packages/Type_Utils.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
---
id: type-utils
sidebar_label: type-utils
toc_max_heading_level: 3
---

import GeneratedDocs from './type-utils/generated/index.md';

# `@typescript-eslint/type-utils`

<PackageLink packageName="type-utils" scope="@typescript-eslint" />

> Type utilities for working with TypeScriptwithin ESLint rules.
> Type utilities for working with TypeScripttypes

This package contains public utilities for working with TypeScript types that ESLint rules often use.
This package contains public utilities for working with TypeScript types.
Rules declared in [`@typescript-eslint/eslint-plugin`](./ESLint_Plugin.mdx) use these utility functions.

The utilities in this package are both:

- More generally ESLint-focused than the broad TypeScript utilities in [`ts-api-utils`](https://npmjs.com/package/ts-api-utils)
- Separated from [`@typescript-eslint/utils`](./Utils.mdx) so that that package does not require a dependency on `typescript`

> See [Custom Rules](../developers/Custom_Rules.mdx) for documentation on creating your own custom ESLint rules for TypeScript code.
:::tip
See [Custom Rules](../developers/Custom_Rules.mdx) for documentation on creating your own custom ESLint rules for TypeScript code.
:::

---

The following documentation is auto-generated from source code.

<GeneratedDocs />
1 change: 1 addition & 0 deletionsdocs/packages/Utils.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
---
id: utils
sidebar_label: utils
toc_max_heading_level: 3
---

# `@typescript-eslint/utils`
Expand Down
13 changes: 13 additions & 0 deletionsdocs/packages/typescript-estree/AST_Spec.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
---
id: ast-spec
sidebar_label: AST Specification
toc_max_heading_level: 3
---

import GeneratedDocs from '../ast-spec/generated/index.md';

# AST Specification

The following auto-generated documentation describes the Abstract Syntax Tree (AST) generated by [`@typescript-eslint/typescript-estree`](../TypeScript_ESTree.mdx) for parsers such as [`@typescript-eslint/parser`](../Parser.mdx).

<GeneratedDocs />
3 changes: 3 additions & 0 deletionsknip.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,6 +97,9 @@ export default {
'@generated/docusaurus.config',
'^@theme/.*',
'^@theme-original/.*',
'docusaurus-plugin-typedoc',
'typedoc',
'typedoc-plugin-markdown',
],
},
'packages/website-eslint': {
Expand Down
6 changes: 3 additions & 3 deletionspackages/ast-spec/src/ast-node-types.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,9 +88,9 @@ export enum AST_NODE_TYPES {
WhileStatement = 'WhileStatement',
WithStatement = 'WithStatement',
YieldExpression = 'YieldExpression',
/**
* TS-prefixed nodes
*/

// TS_prefixed nodes
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The/** ... */ JSDoc style comment was getting picked up as a comment on specificallyTSAbstractAccessorProperty.

Screenshot of "TS-prefixed-nodes" as a TypeDoc-rendered comment on TSAbstractAccessorProperty


TSAbstractAccessorProperty = 'TSAbstractAccessorProperty',
TSAbstractKeyword = 'TSAbstractKeyword',
TSAbstractMethodDefinition = 'TSAbstractMethodDefinition',
Expand Down
15 changes: 9 additions & 6 deletionspackages/ast-spec/src/base/ClassBase.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,9 @@ import type { BaseNode } from './BaseNode';
export interface ClassBase extends BaseNode {
/**
* Whether the class is an abstract class.
* ```
* abstract class Foo {...}
* @example
* ```ts
* abstract class Foo {}
* ```
*/
abstract: boolean;
Expand All@@ -21,16 +22,18 @@ export interface ClassBase extends BaseNode {
body: ClassBody;
/**
* Whether the class has been `declare`d:
* ```
* declare class Foo {...}
* @example
* ```ts
* declare class Foo {}
* ```
*/
declare: boolean;
/**
* The decorators declared for the class.
* ```
* @example
* ```ts
* @deco
* class Foo {...}
* class Foo {}
* ```
*/
decorators: Decorator[];
Expand Down
12 changes: 6 additions & 6 deletionspackages/ast-spec/src/base/FunctionBase.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,9 +10,9 @@ export interface FunctionBase extends BaseNode {
/**
* Whether the function is async:
* ```
* async function foo(...) {...}
* const x = async function (...) {...}
* const x = async (...) => {...}
* async function foo() {}
* const x = async function () {}
* const x = async () => {}
* ```
*/
async: boolean;
Expand All@@ -27,7 +27,7 @@ export interface FunctionBase extends BaseNode {
/**
* This is only `true` if and only if the node is a `TSDeclareFunction` and it has `declare`:
* ```
* declare function foo(...) {...}
* declare function foo() {}
* ```
*/
declare: boolean;
Expand All@@ -42,8 +42,8 @@ export interface FunctionBase extends BaseNode {
/**
* Whether the function is a generator function:
* ```
* function *foo(...) {...}
* const x = function *(...) {...}
* function *foo() {}
* const x = function *() {}
* ```
* This is always `false` for arrow functions as they cannot be generators.
*/
Expand Down
5 changes: 0 additions & 5 deletionspackages/ast-spec/src/base/NodeOrTokenData.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,14 +6,9 @@ export interface NodeOrTokenData {
* The source location information of the node.
*
* The loc property is defined as nullable by ESTree, but ESLint requires this property.
*
* @see {SourceLocation}
*/
loc: SourceLocation;

/**
* @see {Range}
*/
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

These@sees just restate the type. No useful info added.

range: Range;

type: string;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,16 +9,18 @@ export interface ExportAllDeclaration extends BaseNode {
type: AST_NODE_TYPES.ExportAllDeclaration;
/**
* The assertions declared for the export.
* ```
* export * from 'mod' assert { type: 'json' };
* @example
* ```ts
* export * from 'mod' assert \{ type: 'json' \};
* ```
* @deprecated Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* The attributes declared for the export.
* ```
* export * from 'mod' with { type: 'json' };
* @example
* ```ts
* export * from 'mod' with \{ type: 'json' \};
* ```
*/
attributes: ImportAttribute[];
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,24 +10,27 @@ interface ExportNamedDeclarationBase extends BaseNode {
type: AST_NODE_TYPES.ExportNamedDeclaration;
/**
* The assertions declared for the export.
* ```
* export { foo } from 'mod' assert { type: 'json' };
* @example
* ```ts
* export { foo } from 'mod' assert \{ type: 'json' \};
* ```
* This will be an empty array if `source` is `null`
* @deprecated Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* The attributes declared for the export.
* ```
* export { foo } from 'mod' with { type: 'json' };
* @example
* ```ts
* export { foo } from 'mod' with \{ type: 'json' \};
* ```
* This will be an empty array if `source` is `null`
*/
attributes: ImportAttribute[];
/**
* The exported declaration.
* ```
* @example
* ```ts
* export const x = 1;
* ```
* This will be `null` if `source` is not `null`, or if there are `specifiers`
Expand All@@ -43,7 +46,8 @@ interface ExportNamedDeclarationBase extends BaseNode {
source: StringLiteral | null;
/**
* The specifiers being exported.
* ```
* @example
* ```ts
* export { a, b };
* ```
* This will be an empty array if `declaration` is not `null`
Expand Down
10 changes: 6 additions & 4 deletionspackages/ast-spec/src/declaration/ImportDeclaration/spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,16 +9,18 @@ export interface ImportDeclaration extends BaseNode {
type: AST_NODE_TYPES.ImportDeclaration;
/**
* The assertions declared for the export.
* ```
* import * from 'mod' assert { type: 'json' };
* @example
* ```ts
* import * from 'mod' assert \{ type: 'json' \};
* ```
* @deprecated Replaced with {@link `attributes`}.
*/
assertions: ImportAttribute[];
/**
* The attributes declared for the export.
* ```
* import * from 'mod' with { type: 'json' };
* @example
* ```ts
* import * from 'mod' with \{ type: 'json' \};
* ```
*/
attributes: ImportAttribute[];
Expand Down
10 changes: 6 additions & 4 deletionspackages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,15 +7,17 @@ export interface TSEnumDeclaration extends BaseNode {
type: AST_NODE_TYPES.TSEnumDeclaration;
/**
* Whether this is a `const` enum.
* ```
* const enum Foo {...}
* @example
* ```ts
* const enum Foo {}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Invalid TS syntax in```s -with or without@example or the `ts` block- causes a parse error in the generated `index.md`:

Error: MDX compilation failed for file "/Users/josh/repos/typescript-eslint/docs/packages/ast-spec/generated/index.md"Cause: Could not parse expression with acornDetails:{  "cause": {    "pos": 65758,    "loc": {      "line": 2505,      "column": 102    },    "raisedAt": 3  },  "column": 103,  "message": "Could not parse expression with acorn",  "line": 2505,  "name": "2505:103",  "place": {    "line": 2505,    "column": 103,    "offset": 65758  },  "reason": "Could not parse expression with acorn",  "ruleId": "acorn",  "source": "micromark-extension-mdx-expression",  "url": "https://github.com/micromark/micromark-extension-mdx-expression/tree/main/packages/micromark-extension-mdx-expression#could-not-parse-expression-with-acorn"}

The Markdown in question:

####Properties| Property| Type| Description| Overrides|| :------| :------| :------| :------||`const`|`boolean`| <p>Whether this is a`const` enum.</p><p>**Example**</p><code>const enum Foo {...}</code>| -||`declare`|`boolean`| <p>Whether this is a`declare`d enum.</p><p>**Example**</p><code>declare enum Foo {...}</code>| -||`id`|[`Identifier`](index.md#identifier)| The enum name.| -||`members`|[`TSEnumMember`](index.md#tsenummember)[]| The enum members.| -||`type`|`TSEnumDeclaration`| -|[`BaseNode`](index.md#basenode).`type`|***

...where the issue is on the<code> in the first tbody row.

* ```
*/
const: boolean;
/**
* Whether this is a `declare`d enum.
* ```
* declare enum Foo {...}
* @example
* ```ts
* declare enum Foo {}
* ```
*/
declare: boolean;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,8 @@ interface TSImportEqualsDeclarationBase extends BaseNode {
id: Identifier;
/**
* The value being aliased.
* ```
* @example
* ```ts
* import F1 = A;
* import F2 = A.B.C;
* import F3 = require('mod');
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,22 +26,28 @@ interface TSModuleDeclarationBase extends BaseNode {
body?: TSModuleBlock;
/**
* Whether this is a global declaration
* @example
* ```ts
* declare global {}
* ```
*
* @deprecated Use {@link kind} instead
*/
// TODO - remove this in the next major (we have `.kind` now)
global: boolean;
/**
* Whether the module is `declare`d
* ```
* @example
* ```ts
* declare namespace F {}
* ```
*/
declare: boolean;

/**
* The keyword used to define this module declaration
* ```
* @example
* ```ts
* namespace Foo {}
* ^^^^^^^^^
*
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,8 @@ export interface TSTypeAliasDeclaration extends BaseNode {
type: AST_NODE_TYPES.TSTypeAliasDeclaration;
/**
* Whether the type was `declare`d.
* ```
* @example
* ```ts
* declare type T = 1;
* ```
*/
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp