Skip to content

Commit

Permalink
build: refactor linting setup
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Aug 24, 2023
1 parent 788888a commit fb81f7b
Show file tree
Hide file tree
Showing 103 changed files with 1,545 additions and 971 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ dist-docs

# Miscellaneous
.tmp
.vscode
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
!packages/create-discord-bot/template/**/.vscode
.idea
.DS_Store
.turbo
Expand Down
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.useESLintClass": false,
"eslint.experimental.useFlatConfig": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": false
"source.organizeImports": false,
"source.fixAll.eslint": true,
"source.fixAll": true
},
"editor.trimAutoWhitespace": false,
"files.associations": {
Expand Down
105 changes: 105 additions & 0 deletions .yarn/patches/eslint-plugin-i-npm-2.28.0-2-4a8edfc1f1.patch

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/guide/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/** @type {import('prettier').Config} */
module.exports = require('../../.prettierrc.json');
12 changes: 6 additions & 6 deletions apps/guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/html-escaper": "^3.0.0",
"@types/node": "18.17.6",
"@types/react": "^18.2.20",
"@types/node": "18.17.9",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@unocss/cli": "^0.55.2",
"@unocss/eslint-plugin": "^0.55.2",
Expand All @@ -81,18 +81,18 @@
"concurrently": "^8.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.54",
"eslint-config-neon": "^0.1.56",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^10.10.4",
"happy-dom": "^10.11.0",
"hast-util-to-string": "^2.0.0",
"hastscript": "^8.0.0",
"html-escaper": "^3.0.3",
"lighthouse": "^11.0.0",
"prettier": "^3.0.2",
"turbo": "^1.10.12",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"unocss": "^0.55.2",
"vercel": "^32.0.0",
"vercel": "^32.0.1",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/app/_global-error.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { Providers } from './providers';
import { inter } from '~/util/fonts';
import { Providers } from './providers';

export default function GlobalError({ error }: { readonly error: Error }) {
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/app/guide/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { allContents } from 'contentlayer/generated';
import { notFound } from 'next/navigation';
import { allContents } from 'contentlayer/generated';
import { Mdx } from '~/components/Mdx';

export async function generateStaticParams() {
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/app/guide/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PropsWithChildren } from 'react';
import { Providers } from './providers';
import Footer from '~/components/Footer';
import Header from '~/components/Header';
import { Nav } from '~/components/Nav';
import { Providers } from './providers';

export default function Layout({ children }: PropsWithChildren) {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Analytics } from '@vercel/analytics/react';
import type { Metadata } from 'next';
import type { PropsWithChildren } from 'react';
import { Providers } from './providers';
import { DESCRIPTION } from '~/util/constants';
import { inter, jetBrainsMono } from '~/util/fonts';
import { Providers } from './providers';

import '@unocss/reset/tailwind-compat.css';
import '~/styles/unocss.css';
Expand Down
4 changes: 2 additions & 2 deletions apps/guide/src/components/Mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import { Alert, Section, DiscordMessages, DiscordMessage, DiscordMessageEmbed } from '@discordjs/ui';
import { useMDXComponent } from 'next-contentlayer/hooks';
import { DocsLink } from '~/components/DocsLink';
import { ResultingCode } from '~/components/ResultingCode';
import { DiscordAPITypesLink } from './DiscordAPITypesLink';
import { H1 } from './H1';
import { H2 } from './H2';
import { H3 } from './H3';
import { H4 } from './H4';
import { DocsLink } from '~/components/DocsLink';
import { ResultingCode } from '~/components/ResultingCode';

export function Mdx({ code }: { readonly code: string }) {
const Component = useMDXComponent(code);
Expand Down
2 changes: 1 addition & 1 deletion apps/guide/src/components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import { Scrollbars } from 'react-custom-scrollbars-2';
import { Sidebar } from './Sidebar';
import { useNav } from '~/contexts/nav';
import { Sidebar } from './Sidebar';

export function Nav() {
const { opened } = useNav();
Expand Down
4 changes: 2 additions & 2 deletions apps/guide/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client';

import { allContents } from 'contentlayer/generated';
import type { Route } from 'next';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { Section } from './Section';
import { allContents } from 'contentlayer/generated';
import { useNav } from '~/contexts/nav';
import { Section } from './Section';

const items = allContents.map((content) => ({
title: content.title,
Expand Down
16 changes: 1 addition & 15 deletions apps/guide/tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,5 @@
"compilerOptions": {
"allowJs": true
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.cjs",
"**/*.mjs",
"**/*.jsx",
"**/*.test.ts",
"**/*.test.js",
"**/*.test.mjs",
"**/*.spec.ts",
"**/*.spec.js",
"**/*.spec.mjs"
],
"exclude": []
"include": ["*.ts", "*.js", "*.cjs", "*.mjs", "src"]
}
12 changes: 6 additions & 6 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"@next/bundle-analyzer": "^13.4.19",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/node": "18.17.6",
"@types/react": "^18.2.20",
"@types/node": "18.17.9",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@unocss/cli": "^0.55.2",
"@unocss/eslint-plugin": "^0.55.2",
Expand All @@ -91,14 +91,14 @@
"cpy-cli": "^5.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint-config-neon": "^0.1.54",
"eslint-config-neon": "^0.1.56",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^10.10.4",
"happy-dom": "^10.11.0",
"lighthouse": "^11.0.0",
"prettier": "^3.0.2",
"turbo": "^1.10.12",
"turbo": "^1.10.13",
"typescript": "^5.1.6",
"vercel": "^32.0.0",
"vercel": "^32.0.1",
"vitest": "^0.34.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/app/_global-error.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import { Analytics } from '@vercel/analytics/react';
import { Providers } from './providers';
import { inter } from '~/util/fonts';
import { Providers } from './providers';

import '@unocss/reset/tailwind-compat.css';
import '~/styles/unocss.css';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { ApiModel } from '@microsoft/api-extractor-model';
import dynamic from 'next/dynamic';
import { notFound } from 'next/navigation';
import type { PropsWithChildren } from 'react';
import { Providers } from './providers';
import { fetchModelJSON, fetchVersions } from '~/app/docAPI';
import { Banner } from '~/components/Banner';
import { CmdKDialog } from '~/components/CmdK';
import { Nav } from '~/components/Nav';
import type { SidebarSectionItemData } from '~/components/Sidebar';
import { resolveItemURI } from '~/components/documentation/util';
import { N_RECENT_VERSIONS, PACKAGES } from '~/util/constants';
import { Providers } from './providers';

const Header = dynamic(async () => import('~/components/Header'));
const Footer = dynamic(async () => import('~/components/Footer'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { MDXRemote } from 'next-mdx-remote/rsc';
import rehypeRaw from 'rehype-raw';
import rehypeSlug from 'rehype-slug';
import remarkGfm from 'remark-gfm';
import type { VersionRouteParams } from './layout';
import { SyntaxHighlighter } from '~/components/SyntaxHighlighter';
import type { VersionRouteParams } from './layout';

async function loadREADME(packageName: string) {
return readFile(join(process.cwd(), 'src', 'assets', 'readme', packageName, 'home-README.md'), 'utf8');
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Analytics } from '@vercel/analytics/react';
import type { Metadata } from 'next';
import type { PropsWithChildren } from 'react';
import { Providers } from './providers';
import { DESCRIPTION } from '~/util/constants';
import { inter, jetBrainsMono } from '~/util/fonts';
import { Providers } from './providers';

import '@unocss/reset/tailwind-compat.css';
import '~/styles/unocss.css';
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/ExcerptText.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ApiModel, Excerpt } from '@microsoft/api-extractor-model';
import { ExcerptTokenKind } from '@microsoft/api-extractor-model';
import { DISCORD_API_TYPES_DOCS_URL } from '~/util/constants';
import { ItemLink } from './ItemLink';
import { resolveItemURI } from './documentation/util';
import { DISCORD_API_TYPES_DOCS_URL } from '~/util/constants';

export interface ExcerptTextProps {
/**
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import dynamic from 'next/dynamic';
import { Scrollbars } from 'react-custom-scrollbars-2';
import { useNav } from '~/contexts/nav';
import { Sidebar } from './Sidebar';
import type { SidebarSectionItemData } from './Sidebar';
import { useNav } from '~/contexts/nav';

const PackageSelect = dynamic(async () => import('./PackageSelect'));
const VersionSelect = dynamic(async () => import('./VersionSelect'));
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/ParameterTable.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ApiDocumentedItem, ApiParameterListMixin } from '@microsoft/api-extractor-model';
import { useMemo } from 'react';
import { resolveParameters } from '~/util/model';
import { ExcerptText } from './ExcerptText';
import { Table } from './Table';
import { TSDoc } from './documentation/tsdoc/TSDoc';
import { resolveParameters } from '~/util/model';

const columnStyles = {
Name: 'font-mono whitespace-nowrap',
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/PropertyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {
} from '@microsoft/api-extractor-model';
import { ApiItemKind } from '@microsoft/api-extractor-model';
import { Fragment, useMemo } from 'react';
import { Property } from './Property';
import { resolveMembers } from '~/util/members';
import { Property } from './Property';

export function isPropertyLike(item: ApiItem): item is ApiProperty | ApiPropertySignature {
return item.kind === ApiItemKind.Property || item.kind === ApiItemKind.PropertySignature;
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
import { VscSymbolVariable } from '@react-icons/all-files/vsc/VscSymbolVariable';
import { useSelectedLayoutSegment } from 'next/navigation';
import { useMemo } from 'react';
import { useNav } from '~/contexts/nav';
import { ItemLink } from './ItemLink';
import { Section } from './Section';
import { useNav } from '~/contexts/nav';

export interface SidebarSectionItemData {
href: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { ApiConstructor } from '@microsoft/api-extractor-model';
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
import { CodeHeading } from '~/components/CodeHeading';
import { ParameterTable } from '../../ParameterTable';
import { TSDoc } from '../tsdoc/TSDoc';
import { parametersString } from '../util';
import { DocumentationSection } from './DocumentationSection';
import { CodeHeading } from '~/components/CodeHeading';

export function ConstructorSection({ item }: { readonly item: ApiConstructor }) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type {
import { ApiItemKind } from '@microsoft/api-extractor-model';
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
import { useMemo, Fragment } from 'react';
import { resolveMembers } from '~/util/members';
import { Method } from '../../model/method/Method';
import { DocumentationSection } from './DocumentationSection';
import { resolveMembers } from '~/util/members';

function isMethodLike(item: ApiItem): item is ApiMethod | ApiMethodSignature {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/documentation/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type {
ApiDocumentedItem,
ApiParameterListMixin,
} from '@microsoft/api-extractor-model';
import type { TableOfContentsSerialized } from '../TableOfContentItems';
import { METHOD_SEPARATOR, OVERLOAD_SEPARATOR } from '~/util/constants';
import { resolveMembers } from '~/util/members';
import { resolveParameters } from '~/util/model';
import type { TableOfContentsSerialized } from '../TableOfContentItems';

export function hasProperties(item: ApiItemContainerMixin) {
return resolveMembers(item, memberPredicate).some(
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/model/enum/EnumMember.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ApiEnumMember } from '@microsoft/api-extractor-model';
import { CodeHeading } from '~/components/CodeHeading';
import { SignatureText } from '../../SignatureText';
import { TSDoc } from '../../documentation/tsdoc/TSDoc';
import { CodeHeading } from '~/components/CodeHeading';

export function EnumMember({ member }: { readonly member: ApiEnumMember }) {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/util/fetchMember.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { addPackageToModel } from '@discordjs/scripts';
import { ApiModel, ApiFunction } from '@microsoft/api-extractor-model';
import { notFound } from 'next/navigation';
import { fetchModelJSON } from '~/app/docAPI';
import { OVERLOAD_SEPARATOR, PACKAGES } from './constants';
import { findMember, findMemberByKey } from './model';
import { fetchModelJSON } from '~/app/docAPI';

export interface ItemRouteParams {
item: string;
Expand Down
16 changes: 1 addition & 15 deletions apps/website/tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,5 @@
"compilerOptions": {
"allowJs": true
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.cjs",
"**/*.mjs",
"**/*.jsx",
"**/*.test.ts",
"**/*.test.js",
"**/*.test.mjs",
"**/*.spec.ts",
"**/*.spec.js",
"**/*.spec.mjs"
],
"exclude": []
"include": ["*.ts", "*.tsx", "*.js", "*.cjs", "*.mjs", "src", "scripts"]
}
Loading

1 comment on commit fb81f7b

@vercel
Copy link

@vercel vercel bot commented on fb81f7b Aug 24, 2023

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.