chore(lint): small clean up of lint errors wip on #312

This commit is contained in:
Jean-Philippe Sirois
2020-08-26 19:39:27 -04:00
parent c2d58941c5
commit 2a974cc598
24 changed files with 61 additions and 40 deletions
+6 -3
View File
@@ -15,9 +15,15 @@ module.exports = {
extends: [ extends: [
"eslint:recommended", "eslint:recommended",
"plugin:react/recommended", "plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier", "prettier",
"prettier/@typescript-eslint", "prettier/@typescript-eslint",
], ],
settings: {
react: {
version: "16.13.1",
},
},
parser: "@typescript-eslint/parser", parser: "@typescript-eslint/parser",
parserOptions: { parserOptions: {
project: "tsconfig.json", project: "tsconfig.json",
@@ -185,7 +191,6 @@ module.exports = {
"no-var": "error", "no-var": "error",
"object-shorthand": "error", "object-shorthand": "error",
"one-var": ["error", "never"], "one-var": ["error", "never"],
"prefer-arrow/prefer-arrow-functions": "error",
"prefer-const": "error", "prefer-const": "error",
"prefer-object-spread": "error", "prefer-object-spread": "error",
"quote-props": "off", "quote-props": "off",
@@ -208,9 +213,7 @@ module.exports = {
"error", "error",
{ {
rules: { rules: {
"object-curly-spacing": true,
"prefer-conditional-expression": true, "prefer-conditional-expression": true,
"react-hooks-nesting": true,
typedef: [ typedef: [
true, true,
"parameter", "parameter",
+9 -9
View File
@@ -8956,9 +8956,10 @@
} }
}, },
"eslint-plugin-react-hooks": { "eslint-plugin-react-hooks": {
"version": "1.7.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.1.0.tgz",
"integrity": "sha512-iXTCFcOmlWvw4+TOE8CLWj6yX1GwzT0Y6cUfHHZqWnSk144VmVIRcVGtUAzrLES7C798lmvnt02C7rxaOX1HNA==" "integrity": "sha512-36zilUcDwDReiORXmcmTc6rRumu9JIM3WjSvV0nclHoUQ0CNrX866EwONvLR/UqaeqFutbAnVu8PEmctdo2SRQ==",
"dev": true
}, },
"eslint-scope": { "eslint-scope": {
"version": "5.0.0", "version": "5.0.0",
@@ -10152,6 +10153,11 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
}, },
"eslint-plugin-react-hooks": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz",
"integrity": "sha512-iXTCFcOmlWvw4+TOE8CLWj6yX1GwzT0Y6cUfHHZqWnSk144VmVIRcVGtUAzrLES7C798lmvnt02C7rxaOX1HNA=="
},
"find-up": { "find-up": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
@@ -21886,12 +21892,6 @@
"integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==",
"dev": true "dev": true
}, },
"tslint-react-hooks": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/tslint-react-hooks/-/tslint-react-hooks-2.2.2.tgz",
"integrity": "sha512-gtwA14+WevNUtlBhvAD5Ukpxt2qMegYI7IDD8zN/3JXLksdLdEuU/T/oqlI1CtZhMJffqyNn+aqq2oUqUFXiNA==",
"dev": true
},
"tsparticles": { "tsparticles": {
"version": "1.14.0", "version": "1.14.0",
"resolved": "https://registry.npmjs.org/tsparticles/-/tsparticles-1.14.0.tgz", "resolved": "https://registry.npmjs.org/tsparticles/-/tsparticles-1.14.0.tgz",
+2 -2
View File
@@ -86,10 +86,10 @@
"eslint-plugin-jsdoc": "^30.2.1", "eslint-plugin-jsdoc": "^30.2.1",
"eslint-plugin-prefer-arrow": "^1.2.2", "eslint-plugin-prefer-arrow": "^1.2.2",
"eslint-plugin-react": "^7.20.5", "eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.1.0",
"gatsby-plugin-remove-trailing-slashes": "^2.3.3", "gatsby-plugin-remove-trailing-slashes": "^2.3.3",
"prettier": "^2.0.5", "prettier": "^2.0.5",
"tslint": "^6.1.2", "tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0", "tslint-config-prettier": "^1.18.0"
"tslint-react-hooks": "^2.2.2"
} }
} }
+4 -2
View File
@@ -1,4 +1,6 @@
/* globals module */
const DEFAULT_AVATAR_MODULO = 5 const DEFAULT_AVATAR_MODULO = 5
module.exports = { module.exports = {
findMarkdownLink(absolutePath) { findMarkdownLink(absolutePath) {
// We're assuming this path isn't going to change // We're assuming this path isn't going to change
@@ -28,7 +30,7 @@ module.exports = {
return `https://cdn.discordapp.com/embed/avatars/${avatar}.png` return `https://cdn.discordapp.com/embed/avatars/${avatar}.png`
}, },
resolveAuthor(users, author) { resolveAuthor(users, author) {
const target = users.find(user => user.identifier === author) const target = users.find((user) => user.identifier === author)
const [name, hash] = this.splitHash(author) const [name, hash] = this.splitHash(author)
const avatar = target ? target.avatar : this.getDefaultAvatar(hash) const avatar = target ? target.avatar : this.getDefaultAvatar(hash)
@@ -39,6 +41,6 @@ module.exports = {
} }
}, },
resolveAuthors(users, authors) { resolveAuthors(users, authors) {
return authors.map(author => this.resolveAuthor(users, author)) return authors.map((author) => this.resolveAuthor(users, author))
}, },
} }
+3 -5
View File
@@ -1,3 +1,5 @@
/* globals require, process, console */
/* eslint-disable @typescript-eslint/no-var-requires */
// This script will be ran periodically through CI // This script will be ran periodically through CI
// don't touch it // don't touch it
const Discord = require("discord.js") const Discord = require("discord.js")
@@ -22,27 +24,23 @@ const writeS = (content, dest) => {
} }
client.once("ready", async () => { client.once("ready", async () => {
// tslint:disable-next-line no-console
console.log("Bot ready, fetching user list...") console.log("Bot ready, fetching user list...")
const tph = client.guilds.cache.get(TPH) const tph = client.guilds.cache.get(TPH)
if (!tph) { if (!tph) {
throw Error("Bot is not in TPH, cannot fetch users") throw Error("Bot is not in TPH, cannot fetch users")
} }
const members = await tph.members.fetch() const members = await tph.members.fetch()
const memberInfo = members.map(member => ({ const memberInfo = members.map((member) => ({
avatar: member.user.displayAvatarURL(), avatar: member.user.displayAvatarURL(),
identifier: member.user.tag, identifier: member.user.tag,
})) }))
const wrs = fs.createWriteStream(DESTINATION) const wrs = fs.createWriteStream(DESTINATION)
// tslint:disable-next-line no-console
console.log(`Fetched ${memberInfo.length} users, writing to ${DESTINATION}`) console.log(`Fetched ${memberInfo.length} users, writing to ${DESTINATION}`)
writeS(memberInfo, wrs).on("finish", () => { writeS(memberInfo, wrs).on("finish", () => {
// tslint:disable-next-line no-console
console.log("Finished writing list") console.log("Finished writing list")
process.exit(0) process.exit(0)
}) })
}) })
// tslint:disable-next-line no-console
console.log("Attempting to log in...") console.log("Attempting to log in...")
client.login(BOT_TOKEN) client.login(BOT_TOKEN)
+1 -1
View File
@@ -24,7 +24,7 @@ export const SidebarProvider: FC = ({ children }) => {
} else { } else {
setCurrent(null) setCurrent(null)
} }
}, [location]) }, [location, getSecondLevel])
const memoizedContextValue = useMemo( const memoizedContextValue = useMemo(
() => ({ () => ({
+2 -2
View File
@@ -4,7 +4,7 @@ import React, { FC, HTMLAttributes } from "react"
import useBuildTree from "../../hooks/useBuildTree" import useBuildTree from "../../hooks/useBuildTree"
import { useLockBodyScroll } from "../../hooks/useLockBodyScroll" import { useLockBodyScroll } from "../../hooks/useLockBodyScroll"
import useSidebar from "../../hooks/useSidebar" import useSidebar from "../../hooks/useSidebar"
import { IAllArchivesQuery, IFileOrFolder } from "../../types" import { IFileOrFolder } from "../../types"
import { humanize } from "../../utils" import { humanize } from "../../utils"
import { Sidebar } from "../Sidebar" import { Sidebar } from "../Sidebar"
import * as SC from "./styles" import * as SC from "./styles"
@@ -50,7 +50,7 @@ export const ArchivesSidebar: FC<HTMLAttributes<HTMLDivElement>> = (props) => {
return ( return (
<Sidebar {...props}> <Sidebar {...props}>
{sortedTree.map((node) => ( {sortedTree.map((node) => (
<Tree item={node} /> <Tree item={node} key={node.path} />
))} ))}
</Sidebar> </Sidebar>
) )
+1 -1
View File
@@ -1,4 +1,4 @@
import React, { FC, Fragment } from "react" import React, { FC } from "react"
import * as SC from "./styles" import * as SC from "./styles"
interface IPossibleCorrections { interface IPossibleCorrections {
+1 -1
View File
@@ -100,7 +100,7 @@ export const FourZeroFourHint: FC<IFourZeroFourHint> = ({
return ( return (
<Fragment> <Fragment>
<SC.StyledDiv> <SC.StyledDiv>
<h3>Based off of "{search}" you may have meant:</h3> <h3>Based off of &quot;{search}&quot; you may have meant:</h3>
{found} {found}
</SC.StyledDiv> </SC.StyledDiv>
<ul> <ul>
+5 -3
View File
@@ -4,6 +4,7 @@ import { DiscordButton } from "../DiscordButton"
import { HomePartner } from "../HomePartner" import { HomePartner } from "../HomePartner"
import { WavesBottom, WavesTop } from "../Waves" import { WavesBottom, WavesTop } from "../Waves"
import * as SC from "./styles" import * as SC from "./styles"
import { OutMode, MoveDirection } from "react-particles-js"
interface IMenuItemProps { interface IMenuItemProps {
to: string to: string
@@ -33,6 +34,7 @@ export const Home: FC = () => {
<SC.StyledParticles <SC.StyledParticles
params={{ params={{
particles: { particles: {
/* eslint-disable-next-line id-blacklist */
number: { value: 5, density: { enable: true, value_area: 500 } }, number: { value: 5, density: { enable: true, value_area: 500 } },
color: { value: "#ffffff" }, color: { value: "#ffffff" },
opacity: { opacity: {
@@ -51,10 +53,10 @@ export const Home: FC = () => {
move: { move: {
enable: true, enable: true,
speed: 1.5, speed: 1.5,
direction: "top", direction: MoveDirection.top,
random: false, random: false,
straight: false, straight: false,
out_mode: "out", out_mode: OutMode.out,
bounce: false, bounce: false,
attract: { enable: false }, attract: { enable: false },
}, },
@@ -67,7 +69,7 @@ export const Home: FC = () => {
<Link to="/"> <Link to="/">
<SC.Logo /> <SC.Logo />
</Link> </Link>
<SC.Title>The Programmer's Hangout</SC.Title> <SC.Title>The Programmer&apos;s Hangout</SC.Title>
</SC.TitleWrapper> </SC.TitleWrapper>
<SC.Menu> <SC.Menu>
<MenuItem to="/about">about</MenuItem> <MenuItem to="/about">about</MenuItem>
+2
View File
@@ -67,6 +67,8 @@ const Language = memo(
} }
) )
Language.displayName = "Language"
function sortTree(tree: IFileOrFolder[]) { function sortTree(tree: IFileOrFolder[]) {
return sort((a, b) => a.title.localeCompare(b.title), tree) return sort((a, b) => a.title.localeCompare(b.title), tree)
} }
@@ -141,6 +141,8 @@ const FirstLevelFolder = memo(({ item }: { item: IFolder }) => {
) )
}) })
FirstLevelFolder.displayName = "FirstLevelFolder"
const ResourceList: FC<{ const ResourceList: FC<{
items: IFileOrFolder[] items: IFileOrFolder[]
setExpanded: React.Dispatch<React.SetStateAction<boolean>> setExpanded: React.Dispatch<React.SetStateAction<boolean>>
@@ -8,5 +8,5 @@ export default function useMatchingPath(path: string, callback: () => void) {
if (isMatchingPath(path)) { if (isMatchingPath(path)) {
callback() callback()
} }
}, []) }, [path, isMatchingPath, callback])
} }
+1 -1
View File
@@ -28,7 +28,7 @@ export const Sidebar: FC<PropsWithChildren<HTMLAttributes<HTMLDivElement>>> = (
<SC.Title to="/"> <SC.Title to="/">
The The
<br /> <br />
Programmer's Programmer&apos;s
<br /> <br />
Hangout Hangout
</SC.Title> </SC.Title>
+2 -2
View File
@@ -11,7 +11,7 @@ interface ITocProps {
} }
interface ITitle { interface ITitle {
prefix?: string prefix: string | null
title: string title: string
} }
@@ -20,7 +20,7 @@ function extractTitle(title: string): ITitle {
const rest = maybePrefix ? title.replace(maybePrefix[0], "") : title const rest = maybePrefix ? title.replace(maybePrefix[0], "") : title
return { return {
prefix: maybePrefix ? `${maybePrefix[0]} ` : undefined, prefix: maybePrefix ? `${maybePrefix[0]} ` : null,
title: rest.trim(), title: rest.trim(),
} }
} }
+1
View File
@@ -1,3 +1,4 @@
/* globals window */
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
export const useLocalStorage = (name: string, initialValue: string) => { export const useLocalStorage = (name: string, initialValue: string) => {
+1
View File
@@ -1,3 +1,4 @@
/* globals document */
import { useState } from "react" import { useState } from "react"
export const useLockBodyScroll = () => { export const useLockBodyScroll = () => {
+1 -1
View File
@@ -15,7 +15,7 @@ export const HomeLayout: FC<RouteComponentProps> = () => {
if (locked) { if (locked) {
unlock() unlock()
} }
}, [locked]) }, [locked, unlock])
return ( return (
<ThemeProvider> <ThemeProvider>
+6 -1
View File
@@ -9,7 +9,10 @@ import { SEO } from "../../components/SEO"
import { FourZeroFourHint } from "../../components/FourZeroFourHint" import { FourZeroFourHint } from "../../components/FourZeroFourHint"
import { FourZeroFour } from "../../components/FourZeroFour" import { FourZeroFour } from "../../components/FourZeroFour"
export default ({ data }: ComponentQuery<{ allFile: FileConnection }>) => ( // TODO: there has to be a better type for this
const FourZeroFourPage: React.FC<{ data: { allFile: FileConnection } }> = ({
data,
}: ComponentQuery<{ allFile: FileConnection }>) => (
<Fragment> <Fragment>
<SEO title="404: Archive Not found" /> <SEO title="404: Archive Not found" />
<FourZeroFour title="ARCHIVE NOT FOUND"> <FourZeroFour title="ARCHIVE NOT FOUND">
@@ -26,6 +29,8 @@ export default ({ data }: ComponentQuery<{ allFile: FileConnection }>) => (
</Fragment> </Fragment>
) )
export default FourZeroFourPage
export const query = graphql` export const query = graphql`
query { query {
allFile(filter: { sourceInstanceName: { eq: "what-is-archive" } }) { allFile(filter: { sourceInstanceName: { eq: "what-is-archive" } }) {
+1 -1
View File
@@ -17,7 +17,7 @@ function ArchivesPage() {
This regroups the archives of our occasional, temporary channels This regroups the archives of our occasional, temporary channels
that cover a piece of technology that might be unknown to part of that cover a piece of technology that might be unknown to part of
our users. You can find those on{" "} our users. You can find those on{" "}
<Link to="/about">The Programmer's Hangout</Link>. <Link to="/about">The Programmer&apos;s Hangout</Link>.
</p> </p>
} }
/> />
+6 -1
View File
@@ -8,7 +8,10 @@ import { FourZeroFourHint } from "../../components/FourZeroFourHint"
import { SEO } from "../../components/SEO" import { SEO } from "../../components/SEO"
import { FourZeroFour } from "../../components/FourZeroFour" import { FourZeroFour } from "../../components/FourZeroFour"
export default ({ data }: ComponentQuery<{ allFile: FileConnection }>) => ( // TODO: there has to be a better type for this
const FourZeroFourPage: React.FC<{ data: { allFile: FileConnection } }> = ({
data,
}: ComponentQuery<{ allFile: FileConnection }>) => (
<Fragment> <Fragment>
<SEO title="404: Resource Not found" /> <SEO title="404: Resource Not found" />
<FourZeroFour title="RESOURCE NOT FOUND"> <FourZeroFour title="RESOURCE NOT FOUND">
@@ -25,6 +28,8 @@ export default ({ data }: ComponentQuery<{ allFile: FileConnection }>) => (
</Fragment> </Fragment>
) )
export default FourZeroFourPage
export const query = graphql` export const query = graphql`
query { query {
allFile(filter: { sourceInstanceName: { eq: "resources" } }) { allFile(filter: { sourceInstanceName: { eq: "resources" } }) {
+1 -1
View File
@@ -18,7 +18,7 @@ function ResourcesPage() {
<p> <p>
This is meant as a small knowledge base for commonly answered This is meant as a small knowledge base for commonly answered
questions on our Discord community,{" "} questions on our Discord community,{" "}
<Link to="/about">The Programmer's Hangout</Link>. <Link to="/about">The Programmer&apos;s Hangout</Link>.
</p> </p>
<p> <p>
All of it is open source, and you can contribute to it on{" "} All of it is open source, and you can contribute to it on{" "}
+1 -1
View File
@@ -146,7 +146,7 @@ export function buildToc(headings: Mdx["headings"]): ITocItem[] {
return [] return []
} }
const strip = (value: string) => value.replace(/^(\d*\-)(.*)/, "$2") const strip = (value: string) => value.replace(/^(\d*-)(.*)/, "$2")
slugger.reset() slugger.reset()
+1 -1
View File
@@ -4,7 +4,7 @@
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["ES2019"], /* Specify library files to be included in the compilation. */ "lib": ["ES2019", "DOM"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */
"jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */