Skip to content

Commit

Permalink
chore: set up tslint (#60)
Browse files Browse the repository at this point in the history
chore: set up tslint
  • Loading branch information
veksen committed Aug 19, 2019
2 parents 8f740b8 + e7f1f07 commit adb2a92
Show file tree
Hide file tree
Showing 29 changed files with 211 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/generated/* linguist-vendored
generated/* linguist-vendored
2 changes: 1 addition & 1 deletion codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ overwrite: true
schema: "http://localhost:8000/___graphql"
documents: "src/**/*.graphql"
generates:
src/generated/graphql.ts:
generated/graphql.ts:
plugins:
- "typescript"
- "typescript-operations"
File renamed without changes.
111 changes: 111 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"develop": "gatsby develop",
"fetch-users": "node ./scripts/fetchUsers.js",
"format": "prettier --write src/**/*.{js,jsx}",
"lint": "tslint -c tslint.json '{src,scripts}/**/*.{js,ts,tsx}'",
"lint:fix": "npm run lint -- --fix",
"serve": "gatsby serve",
"start": "npm run develop",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\""
Expand Down Expand Up @@ -49,7 +51,8 @@
"react-helmet": "^5.2.1",
"react-highlight": "^0.12.0",
"react-perfect-scrollbar": "^1.5.3",
"styled-components": "^4.3.2"
"styled-components": "^4.3.2",
"typescript": "^3.5.3"
},
"devDependencies": {
"@graphql-codegen/cli": "^1.4.0",
Expand All @@ -65,6 +68,10 @@
"@types/styled-components": "^4.1.18",
"babel-plugin-styled-components": "^1.10.6",
"discord.js": "^11.5.1",
"prettier": "^1.18.2"
"prettier": "^1.18.2",
"tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-react-hooks": "^2.2.1"
}
}
4 changes: 2 additions & 2 deletions scripts/buildHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ module.exports = {
const avatar = target ? target.avatar : this.getDefaultAvatar(hash)

return {
name,
hash,
avatar,
hash,
name,
}
},
resolveAuthors(users, authors) {
Expand Down
6 changes: 5 additions & 1 deletion scripts/fetchUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,27 @@ const writeS = (content, dest) => {
}

client.once("ready", async () => {
// tslint:disable-next-line no-console
console.log("Bot ready, fetching user list...")
const tph = client.guilds.get(TPH)
if (!tph) {
throw Error("Bot is not in TPH, cannot fetch users")
}
const guild = await tph.fetchMembers()
const memberInfo = guild.members.map(member => ({
identifier: `${member.user.username}#${member.user.discriminator}`,
avatar: member.user.displayAvatarURL,
identifier: `${member.user.username}#${member.user.discriminator}`,
}))
const wrs = fs.createWriteStream(DESTINATION)
// tslint:disable-next-line no-console
console.log(`Fetched ${memberInfo.length} users, writing to ${DESTINATION}`)
writeS(memberInfo, wrs).on("finish", () => {
// tslint:disable-next-line no-console
console.log("Finished writing list")
process.exit(0)
})
})

// tslint:disable-next-line no-console
console.log("Attempting to log in...")
client.login(process.env.BOT_TOKEN)
8 changes: 4 additions & 4 deletions src/SidebarProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React, { useState } from "react"

interface SidebarProviderProps {
interface ISidebarProviderProps {
children: React.ReactNode
}

export interface SidebarContextInterface {
export interface ISidebarContextInterface {
current: number
setCurrent: (index: number) => void
}

export const SidebarContext = React.createContext<SidebarContextInterface | null>(
export const SidebarContext = React.createContext<ISidebarContextInterface | null>(
null
)

export function SidebarProvider({
children,
}: SidebarProviderProps): JSX.Element {
}: ISidebarProviderProps): JSX.Element {
const [current, setCurrent] = useState(0)

function selectFirstLevel(index: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import * as SC from "./styles"
import { Container } from "../Container"
import * as SC from "./styles"

export function Footer() {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link } from "gatsby"
import React, { PropsWithChildren } from "react"
import { Container } from "../Container"
import logo from "../../images/tph-logo.png"
import { Container } from "../Container"
import * as SC from "./styles"

function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
* See: https://www.gatsbyjs.org/docs/use-static-query/
*/

import { graphql, useStaticQuery } from "gatsby"
import React, { PropsWithChildren } from "react"
import { useStaticQuery, graphql } from "gatsby"

import Scrollbar from "react-perfect-scrollbar"
import "react-perfect-scrollbar/dist/css/styles.css"
import { GlobalStyles } from "../../globalStyles"
import { Container } from "../Container"
import { Footer } from "../Footer"
import { Header } from "../Header"
import { GlobalStyles } from "../../globalStyles"
import * as SC from "./styles"
import Scrollbar from "react-perfect-scrollbar"
import "react-perfect-scrollbar/dist/css/styles.css"

export function Layout({ children }: PropsWithChildren<{}>) {
const data = useStaticQuery(graphql`
Expand Down
8 changes: 4 additions & 4 deletions src/components/Markdown/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react"
import * as SC from "./styles"
import Prism from "prismjs"
import "prismjs/components/prism-python"
import "prismjs/components/prism-markup-templating"
import "prismjs/components/prism-php"
import "prismjs/components/prism-python"
import "prismjs/plugins/line-numbers/prism-line-numbers.css"
import React from "react"
import * as SC from "./styles"

interface MarkdownProps {
interface IMarkdownProps {
content: string
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/ResourceBreadcrumb/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react"

import { IFileOrFolder } from "../ResourcesSidebar/index"
import ChevronUp from "../../icons/chevron-up.svg"
import { traversePaths } from "../../utils"
import { IFileOrFolder } from "../ResourcesSidebar/index"
import * as SC from "./styles"

interface ResourceBreadcrumbProps {
interface IResourceBreadcrumbProps {
relativePath: any
}

Expand All @@ -24,7 +24,7 @@ function flatten([
return flatten([...currNode.children, ...previousNodes, currNode])
}

export function ResourceBreadcrumb({ relativePath }: ResourceBreadcrumbProps) {
export function ResourceBreadcrumb({ relativePath }: IResourceBreadcrumbProps) {
const paths = relativePath.split("/")
const breadcrumbItems = flatten([traversePaths(paths)])

Expand Down
2 changes: 1 addition & 1 deletion src/components/ResourceBreadcrumb/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "styled-components"
import { Link } from "gatsby"
import styled from "styled-components"

export const ResourceBreadcrumbWrapper = styled.div`
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions src/components/ResourceHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { Fragment } from "react"

import { StackedAvatars } from "../StackedAvatars"
import ChevronUp from "../../icons/chevron-up.svg"
import { ResourceBreadcrumb } from "../ResourceBreadcrumb"
import { StackedAvatars } from "../StackedAvatars"
import * as SC from "./styles"

interface ResourceHeaderProps {
interface IResourceHeaderProps {
relativePath: any
title: any
authors: any
Expand Down
2 changes: 1 addition & 1 deletion src/components/ResourceHeader/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled, { css } from "styled-components"
import { Link } from "gatsby"
import styled, { css } from "styled-components"
import { fontFamily, modularScale } from "../../design/typography"

export const ResourceHeaderWrapper = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion src/components/ResourcesLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import React, { PropsWithChildren } from "react"

import { GlobalStyles } from "../../globalStyles"
import { SidebarProvider } from "../../SidebarProvider"
import { ResourcesSidebar } from "../ResourcesSidebar"
import * as SC from "./styles"
import { SidebarProvider } from "../../SidebarProvider"

export function ResourcesLayout({ children }: PropsWithChildren<{}>) {
return (
Expand Down
10 changes: 5 additions & 5 deletions src/components/ResourcesSidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState, PropsWithChildren } from "react"
import { useStaticQuery, graphql, Link } from "gatsby"
import useBuildTree from "./useBuildTree"
import useSidebar from "./../../hooks/useSidebar"
import Banner from "../../images/tph-banner.svg"
import { graphql, Link, useStaticQuery } from "gatsby"
import React, { PropsWithChildren, useState } from "react"
import TriangleDown from "../../icons/triangle-down.svg"
import Banner from "../../images/tph-banner.svg"
import useSidebar from "./../../hooks/useSidebar"
import * as SC from "./styles"
import useBuildTree from "./useBuildTree"

export interface IFile {
title: string
Expand Down
2 changes: 1 addition & 1 deletion src/components/ResourcesSidebar/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "styled-components"
import { Link } from "gatsby"
import styled from "styled-components"
import ChevronUp from "../../icons/chevron-up.svg"

export const ResourcesSidebarWrapper = styled.div`
Expand Down
Loading

0 comments on commit adb2a92

Please sign in to comment.