refactor: use eslint-config-neon for packages. (#8579)

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Suneet Tipirneni
2022-09-01 14:50:16 -04:00
committed by GitHub
parent 4bdb0593ae
commit edadb9fe5d
219 changed files with 2608 additions and 2053 deletions

View File

@@ -18,12 +18,12 @@ import {
type ApiConstructor,
type ApiItemContainerMixin,
} from '@microsoft/api-extractor-model';
import { generateTypeParamData } from './TypeParameterJSONEncoder';
import { type TokenDocumentation, resolveName, genReference, genToken, genParameter, generatePath } from './parse';
import { createCommentNode } from './tsdoc';
import { generateTypeParamData } from './TypeParameterJSONEncoder.js';
import { type TokenDocumentation, resolveName, genReference, genToken, genParameter, generatePath } from './parse.js';
import type { DocBlockJSON } from './tsdoc/CommentBlock';
import type { AnyDocNodeJSON } from './tsdoc/CommentNode';
import { type DocNodeContainerJSON, nodeContainer } from './tsdoc/CommentNodeContainer';
import { type DocNodeContainerJSON, nodeContainer } from './tsdoc/CommentNodeContainer.js';
import { createCommentNode } from './tsdoc/index.js';
export interface ReferenceData {
name: string;
@@ -31,9 +31,9 @@ export interface ReferenceData {
}
export interface InheritanceData {
parentKey: string;
parentName: string;
path: string;
parentKey: string;
}
export interface ApiInheritableJSON {
@@ -41,23 +41,23 @@ export interface ApiInheritableJSON {
}
export interface ApiItemJSON {
kind: string;
name: string;
referenceData: ReferenceData;
excerpt: string;
excerptTokens: TokenDocumentation[];
remarks: DocNodeContainerJSON | null;
summary: DocNodeContainerJSON | null;
deprecated: DocNodeContainerJSON | null;
comment: AnyDocNodeJSON | null;
containerKey: string;
deprecated: DocNodeContainerJSON | null;
excerpt: string;
excerptTokens: TokenDocumentation[];
kind: string;
name: string;
path: string[];
referenceData: ReferenceData;
remarks: DocNodeContainerJSON | null;
summary: DocNodeContainerJSON | null;
}
export interface ApiPropertyItemJSON extends ApiItemJSON, ApiInheritableJSON {
optional: boolean;
propertyTypeTokens: TokenDocumentation[];
readonly: boolean;
optional: boolean;
}
export interface ApiTypeParameterListJSON {
@@ -65,11 +65,11 @@ export interface ApiTypeParameterListJSON {
}
export interface ApiTypeParameterJSON {
name: string;
commentBlock: DocBlockJSON | null;
constraintTokens: TokenDocumentation[];
defaultTokens: TokenDocumentation[];
name: string;
optional: boolean;
commentBlock: DocBlockJSON | null;
}
export interface ApiParameterListJSON {
@@ -81,29 +81,29 @@ export interface ApiMethodSignatureJSON
ApiTypeParameterListJSON,
ApiParameterListJSON,
ApiInheritableJSON {
returnTypeTokens: TokenDocumentation[];
optional: boolean;
overloadIndex: number;
returnTypeTokens: TokenDocumentation[];
}
export interface ApiMethodJSON extends ApiMethodSignatureJSON {
static: boolean;
protected: boolean;
static: boolean;
}
export interface ApiParameterJSON {
name: string;
isOptional: boolean;
tokens: TokenDocumentation[];
name: string;
paramCommentBlock: DocBlockJSON | null;
tokens: TokenDocumentation[];
}
export interface ApiClassJSON extends ApiItemJSON, ApiTypeParameterListJSON {
constructor: ApiConstructorJSON | null;
properties: ApiPropertyItemJSON[];
methods: ApiMethodJSON[];
extendsTokens: TokenDocumentation[];
implementsTokens: TokenDocumentation[][];
methods: ApiMethodJSON[];
properties: ApiPropertyItemJSON[];
}
export interface ApiTypeAliasJSON extends ApiItemJSON, ApiTypeParameterListJSON {
@@ -111,8 +111,8 @@ export interface ApiTypeAliasJSON extends ApiItemJSON, ApiTypeParameterListJSON
}
export interface EnumMemberData {
name: string;
initializerTokens: TokenDocumentation[];
name: string;
summary: DocNodeContainerJSON | null;
}
@@ -121,19 +121,19 @@ export interface ApiEnumJSON extends ApiItemJSON {
}
export interface ApiInterfaceJSON extends ApiItemJSON, ApiTypeParameterListJSON {
properties: ApiPropertyItemJSON[];
methods: ApiMethodSignatureJSON[];
extendsTokens: TokenDocumentation[][] | null;
methods: ApiMethodSignatureJSON[];
properties: ApiPropertyItemJSON[];
}
export interface ApiVariableJSON extends ApiItemJSON {
typeTokens: TokenDocumentation[];
readonly: boolean;
typeTokens: TokenDocumentation[];
}
export interface ApiFunctionJSON extends ApiItemJSON, ApiTypeParameterListJSON, ApiParameterListJSON {
returnTypeTokens: TokenDocumentation[];
overloadIndex: number;
returnTypeTokens: TokenDocumentation[];
}
export interface ApiConstructorJSON extends ApiItemJSON, ApiParameterListJSON {
@@ -203,7 +203,7 @@ export class ApiNodeJSONEncoder {
public static encodeParameterList(
model: ApiModel,
item: ApiParameterListMixin & ApiDeclaredItem,
item: ApiDeclaredItem & ApiParameterListMixin,
version: string,
): { parameters: ApiParameterJSON[] } {
return {
@@ -213,7 +213,7 @@ export class ApiNodeJSONEncoder {
public static encodeTypeParameterList(
model: ApiModel,
item: ApiTypeParameterListMixin & ApiDeclaredItem,
item: ApiDeclaredItem & ApiTypeParameterListMixin,
version: string,
): ApiTypeParameterListJSON {
return {

View File

@@ -1,13 +1,13 @@
import type { TypeParameter, ApiModel, ApiItem } from '@microsoft/api-extractor-model';
import { type TokenDocumentation, genToken } from './parse';
import { type DocBlockJSON, block } from './tsdoc/CommentBlock';
import { type TokenDocumentation, genToken } from './parse.js';
import { type DocBlockJSON, block } from './tsdoc/CommentBlock.js';
export interface TypeParameterData {
name: string;
commentBlock: DocBlockJSON | null;
constraintTokens: TokenDocumentation[];
defaultTokens: TokenDocumentation[];
name: string;
optional: boolean;
commentBlock: DocBlockJSON | null;
}
export function generateTypeParamData(

View File

@@ -1,4 +1,4 @@
export * from './ApiNodeJSONEncoder';
export * from './parse';
export * from './tsdoc';
export * from './TypeParameterJSONEncoder';
export * from './ApiNodeJSONEncoder.js';
export * from './parse.js';
export * from './tsdoc/index.js';
export * from './TypeParameterJSONEncoder.js';

View File

@@ -14,8 +14,8 @@ import {
} from '@microsoft/api-extractor-model';
import type { DocNode, DocParagraph, DocPlainText } from '@microsoft/tsdoc';
import { type Meaning, ModuleSource } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';
import { createCommentNode } from './tsdoc';
import type { DocBlockJSON } from './tsdoc/CommentBlock';
import type { DocBlockJSON } from './tsdoc/CommentBlock.js';
import { createCommentNode } from './tsdoc/index.js';
export function findPackage(model: ApiModel, name: string): ApiPackage | undefined {
return (model.findMembersByName(name)[0] ?? model.findMembersByName(`@discordjs/${name}`)[0]) as
@@ -54,6 +54,7 @@ export function generatePath(items: readonly ApiItem[], version: string) {
}
}
// eslint-disable-next-line prefer-named-capture-group, unicorn/no-unsafe-regex
return path.replace(/@discordjs\/(.*)\/(.*)?/, `$1/${version}/$2`);
}
@@ -70,26 +71,22 @@ export function resolveDocComment(item: ApiDocumentedItem) {
const { summarySection } = tsdocComment;
function recurseNodes(nodes: readonly DocNode[] | undefined): string | null {
if (!nodes) {
function recurseNodes(node: DocNode | undefined): string | null {
if (!node) {
return null;
}
for (const node of nodes) {
switch (node.kind) {
case 'Paragraph':
return recurseNodes((node as DocParagraph).nodes);
case 'PlainText':
return (node as DocPlainText).text;
default:
return null;
}
switch (node.kind) {
case 'Paragraph':
return recurseNodes(node as DocParagraph);
case 'PlainText':
return (node as DocPlainText).text;
default:
return null;
}
return null;
}
return recurseNodes(summarySection.nodes);
return recurseNodes(summarySection);
}
export function findReferences(model: ApiModel, excerpt: Excerpt) {
@@ -107,6 +104,7 @@ export function findReferences(model: ApiModel, excerpt: Excerpt) {
break;
}
default:
break;
}
@@ -142,16 +140,16 @@ export function getProperties(item: ApiItem) {
}
export interface TokenDocumentation {
text: string;
path: string | null;
kind: string;
path: string | null;
text: string;
}
export interface ParameterDocumentation {
name: string;
isOptional: boolean;
tokens: TokenDocumentation[];
name: string;
paramCommentBlock: DocBlockJSON | null;
tokens: TokenDocumentation[];
}
function createDapiTypesURL(meaning: Meaning, name: string) {
@@ -174,7 +172,7 @@ export function genReference(item: ApiItem, version: string) {
export function genToken(model: ApiModel, token: ExcerptToken, version: string) {
if (token.canonicalReference) {
// @ts-expect-error
// @ts-expect-error: Symbol is not publicly accessible
token.canonicalReference._navigation = '.';
}

View File

@@ -1,8 +1,8 @@
import type { ApiModel, ApiItem } from '@microsoft/api-extractor-model';
import type { DocBlock } from '@microsoft/tsdoc';
import { blockTag, type DocBlockTagJSON } from './CommentBlockTag.js';
import { type AnyDocNodeJSON, type DocNodeJSON, node } from './CommentNode.js';
import { createCommentNode } from '.';
import { blockTag, type DocBlockTagJSON } from './CommentBlockTag';
import { type AnyDocNodeJSON, type DocNodeJSON, node } from './CommentNode';
export interface DocBlockJSON extends DocNodeJSON {
content: AnyDocNodeJSON[];

View File

@@ -1,5 +1,5 @@
import type { DocBlockTag } from '@microsoft/tsdoc';
import { type DocNodeJSON, node } from './CommentNode';
import { type DocNodeJSON, node } from './CommentNode.js';
export interface DocBlockTagJSON extends DocNodeJSON {
tagName: string;

View File

@@ -1,5 +1,5 @@
import type { DocCodeSpan } from '@microsoft/tsdoc';
import { type DocNodeJSON, node } from './CommentNode';
import { type DocNodeJSON, node } from './CommentNode.js';
export interface DocCodeSpanJSON extends DocNodeJSON {
code: string;

View File

@@ -12,14 +12,14 @@ export interface DocNodeJSON {
}
export type AnyDocNodeJSON =
| DocNodeJSON
| DocPlainTextJSON
| DocNodeContainerJSON
| DocLinkTagJSON
| DocFencedCodeJSON
| DocBlockJSON
| DocCodeSpanJSON
| DocCommentJSON
| DocCodeSpanJSON;
| DocFencedCodeJSON
| DocLinkTagJSON
| DocNodeContainerJSON
| DocNodeJSON
| DocPlainTextJSON;
export function node(node: DocNode): DocNodeJSON {
return {

View File

@@ -1,7 +1,7 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocNodeContainer } from '@microsoft/tsdoc';
import { type AnyDocNodeJSON, type DocNodeJSON, node } from './CommentNode.js';
import { createCommentNode } from '.';
import { type AnyDocNodeJSON, type DocNodeJSON, node } from './CommentNode';
export interface DocNodeContainerJSON extends DocNodeJSON {
nodes: AnyDocNodeJSON[];

View File

@@ -1,5 +1,5 @@
import type { DocFencedCode } from '@microsoft/tsdoc';
import { type DocNodeJSON, node } from './CommentNode';
import { type DocNodeJSON, node } from './CommentNode.js';
export interface DocFencedCodeJSON extends DocNodeJSON {
code: string;

View File

@@ -1,17 +1,17 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocDeclarationReference, DocLinkTag } from '@microsoft/tsdoc';
import { type DocNodeJSON, node } from './CommentNode';
import { resolveName, generatePath } from '../parse';
import { resolveName, generatePath } from '../parse.js';
import { type DocNodeJSON, node } from './CommentNode.js';
interface LinkTagCodeLink {
name: string;
kind: string;
name: string;
path: string;
}
export interface DocLinkTagJSON extends DocNodeJSON {
text: string | null;
codeDestination: LinkTagCodeLink | null;
text: string | null;
urlDestination: string | null;
}

View File

@@ -1,6 +1,6 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocParamBlock } from '@microsoft/tsdoc';
import { block, type DocBlockJSON } from './CommentBlock';
import { block, type DocBlockJSON } from './CommentBlock.js';
interface DocParamBlockJSON extends DocBlockJSON {
name: string;

View File

@@ -1,5 +1,5 @@
import type { DocPlainText } from '@microsoft/tsdoc';
import { type DocNodeJSON, node } from './CommentNode';
import { type DocNodeJSON, node } from './CommentNode.js';
export interface DocPlainTextJSON extends DocNodeJSON {
text: string;

View File

@@ -1,14 +1,14 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocComment } from '@microsoft/tsdoc';
import { block, type DocBlockJSON } from './CommentBlock.js';
import { type DocNodeJSON, node } from './CommentNode.js';
import { createCommentNode } from '.';
import { block, type DocBlockJSON } from './CommentBlock';
import { type DocNodeJSON, node } from './CommentNode';
export interface DocCommentJSON extends DocNodeJSON {
summary: DocNodeJSON[];
remarks: DocNodeJSON[];
deprecated: DocNodeJSON[];
customBlocks: DocBlockJSON[];
deprecated: DocNodeJSON[];
remarks: DocNodeJSON[];
summary: DocNodeJSON[];
}
export function comment(comment: DocComment, model: ApiModel, version: string, parentItem?: ApiItem): DocCommentJSON {

View File

@@ -11,16 +11,15 @@ import {
type DocCodeSpan,
type DocParamBlock,
} from '@microsoft/tsdoc';
import { block } from './CommentBlock';
import { codeSpan } from './CommentCodeSpan';
import type { AnyDocNodeJSON } from './CommentNode';
import { node as _node } from './CommentNode';
import { nodeContainer } from './CommentNodeContainer';
import { fencedCode } from './FencedCodeCommentNode';
import { linkTagNode } from './LinkTagCommentNode';
import { paramBlock } from './ParamBlock';
import { plainTextNode } from './PlainTextCommentNode';
import { comment } from './RootComment';
import { block } from './CommentBlock.js';
import { codeSpan } from './CommentCodeSpan.js';
import { node as _node, type AnyDocNodeJSON } from './CommentNode.js';
import { nodeContainer } from './CommentNodeContainer.js';
import { fencedCode } from './FencedCodeCommentNode.js';
import { linkTagNode } from './LinkTagCommentNode.js';
import { paramBlock } from './ParamBlock.js';
import { plainTextNode } from './PlainTextCommentNode.js';
import { comment } from './RootComment.js';
export function createCommentNode(
node: DocNode,
@@ -51,13 +50,13 @@ export function createCommentNode(
}
}
export * from './CommentNode';
export * from './CommentNodeContainer';
export * from './CommentBlock';
export * from './CommentBlockTag';
export * from './CommentCodeSpan';
export * from './FencedCodeCommentNode';
export * from './LinkTagCommentNode';
export * from './ParamBlock';
export * from './PlainTextCommentNode';
export * from './RootComment';
export * from './CommentNode.js';
export * from './CommentNodeContainer.js';
export * from './CommentBlock.js';
export * from './CommentBlockTag.js';
export * from './CommentCodeSpan.js';
export * from './FencedCodeCommentNode.js';
export * from './LinkTagCommentNode.js';
export * from './ParamBlock.js';
export * from './PlainTextCommentNode.js';
export * from './RootComment.js';