Skip to content

Commit

Permalink
Update ESLint, add /httpcat, update /help. Fix /say with @everyone.
Browse files Browse the repository at this point in the history
Removed eslint-plugin-typescript and added eslint-plugin-react-hooks.
  • Loading branch information
retrixe committed Sep 29, 2019
1 parent b196a77 commit 84e1318
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 32 deletions.
33 changes: 24 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ module.exports = {
node: true,
browser: true
},
extends: ["plugin:react/recommended", "standard", "standard-react"],
plugins: ["react", "graphql", "@typescript-eslint/eslint-plugin"],
parser: "@typescript-eslint/parser",
extends: ['plugin:react/recommended', 'standard', 'standard-react'],
plugins: ['react', 'graphql', 'react-hooks', '@typescript-eslint'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json'
},
rules: {
'graphql/template-strings': ['error', {
env: 'apollo',
Expand All @@ -15,13 +18,25 @@ module.exports = {
{ encoding: 'utf8' }
)
}],
// React Hooks rules.
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

// TypeScript styling.
"@typescript-eslint/no-explicit-any": ["error"],
"@typescript-eslint/type-annotation-spacing": ["error"],
"@typescript-eslint/no-namespace": ["error"],
"@typescript-eslint/interface-name-prefix": ["error"],
"@typescript-eslint/no-angle-bracket-type-assertion": ["error"],
'@typescript-eslint/no-explicit-any': ['error'],
'@typescript-eslint/type-annotation-spacing': ['error'],
'@typescript-eslint/no-namespace': ['error'],
'@typescript-eslint/interface-name-prefix': ['error'],
'@typescript-eslint/no-angle-bracket-type-assertion': ['error'],
// Fix no-unused-vars.
"@typescript-eslint/no-unused-vars": ["error"]
'@typescript-eslint/no-unused-vars': ['error'],

// Make TypeScript ESLint less strict.
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/triple-slash-reference': 'off'
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"eslint": "^5.6.1",
"eslint-config-standard": "^12.0.0",
"eslint-config-standard-react": "^7.0.2",
"eslint-plugin-graphql": "^2.1.1",
"eslint-plugin-graphql": "^3.1.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react-hooks": "^2.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-typescript": "^0.12.0",
"graphql-schema-linter": "^0.0.28",
"husky": "^1.3.1",
"nodemon": "^1.18.7",
Expand Down
20 changes: 20 additions & 0 deletions server/bot/commands/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,23 @@ export const handleXkcd: Command = {
} catch (e) { return 'Failed to fetch an xkcd comic!\nhttps://xkcd.com/1348' }
}
}

