Copy formatting config from main repo
This commit is contained in:
parent
36fd94137b
commit
f6995f3e42
250
.eslintrc.json
250
.eslintrc.json
|
@ -1,250 +0,0 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint", "react"],
|
||||
"globals": {
|
||||
"powercord": true,
|
||||
"webpackChunkdiscord_app": true,
|
||||
"DiscordNative": false,
|
||||
"PowercordNative": false,
|
||||
"GLOBAL_ENV": true,
|
||||
"BigInt": false
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2021,
|
||||
"sourceType": "script",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"project": ["./tsconfig.json"]
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"browser": true
|
||||
},
|
||||
"rules": {
|
||||
"for-direction": [ "error" ],
|
||||
"getter-return": [ "error" ],
|
||||
"no-compare-neg-zero": [ "error" ],
|
||||
"no-cond-assign": [ "error" ],
|
||||
"no-constant-condition": [ "error" ],
|
||||
"no-control-regex": [ "error" ],
|
||||
"no-debugger": [ "error" ],
|
||||
"no-dupe-args": [ "error" ],
|
||||
"no-dupe-keys": [ "error" ],
|
||||
"no-duplicate-case": [ "error" ],
|
||||
"no-empty": [ "error", {
|
||||
"allowEmptyCatch": true
|
||||
}],
|
||||
"no-empty-character-class": [ "error" ],
|
||||
"no-extra-boolean-cast": [ "error" ],
|
||||
"@typescript-eslint/no-extra-semi": [ "error" ],
|
||||
"no-func-assign": [ "error" ],
|
||||
"no-invalid-regexp": [ "error" ],
|
||||
"no-irregular-whitespace": [ "error", {
|
||||
"skipStrings": true,
|
||||
"skipRegExps": true
|
||||
}],
|
||||
"no-obj-calls": [ "error" ],
|
||||
"no-regex-spaces": [ "error" ],
|
||||
"no-sparse-arrays": [ "error" ],
|
||||
"no-template-curly-in-string": [ "error" ],
|
||||
"no-unexpected-multiline": [ "error" ],
|
||||
"no-unreachable": [ "error" ],
|
||||
"no-unsafe-negation": [ "error" ],
|
||||
"use-isnan": [ "error" ],
|
||||
"valid-typeof": [ "error", {
|
||||
"requireStringLiterals": true
|
||||
}],
|
||||
"accessor-pairs": [ "error" ],
|
||||
"array-callback-return": [ "error", {
|
||||
"allowImplicit": true
|
||||
}],
|
||||
"curly": [ "error", "all" ],
|
||||
"dot-location": [ "error", "property" ],
|
||||
"@typescript-eslint/dot-notation": [ "error" ],
|
||||
"eqeqeq": [ "error", "always" ],
|
||||
"no-caller": [ "error" ],
|
||||
"no-case-declarations": [ "error" ],
|
||||
"no-else-return": [ "error", {
|
||||
"allowElseIf": true
|
||||
}],
|
||||
"@typescript-eslint/no-empty-function": [ "error" ],
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"no-empty-pattern": [ "error" ],
|
||||
"no-eq-null": [ "error" ],
|
||||
"no-eval": [ "error" ],
|
||||
"no-extend-native": [ "error" ],
|
||||
"no-extra-bind": [ "error" ],
|
||||
"no-extra-label": [ "error" ],
|
||||
"no-fallthrough": [ "error" ],
|
||||
"no-floating-decimal": [ "error" ],
|
||||
"no-global-assign": [ "error" ],
|
||||
"no-lone-blocks": [ "error" ],
|
||||
"no-multi-spaces": [ "error", {
|
||||
"exceptions": {
|
||||
"Property": true,
|
||||
"BinaryExpression": false,
|
||||
"VariableDeclarator": true
|
||||
}
|
||||
}],
|
||||
"no-multi-str": [ "error" ],
|
||||
"no-new-func": [ "error" ],
|
||||
"no-new-wrappers": [ "error" ],
|
||||
"no-octal": [ "error" ],
|
||||
"no-octal-escape": [ "error" ],
|
||||
"@typescript-eslint/no-redeclare": [ "error", {
|
||||
"builtinGlobals": true
|
||||
}],
|
||||
"no-return-await": [ "error" ],
|
||||
"no-self-assign": [ "error", {
|
||||
"props": true
|
||||
}],
|
||||
"no-self-compare": [ "error" ],
|
||||
"no-sequences": [ "error" ],
|
||||
"no-unmodified-loop-condition": [ "error" ],
|
||||
"@typescript-eslint/no-unused-expressions": [ "error" ],
|
||||
"no-unused-labels": [ "error" ],
|
||||
"no-useless-call": [ "error" ],
|
||||
"no-useless-concat": [ "error" ],
|
||||
"no-useless-escape": [ "error" ],
|
||||
"no-useless-return": [ "error" ],
|
||||
"no-warning-comments": [ "warn" ],
|
||||
"no-with": [ "error" ],
|
||||
"prefer-promise-reject-errors": ["error", {
|
||||
"allowEmptyReject": true
|
||||
}],
|
||||
"radix": [ "error", "as-needed" ],
|
||||
"wrap-iife": [ "error" ],
|
||||
"yoda": [ "error" ],
|
||||
"no-delete-var": [ "error" ],
|
||||
"no-shadow-restricted-names": [ "error" ],
|
||||
"no-undef": [ "error" ],
|
||||
"no-undef-init": [ "error" ],
|
||||
"no-undefined": [ "error" ],
|
||||
"@typescript-eslint/no-unused-vars": [ "error" ],
|
||||
"@typescript-eslint/no-use-before-define": [ "error" ],
|
||||
"callback-return": [ "error" ],
|
||||
"handle-callback-err": [ "error" ],
|
||||
"no-buffer-constructor": [ "error" ],
|
||||
"@typescript-eslint/no-var-requires": [ "off" ],
|
||||
"no-mixed-requires": [ "error" ],
|
||||
"array-bracket-newline": [ "error", "consistent" ],
|
||||
"array-bracket-spacing": [ "error", "always" ],
|
||||
"block-spacing": [ "error", "always" ],
|
||||
"@typescript-eslint/brace-style": [ "error", "1tbs" ],
|
||||
"@typescript-eslint/comma-dangle": [ "error" ],
|
||||
"@typescript-eslint/comma-spacing": [ "error", {
|
||||
"before": false,
|
||||
"after": true
|
||||
}],
|
||||
"comma-style": [ "error" ],
|
||||
"computed-property-spacing": [ "error" ],
|
||||
"consistent-this": [ "error", "_this" ],
|
||||
"eol-last": [ "error", "always" ],
|
||||
"@typescript-eslint/func-call-spacing": [ "error", "never" ],
|
||||
"func-name-matching": [ "error", "always" ],
|
||||
"@typescript-eslint/indent": [ "error", 2, {
|
||||
"SwitchCase": 1
|
||||
}],
|
||||
"@typescript-eslint/keyword-spacing": [ "error" ],
|
||||
"@typescript-eslint/lines-between-class-members": [ "error", "always", {
|
||||
"exceptAfterSingleLine": true
|
||||
}],
|
||||
"max-statements-per-line": [ "error", {
|
||||
"max": 2
|
||||
}],
|
||||
// "multiline-comment-style": [ "error" ],
|
||||
"multiline-ternary": [ "error", "always-multiline" ],
|
||||
"new-cap": [ "error", {
|
||||
"newIsCap": true
|
||||
}],
|
||||
"new-parens": [ "error" ],
|
||||
"@typescript-eslint/no-array-constructor": [ "error" ],
|
||||
"no-mixed-operators": [ "error" ],
|
||||
"no-mixed-spaces-and-tabs": [ "error" ],
|
||||
"no-multiple-empty-lines": [ "error" ],
|
||||
"no-new-object": [ "error" ],
|
||||
"no-tabs": [ "error" ],
|
||||
"no-trailing-spaces": [ "error" ],
|
||||
"no-unneeded-ternary": [ "error" ],
|
||||
"no-whitespace-before-property": [ "error" ],
|
||||
"@typescript-eslint/object-curly-spacing": [ "error", "always" ],
|
||||
"object-property-newline": [ "error" ],
|
||||
"one-var-declaration-per-line": [ "error", "initializations" ],
|
||||
"operator-assignment": [ "error", "always" ],
|
||||
"operator-linebreak": [ "error", "after", {
|
||||
"overrides": {
|
||||
"?": "before",
|
||||
":": "before"
|
||||
}
|
||||
}],
|
||||
"padded-blocks": [ "error", "never" ],
|
||||
"quote-props": [ "error", "as-needed" ],
|
||||
"@typescript-eslint/quotes": [ "error", "single" ],
|
||||
"@typescript-eslint/semi": [ "error", "always" ],
|
||||
"semi-spacing": [ "error", {
|
||||
"before": false,
|
||||
"after": true
|
||||
}],
|
||||
"semi-style": [ "error", "last" ],
|
||||
"@typescript-eslint/space-before-blocks": [ "error", "always" ],
|
||||
"@typescript-eslint/space-before-function-paren": [ "error", "always" ],
|
||||
"space-in-parens": [ "error", "never" ],
|
||||
"@typescript-eslint/space-infix-ops": [ "error" ],
|
||||
"space-unary-ops": [ "error", {
|
||||
"words": true,
|
||||
"nonwords": false
|
||||
}],
|
||||
"spaced-comment": [ "error", "always" ],
|
||||
"switch-colon-spacing": [ "error", {
|
||||
"before": false,
|
||||
"after": true
|
||||
}],
|
||||
"template-tag-spacing": [ "error", "always" ],
|
||||
"wrap-regex": [ "error" ],
|
||||
"arrow-body-style": [ "error", "as-needed" ],
|
||||
"arrow-spacing": [ "error", {
|
||||
"before": true,
|
||||
"after": true
|
||||
}],
|
||||
"constructor-super": [ "error" ],
|
||||
"no-class-assign": [ "error" ],
|
||||
"no-const-assign": [ "error" ],
|
||||
"@typescript-eslint/no-dupe-class-members": [ "error" ],
|
||||
"no-new-symbol": [ "error" ],
|
||||
"no-this-before-super": [ "error" ],
|
||||
"no-useless-computed-key": [ "error" ],
|
||||
"@typescript-eslint/no-useless-constructor": [ "error" ],
|
||||
"no-var": [ "error" ],
|
||||
"object-shorthand": [ "error", "always" ],
|
||||
"prefer-arrow-callback": [ "error" ],
|
||||
"prefer-const": [ "error", {
|
||||
"destructuring": "all"
|
||||
}],
|
||||
"prefer-destructuring": ["error", {
|
||||
"VariableDeclarator": {
|
||||
"array": false,
|
||||
"object": true
|
||||
},
|
||||
"AssignmentExpression": {
|
||||
"array": true,
|
||||
"object": true
|
||||
}
|
||||
}, {
|
||||
"enforceForRenamedProperties": false
|
||||
}],
|
||||
"prefer-numeric-literals": [ "error" ],
|
||||
"prefer-rest-params": [ "error" ],
|
||||
"prefer-spread": [ "error" ],
|
||||
"prefer-template": [ "error" ],
|
||||
"rest-spread-spacing": [ "error", "never" ],
|
||||
"symbol-description": [ "error" ],
|
||||
"template-curly-spacing": [ "error", "never" ],
|
||||
"react/jsx-uses-react": "error",
|
||||
"react/jsx-uses-vars": 1,
|
||||
"linebreak-style": ["error", "unix"]
|
||||
}
|
||||
}
|
54
.eslintrc.yml
Normal file
54
.eslintrc.yml
Normal file
|
@ -0,0 +1,54 @@
|
|||
root: true
|
||||
extends:
|
||||
- eslint-config-dmitmel/presets/node
|
||||
env:
|
||||
browser: true
|
||||
parser: "@typescript-eslint/parser"
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
plugins:
|
||||
- "@typescript-eslint"
|
||||
rules:
|
||||
func-names: off
|
||||
node/no-unsupported-features/es-syntax:
|
||||
- error
|
||||
- ignores:
|
||||
- modules
|
||||
- dynamicImport
|
||||
node/no-unsupported-features/es-builtins:
|
||||
- error
|
||||
- ignores:
|
||||
- globalThis
|
||||
node/no-unsupported-features/node-builtins:
|
||||
- error
|
||||
- ignores:
|
||||
- fs.promises
|
||||
|
||||
node/no-missing-require: off
|
||||
node/no-missing-import: off
|
||||
node/no-unpublished-import: off
|
||||
node/no-unpublished-require: off
|
||||
node/shebang: off
|
||||
no-process-exit: off
|
||||
|
||||
overrides:
|
||||
- files: "**/*.ts"
|
||||
extends: eslint-config-dmitmel/presets/typescript-addon
|
||||
rules:
|
||||
node/no-missing-import: off
|
||||
eqeqeq: off
|
||||
\@typescript-eslint/no-dynamic-delete: off
|
||||
no-return-assign: off
|
||||
no-void: off
|
||||
consistent-return: off
|
||||
|
||||
- files: "**/src/**/*.ts"
|
||||
extends: eslint-config-dmitmel/rules/typescript/with-type-checking
|
||||
|
||||
- files: "**/*.d.ts"
|
||||
rules:
|
||||
no-var: off
|
||||
|
||||
- files: "src/**/*.ts"
|
||||
parserOptions:
|
||||
project: tsconfig.json
|
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"EditorConfig.EditorConfig",
|
||||
"esbenp.prettier-vscode"
|
||||
]
|
||||
}
|
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
}
|
26
index.ts
26
index.ts
|
@ -1,26 +0,0 @@
|
|||
import { webpack, Injector } from 'replugged';
|
||||
import { AnyFunction } from 'replugged/src/types/util';
|
||||
|
||||
const inject = new Injector();
|
||||
|
||||
export async function start () {
|
||||
const typingMod = await webpack.waitForModule(webpack.filters.byProps('startTyping')) as {
|
||||
startTyping: AnyFunction
|
||||
};
|
||||
const getChannelMod = await webpack.waitForModule(webpack.filters.byProps('getChannel')) as {
|
||||
getChannel: (id: string) => {
|
||||
name: string;
|
||||
}
|
||||
};
|
||||
|
||||
if (typingMod && getChannelMod) {
|
||||
inject.instead(typingMod, 'startTyping', ([ channel ]) => {
|
||||
const channelObj = getChannelMod.getChannel(channel as string);
|
||||
console.log(`Typing prevented! Channel: #${(channelObj?.name ?? 'unknown')} (${channel}).`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function stop () {
|
||||
inject.uninjectAll();
|
||||
}
|
|
@ -10,5 +10,5 @@
|
|||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"type": "replugged-plugin",
|
||||
"renderer": "index.ts"
|
||||
"renderer": "src/index.ts"
|
||||
}
|
||||
|
|
16
package.json
16
package.json
|
@ -2,10 +2,19 @@
|
|||
"name": "plugin-template",
|
||||
"version": "1.0.0",
|
||||
"description": "A plugin template",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsx scripts/build.ts",
|
||||
"watch": "tsx scripts/build.ts --watch",
|
||||
"bundle": "asar p dist bundled.asar"
|
||||
"bundle": "asar p dist bundled.asar",
|
||||
"prettier:check": "prettier ./src ./scripts --check",
|
||||
"eslint:check": "eslint ./src ./scripts",
|
||||
"prettier:fix": "prettier ./src ./scripts --write",
|
||||
"eslint:fix": "eslint ./src ./scripts --fix",
|
||||
"lint": "pnpm run prettier:check && pnpm run eslint:check && pnpm run check",
|
||||
"lint:fix": "pnpm run prettier:fix && pnpm run eslint:fix"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
@ -18,8 +27,11 @@
|
|||
"@typescript-eslint/parser": "^5.40.1",
|
||||
"esbuild": "^0.15.11",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-config-dmitmel": "github:dmitmel/eslint-config-dmitmel",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-react": "^7.31.10",
|
||||
"replugged": "4.0.0-beta0.3",
|
||||
"prettier": "^2.8.1",
|
||||
"replugged": "4.0.0-beta0.4",
|
||||
"tsx": "^3.10.3",
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
|
|
14
perttierrc.json
Normal file
14
perttierrc.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"quoteProps": "as-needed",
|
||||
"jsxSingleQuote": false,
|
||||
"trailingComma": "all",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": true,
|
||||
"arrowParens": "always",
|
||||
"proseWrap": "always"
|
||||
}
|
|
@ -8,8 +8,11 @@ specifiers:
|
|||
'@typescript-eslint/parser': ^5.40.1
|
||||
esbuild: ^0.15.11
|
||||
eslint: ^8.25.0
|
||||
eslint-config-dmitmel: github:dmitmel/eslint-config-dmitmel
|
||||
eslint-plugin-node: ^11.1.0
|
||||
eslint-plugin-react: ^7.31.10
|
||||
replugged: 4.0.0-beta0.3
|
||||
prettier: ^2.8.1
|
||||
replugged: 4.0.0-beta0.4
|
||||
tsx: ^3.10.3
|
||||
typescript: ^4.8.4
|
||||
|
||||
|
@ -21,8 +24,11 @@ devDependencies:
|
|||
'@typescript-eslint/parser': 5.40.1_z4bbprzjrhnsfa24uvmcbu7f5q
|
||||
esbuild: 0.15.12
|
||||
eslint: 8.25.0
|
||||
eslint-config-dmitmel: github.com/dmitmel/eslint-config-dmitmel/690f1b1121d342fcc8ee511ca9f2af7502f53db6_eslint@8.25.0
|
||||
eslint-plugin-node: 11.1.0_eslint@8.25.0
|
||||
eslint-plugin-react: 7.31.10_eslint@8.25.0
|
||||
replugged: 4.0.0-beta0.3
|
||||
prettier: 2.8.1
|
||||
replugged: 4.0.0-beta0.4
|
||||
tsx: 3.10.4
|
||||
typescript: 4.8.4
|
||||
|
||||
|
@ -741,6 +747,32 @@ packages:
|
|||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/eslint-plugin-es/3.0.1_eslint@8.25.0:
|
||||
resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==}
|
||||
engines: {node: '>=8.10.0'}
|
||||
peerDependencies:
|
||||
eslint: '>=4.19.1'
|
||||
dependencies:
|
||||
eslint: 8.25.0
|
||||
eslint-utils: 2.1.0
|
||||
regexpp: 3.2.0
|
||||
dev: true
|
||||
|
||||
/eslint-plugin-node/11.1.0_eslint@8.25.0:
|
||||
resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==}
|
||||
engines: {node: '>=8.10.0'}
|
||||
peerDependencies:
|
||||
eslint: '>=5.16.0'
|
||||
dependencies:
|
||||
eslint: 8.25.0
|
||||
eslint-plugin-es: 3.0.1_eslint@8.25.0
|
||||
eslint-utils: 2.1.0
|
||||
ignore: 5.2.0
|
||||
minimatch: 3.1.2
|
||||
resolve: 1.22.1
|
||||
semver: 6.3.0
|
||||
dev: true
|
||||
|
||||
/eslint-plugin-react/7.31.10_eslint@8.25.0:
|
||||
resolution: {integrity: sha512-e4N/nc6AAlg4UKW/mXeYWd3R++qUano5/o+t+wnWxIf+bLsOaH3a4q74kX3nDjYym3VBN4HyO9nEn1GcAqgQOA==}
|
||||
engines: {node: '>=4'}
|
||||
|
@ -780,6 +812,13 @@ packages:
|
|||
estraverse: 5.3.0
|
||||
dev: true
|
||||
|
||||
/eslint-utils/2.1.0:
|
||||
resolution: {integrity: sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==}
|
||||
engines: {node: '>=6'}
|
||||
dependencies:
|
||||
eslint-visitor-keys: 1.3.0
|
||||
dev: true
|
||||
|
||||
/eslint-utils/3.0.0_eslint@8.25.0:
|
||||
resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==}
|
||||
engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0}
|
||||
|
@ -790,6 +829,11 @@ packages:
|
|||
eslint-visitor-keys: 2.1.0
|
||||
dev: true
|
||||
|
||||
/eslint-visitor-keys/1.3.0:
|
||||
resolution: {integrity: sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==}
|
||||
engines: {node: '>=4'}
|
||||
dev: true
|
||||
|
||||
/eslint-visitor-keys/2.1.0:
|
||||
resolution: {integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==}
|
||||
engines: {node: '>=10'}
|
||||
|
@ -1439,6 +1483,12 @@ packages:
|
|||
engines: {node: '>= 0.8.0'}
|
||||
dev: true
|
||||
|
||||
/prettier/2.8.1:
|
||||
resolution: {integrity: sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/prop-types/15.8.1:
|
||||
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
||||
dependencies:
|
||||
|
@ -1481,8 +1531,8 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/replugged/4.0.0-beta0.3:
|
||||
resolution: {integrity: sha512-gHhACP+MfFHLDrh8O//jL4RTSx2oHxdTgnVEFi1X26U+Sb+QbK+z388nU/dL9YJD8gKjzq9K2x1F5V8+Qv/7CA==}
|
||||
/replugged/4.0.0-beta0.4:
|
||||
resolution: {integrity: sha512-KZyzOXGw4Dl9kaU00UJDf+oSv3KD13CpEw6Et9KwWE2qjNqivoH0cFJT/GtpvxtGs4zvtsdfNWP2CYcrccZTpQ==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
dependencies:
|
||||
react: 18.2.0
|
||||
|
@ -1493,6 +1543,15 @@ packages:
|
|||
engines: {node: '>=4'}
|
||||
dev: true
|
||||
|
||||
/resolve/1.22.1:
|
||||
resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
is-core-module: 2.11.0
|
||||
path-parse: 1.0.7
|
||||
supports-preserve-symlinks-flag: 1.0.0
|
||||
dev: true
|
||||
|
||||
/resolve/2.0.0-next.4:
|
||||
resolution: {integrity: sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==}
|
||||
hasBin: true
|
||||
|
@ -1735,3 +1794,15 @@ packages:
|
|||
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
github.com/dmitmel/eslint-config-dmitmel/690f1b1121d342fcc8ee511ca9f2af7502f53db6_eslint@8.25.0:
|
||||
resolution: {tarball: https://codeload.github.com/dmitmel/eslint-config-dmitmel/tar.gz/690f1b1121d342fcc8ee511ca9f2af7502f53db6}
|
||||
id: github.com/dmitmel/eslint-config-dmitmel/690f1b1121d342fcc8ee511ca9f2af7502f53db6
|
||||
name: eslint-config-dmitmel
|
||||
version: 8.2.2
|
||||
engines: {node: '>=8.10.0'}
|
||||
peerDependencies:
|
||||
eslint: '>=8.17.0'
|
||||
dependencies:
|
||||
eslint: 8.25.0
|
||||
dev: true
|
||||
|
|
144
scripts/build.ts
144
scripts/build.ts
|
@ -1,7 +1,7 @@
|
|||
import esbuild from 'esbuild';
|
||||
import { globalExternals } from '@fal-works/esbuild-plugin-global-externals';
|
||||
import path from 'path';
|
||||
import type { Plugin } from 'replugged/src/types/addon';
|
||||
import {globalExternals} from '@fal-works/esbuild-plugin-global-externals';
|
||||
import path, {join} from 'path';
|
||||
import type {Plugin} from 'replugged/src/types/addon';
|
||||
import fs from 'fs';
|
||||
import _manifest from '../manifest.json';
|
||||
|
||||
|
@ -11,75 +11,119 @@ const NODE_VERSION = '14';
|
|||
const CHROME_VERSION = '91';
|
||||
|
||||
const globalModules = {
|
||||
replugged: {
|
||||
varName: 'replugged',
|
||||
namedExports: [ 'Injector', 'webpack', 'notices', 'commands', 'settings', 'quickCSS', 'themes', 'ignition', 'plugins' ],
|
||||
defaultExport: true
|
||||
}
|
||||
replugged: {
|
||||
varName: 'replugged',
|
||||
namedExports: [
|
||||
'Injector',
|
||||
'webpack',
|
||||
'notices',
|
||||
'commands',
|
||||
'settings',
|
||||
'quickCSS',
|
||||
'themes',
|
||||
'ignition',
|
||||
'plugins',
|
||||
],
|
||||
defaultExport: true,
|
||||
},
|
||||
};
|
||||
|
||||
const REPLUGGED_FOLDER_NAME = 'replugged';
|
||||
export const CONFIG_PATH = (() => {
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
return join(
|
||||
process.env.APPDATA || '',
|
||||
REPLUGGED_FOLDER_NAME,
|
||||
'plugins',
|
||||
);
|
||||
case 'darwin':
|
||||
return join(
|
||||
process.env.HOME || '',
|
||||
'Library',
|
||||
'Application Support',
|
||||
REPLUGGED_FOLDER_NAME,
|
||||
'plugins',
|
||||
);
|
||||
default:
|
||||
if (process.env.XDG_CONFIG_HOME) {
|
||||
return join(
|
||||
process.env.XDG_CONFIG_HOME,
|
||||
REPLUGGED_FOLDER_NAME,
|
||||
'plugins',
|
||||
);
|
||||
}
|
||||
return join(
|
||||
process.env.HOME || '',
|
||||
'.config',
|
||||
REPLUGGED_FOLDER_NAME,
|
||||
'plugins',
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
const watch = process.argv.includes('--watch');
|
||||
|
||||
const common: esbuild.BuildOptions = {
|
||||
absWorkingDir: path.join(__dirname, '..'),
|
||||
bundle: true,
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
format: 'cjs' as esbuild.Format,
|
||||
logLevel: 'info',
|
||||
watch
|
||||
absWorkingDir: path.join(__dirname, '..'),
|
||||
bundle: true,
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
format: 'cjs' as esbuild.Format,
|
||||
logLevel: 'info',
|
||||
watch,
|
||||
};
|
||||
|
||||
const targets = [];
|
||||
|
||||
if ('renderer' in manifest) {
|
||||
targets.push(
|
||||
esbuild.build({
|
||||
...common,
|
||||
entryPoints: [ manifest.renderer ],
|
||||
platform: 'browser',
|
||||
target: `chrome${CHROME_VERSION}`,
|
||||
outfile: 'dist/renderer.js',
|
||||
format: 'esm' as esbuild.Format,
|
||||
plugins: [ globalExternals(globalModules) ]
|
||||
})
|
||||
);
|
||||
targets.push(
|
||||
esbuild.build({
|
||||
...common,
|
||||
entryPoints: [manifest.renderer],
|
||||
platform: 'browser',
|
||||
target: `chrome${CHROME_VERSION}`,
|
||||
outfile: 'dist/renderer.js',
|
||||
format: 'esm' as esbuild.Format,
|
||||
plugins: [globalExternals(globalModules)],
|
||||
}),
|
||||
);
|
||||
|
||||
manifest.renderer = 'renderer.js';
|
||||
manifest.renderer = 'renderer.js';
|
||||
}
|
||||
|
||||
if ('preload' in manifest) {
|
||||
targets.push(
|
||||
esbuild.build({
|
||||
...common,
|
||||
entryPoints: [ manifest.preload ],
|
||||
platform: 'node',
|
||||
target: [ `node${NODE_VERSION}`, `chrome${CHROME_VERSION}` ],
|
||||
outfile: 'dist/preload.js',
|
||||
external: [ 'electron' ]
|
||||
})
|
||||
);
|
||||
targets.push(
|
||||
esbuild.build({
|
||||
...common,
|
||||
entryPoints: [manifest.preload],
|
||||
platform: 'node',
|
||||
target: [`node${NODE_VERSION}`, `chrome${CHROME_VERSION}`],
|
||||
outfile: 'dist/preload.js',
|
||||
external: ['electron'],
|
||||
}),
|
||||
);
|
||||
|
||||
manifest.preload = 'preload.js';
|
||||
manifest.preload = 'preload.js';
|
||||
}
|
||||
|
||||
if ('main' in manifest) {
|
||||
targets.push(
|
||||
esbuild.build({
|
||||
...common,
|
||||
entryPoints: [ manifest.main ],
|
||||
platform: 'node',
|
||||
target: `node${NODE_VERSION}`,
|
||||
outfile: 'dist/main.js',
|
||||
external: [ 'electron' ]
|
||||
})
|
||||
);
|
||||
targets.push(
|
||||
esbuild.build({
|
||||
...common,
|
||||
entryPoints: [manifest.main],
|
||||
platform: 'node',
|
||||
target: `node${NODE_VERSION}`,
|
||||
outfile: 'dist/main.js',
|
||||
external: ['electron'],
|
||||
}),
|
||||
);
|
||||
|
||||
manifest.main = 'main.js';
|
||||
manifest.main = 'main.js';
|
||||
}
|
||||
|
||||
if (!fs.existsSync('dist')) {
|
||||
fs.mkdirSync('dist');
|
||||
fs.mkdirSync('dist');
|
||||
}
|
||||
|
||||
fs.writeFileSync('dist/manifest.json', JSON.stringify(manifest));
|
||||
|
|
34
src/index.ts
Normal file
34
src/index.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import {Injector, webpack} from 'replugged';
|
||||
import {AnyFunction} from 'replugged/src/types/util';
|
||||
|
||||
const inject = new Injector();
|
||||
|
||||
export async function start(): Promise<void> {
|
||||
const typingMod = (await webpack.waitForModule(
|
||||
webpack.filters.byProps('startTyping'),
|
||||
)) as {
|
||||
startTyping: AnyFunction;
|
||||
};
|
||||
const getChannelMod = (await webpack.waitForModule(
|
||||
webpack.filters.byProps('getChannel'),
|
||||
)) as {
|
||||
getChannel: (id: string) => {
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
|
||||
if (typingMod && getChannelMod) {
|
||||
inject.instead(typingMod, 'startTyping', ([channel]) => {
|
||||
const channelObj = getChannelMod.getChannel(channel as string);
|
||||
console.log(
|
||||
`Typing prevented! Channel: #${
|
||||
channelObj?.name ?? 'unknown'
|
||||
} (${channel}).`,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function stop(): void {
|
||||
inject.uninjectAll();
|
||||
}
|
Loading…
Reference in a new issue