Skip to content

Commit

Permalink
refactor: use eslint-config-neon for packages. (#8579)
Browse files Browse the repository at this point in the history
Co-authored-by: Noel <buechler.noel@outlook.com>
  • Loading branch information
suneettipirneni and iCrawl authored Sep 1, 2022
1 parent 4bdb059 commit edadb9f
Show file tree
Hide file tree
Showing 219 changed files with 2,576 additions and 2,021 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"root": true,
"extends": "marine/prettier/node",
"extends": ["neon/common", "neon/node", "neon/typescript", "neon/prettier"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"rules": {
"@typescript-eslint/consistent-type-definitions": ["error", "interface"]
},
"ignorePatterns": ["**/dist/*"],
"env": {
"jest": true
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/__tests__/formatTag.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, test, expect } from 'vitest';
import { formatTag } from '../src';
import { formatTag } from '../src/index.js';

describe('Format Tag', () => {
test('GIVEN tag with a prefix THEN format tag to not contain the prefix', () => {
Expand Down
7 changes: 1 addition & 6 deletions packages/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,9 @@
},
"devDependencies": {
"@types/node": "^16.11.56",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"@vitest/coverage-c8": "^0.22.1",
"eslint": "^8.23.0",
"eslint-config-marine": "^9.4.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-config-neon": "^0.1.23",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "^0.33.0",
"typescript": "^4.8.2",
Expand Down
1 change: 1 addition & 0 deletions packages/actions/src/formatTag/formatTag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export function formatTag(tag: string) {
// eslint-disable-next-line unicorn/no-unsafe-regex, prefer-named-capture-group
const parsed = /(^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);

if (parsed?.groups) {
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/formatTag/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getInput, setOutput } from '@actions/core';
import { formatTag } from './formatTag';
import { formatTag } from './formatTag.js';

const tag = getInput('tag', { required: true });
const parsed = formatTag(tag);
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './formatTag/formatTag';
export * from './formatTag/formatTag.js';
8 changes: 1 addition & 7 deletions packages/api-extractor-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@
},
"devDependencies": {
"@types/node": "^16.11.56",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"eslint": "^8.23.0",
"eslint-config-marine": "^9.4.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-tsdoc": "^0.2.16",
"eslint-config-neon": "^0.1.23",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "^0.33.0",
"typescript": "^4.8.2",
Expand Down
54 changes: 27 additions & 27 deletions packages/api-extractor-utils/src/ApiNodeJSONEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,58 @@ 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;
path: string;
}

export interface InheritanceData {
parentKey: string;
parentName: string;
path: string;
parentKey: string;
}

export interface ApiInheritableJSON {
inheritanceData: InheritanceData | null;
}

export interface ApiItemJSON {
comment: AnyDocNodeJSON | null;
containerKey: string;
deprecated: DocNodeContainerJSON | null;
excerpt: string;
excerptTokens: TokenDocumentation[];
kind: string;
name: string;
path: string[];
referenceData: ReferenceData;
excerpt: string;
excerptTokens: TokenDocumentation[];
remarks: DocNodeContainerJSON | null;
summary: DocNodeContainerJSON | null;
deprecated: DocNodeContainerJSON | null;
comment: AnyDocNodeJSON | null;
containerKey: string;
path: string[];
}

export interface ApiPropertyItemJSON extends ApiItemJSON, ApiInheritableJSON {
optional: boolean;
propertyTypeTokens: TokenDocumentation[];
readonly: boolean;
optional: boolean;
}

export interface ApiTypeParameterListJSON {
typeParameters: ApiTypeParameterJSON[];
}

export interface ApiTypeParameterJSON {
name: string;
commentBlock: DocBlockJSON | null;
constraintTokens: TokenDocumentation[];
defaultTokens: TokenDocumentation[];
name: string;
optional: boolean;
commentBlock: DocBlockJSON | null;
}

export interface ApiParameterListJSON {
Expand All @@ -81,38 +81,38 @@ 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 {
typeTokens: TokenDocumentation[];
}

export interface EnumMemberData {
name: string;
initializerTokens: TokenDocumentation[];
name: string;
summary: DocNodeContainerJSON | null;
}

Expand All @@ -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 {
Expand Down Expand Up @@ -203,7 +203,7 @@ export class ApiNodeJSONEncoder {

public static encodeParameterList(
model: ApiModel,
item: ApiParameterListMixin & ApiDeclaredItem,
item: ApiDeclaredItem & ApiParameterListMixin,
version: string,
): { parameters: ApiParameterJSON[] } {
return {
Expand All @@ -213,7 +213,7 @@ export class ApiNodeJSONEncoder {

public static encodeTypeParameterList(
model: ApiModel,
item: ApiTypeParameterListMixin & ApiDeclaredItem,
item: ApiDeclaredItem & ApiTypeParameterListMixin,
version: string,
): ApiTypeParameterListJSON {
return {
Expand Down
8 changes: 4 additions & 4 deletions packages/api-extractor-utils/src/TypeParameterJSONEncoder.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
8 changes: 4 additions & 4 deletions packages/api-extractor-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
40 changes: 19 additions & 21 deletions packages/api-extractor-utils/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`);
}

Expand All @@ -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) {
Expand All @@ -107,6 +104,7 @@ export function findReferences(model: ApiModel, excerpt: Excerpt) {

break;
}

default:
break;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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 = '.';
}

Expand Down
4 changes: 2 additions & 2 deletions packages/api-extractor-utils/src/tsdoc/CommentBlock.ts
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion packages/api-extractor-utils/src/tsdoc/CommentBlockTag.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/api-extractor-utils/src/tsdoc/CommentCodeSpan.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 6 additions & 6 deletions packages/api-extractor-utils/src/tsdoc/CommentNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

1 comment on commit edadb9f

@vercel
Copy link

@vercel vercel bot commented on edadb9f Sep 1, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.