export const handleHttpCat: Command = {
name: 'httpcat',
aliases: ['http.cat'],
opts: {
description: 'Get an HTTP cat from https://http.cat',
fullDescription: 'Get an HTTP cat from https://http.cat',
example: '/httpcat <HTTP error code>',
usage: '/httpcat 200',
argsRequired: false
},
generator: async (message, args) => {
if (isNaN(+args[0]) || args.length > 1) return 'Enter a valid HTTP status code!'

const req = await fetch('https://http.cat/' + args[0], { method: 'HEAD' })
if (req.status === 404) return 'Enter a valid HTTP status code!\nhttps://http.cat/404'

return 'https://http.cat/' + args[0]
}
}
4 changes: 3 additions & 1 deletion server/bot/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const generalHelp = {
\`/namemc\` - A Minecraft user's previous usernames and skin.
\`/astronomy-picture-of-the-day\` or \`/apod\`
\`/currency\` - Currency conversion (\`/help currency\`)
\`/xkcd\` - Get the latest or a random xkcd comic.`
\`/xkcd\` - Get the latest or a random xkcd comic.
\`/httpcat\` - Cats for HTTP status codes.`
}, {
name: '**Utilities.**', value: `
TP \`/request\` - Request a specific feature.
Expand All @@ -49,6 +50,7 @@ TP \`/request\` - Request a specific feature.
name: '**Administrative commands.**', value: `
\`/ban\`, \`/unban\`, \`/kick\`, \`/mute\` and \`/unmute\`
\`/addEmoji\`, \`/deleteEmoji\` and \`/editEmoji\`
\`/deleteChannel\` and \`/editChannel\`
\`/warn\` and \`/warnings\` | \`/clearwarns\` and \`/removewarn\`
\`/changeserverregion\` and \`/listserverregions\`
\`/purge\` - Bulk delete a set of messages.
Expand Down
20 changes: 16 additions & 4 deletions server/bot/commands/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,19 @@ export const handleSay: Command = {
args.shift()
if (args.join(' ') === 'pls adim me') args = ['no']
tempDB.say[message.channelMentions[0]] = (
await client.createMessage(message.channelMentions[0], args.join(' '))
await client.createMessage(message.channelMentions[0], {
content: args.join(' '),
disableEveryone: !(message.member && message.member.permission.has('mentionEveryone'))
})
).id
return
}
// Send the message.
if (args.join(' ') === 'pls adim me') args = ['no']
return args.join(' ')
return {
content: args.join(' '),
disableEveryone: !(message.member && message.member.permission.has('mentionEveryone'))
}
}
}

Expand Down Expand Up @@ -238,7 +244,10 @@ export const handleType: Command = {
args.join(' ').length * 120 > 8000 ? 8000 : args.join(' ').length * 120
)
tempDB.say[message.channelMentions[0]] = (
await client.createMessage(message.channelMentions[0], args.join(' '))
await client.createMessage(message.channelMentions[0], {
content: args.join(' '),
disableEveryone: !(message.member && message.member.permission.has('mentionEveryone'))
})
).id
return
}
Expand All @@ -248,7 +257,10 @@ export const handleType: Command = {
await (ms => new Promise(resolve => setTimeout(resolve, ms)))(
args.join(' ').length * 120 > 8000 ? 8000 : args.join(' ').length * 120
)
return args.join(' ')
return {
content: args.join(' '),
disableEveryone: !(message.member && message.member.permission.has('mentionEveryone'))
}
}
}

Expand Down
25 changes: 9 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2827,10 +2827,10 @@ eslint-plugin-es@^1.3.1:
eslint-utils "^1.3.0"
regexpp "^2.0.0"

eslint-plugin-graphql@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-graphql/-/eslint-plugin-graphql-2.1.1.tgz#dae5d597080075320ea8e98795056309ffe73a18"
integrity sha512-JT2paUyu3e9ZDnroSshwUMc6pKcnkfXTsZInX1+/rPotvqOLVLtdrx/cmfb7PTJwjiEAshwcpm3/XPdTpsKJPw==
eslint-plugin-graphql@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-graphql/-/eslint-plugin-graphql-3.1.0.tgz#ccf0d3c61961f6307170ac565c1fb0902dd4f11f"
integrity sha512-87HGS00aeBqGFiQZQGzSPzk1D59w+124F8CRIDATh3LJqce5RCTuUI4tcIqPeyY95YPBCIKwISksWUuA0nrgNw==
dependencies:
graphql-config "^2.0.1"
lodash "^4.11.1"
Expand Down Expand Up @@ -2868,6 +2868,11 @@ eslint-plugin-promise@^4.0.1:
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.0.1.tgz#2d074b653f35a23d1ba89d8e976a985117d1c6a2"
integrity sha512-Si16O0+Hqz1gDHsys6RtFRrW7cCTB6P7p3OJmKp3Y3dxpQE2qwOA7d3xnV+0mBmrPoi0RBnxlCKvqu70te6wjg==

eslint-plugin-react-hooks@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-2.1.1.tgz#b416390b642113f444ee175b667c3222a045a98e"
integrity sha512-AYitPYzwHyKpZKpzMH5sCkld68vP8wn29Lq716h4jk1ll9Gp4BBFoPq/iCjBBT35eXFJvOPjgMlvhIXFB0OhXg==

eslint-plugin-react@^7.10.0:
version "7.12.4"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.12.4.tgz#b1ecf26479d61aee650da612e425c53a99f48c8c"
Expand All @@ -2886,13 +2891,6 @@ eslint-plugin-standard@^4.0.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-4.0.0.tgz#f845b45109c99cd90e77796940a344546c8f6b5c"
integrity sha512-OwxJkR6TQiYMmt1EsNRMe5qG3GsbjlcOhbGUBY4LtavF9DsLaTcoR+j2Tdjqi23oUwKNUqX7qcn5fPStafMdlA==

eslint-plugin-typescript@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-typescript/-/eslint-plugin-typescript-0.12.0.tgz#e23d58cb27fe28e89fc641a1f20e8d862cb99aef"
integrity sha512-2+DNE8nTvdNkhem/FBJXLPSeMDOZL68vHHNfTbM+PBc5iAuwBe8xLSQubwKxABqSZDwUHg+mwGmv5c2NlImi0Q==
dependencies:
requireindex "~1.1.0"

eslint-scope@^4.0.0, eslint-scope@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
Expand Down Expand Up @@ -5988,11 +5986,6 @@ requireindex@^1.2.0:
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef"
integrity sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==

requireindex@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162"
integrity sha1-5UBLgVV+91225JxacgBIk/4D4WI=

resolve-from@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57"
Expand Down

0 comments on commit 84e1318

Please sign in to comment.