Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dprint for formatting #811

Merged
merged 17 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 2 additions & 174 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,156 +15,48 @@
"plugin:import/recommended"
],
"rules": {
"one-var-declaration-per-line": ["error", "always"],
"one-var": ["error", "never"],
"array-callback-return": "error",
"comma-spacing": "error",
"eol-last": "error",
"guard-for-in": "error",
"key-spacing": "error",
"keyword-spacing": "error",
"new-parens": "error",
"no-array-constructor": "error",
"no-console": 0,
"no-implied-eval": "error",
"no-multi-spaces": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-trailing-spaces": "error",
"no-var": "error",
"no-whitespace-before-property": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-numeric-literals": "error",
"prefer-rest-params": "error",
"prefer-template": "error",
"require-await": "error",
"space-infix-ops": "error",
"array-bracket-newline": [
"error",
"consistent"
],
"array-bracket-spacing": [
"error",
"never"
],
"array-element-newline": [
"error",
"consistent"
],
"arrow-body-style": [
"error",
"as-needed"
],
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": [
"error",
{
"before": true,
"after": true
}
],
"block-spacing": [
"error",
"always"
],
"brace-style": [
"error",
"1tbs"
],
"comma-dangle": [
"error",
"always-multiline"
],
"comma-style": [
"error",
"last"
],
"computed-property-spacing": [
"error",
"never"
],
"curly": [
"error",
"all"
],
"dot-location": [
"error",
"property"
],
"eqeqeq": [
"error",
"always",
{
"null": "ignore"
}
],
"func-call-spacing": [
"error",
"never"
],
"func-style": [
"error",
"declaration",
{
"allowArrowFunctions": true
}
],
"function-paren-newline": [
"error",
"multiline"
],
"implicit-arrow-linebreak": [
"error",
"beside"
],
"indent": [
"error",
4,
{
"VariableDeclarator": "first",
"SwitchCase": 0
}
],
"linebreak-style": [
"error",
"unix"
],
"no-extra-parens": [
"error",
"all",
{
"conditionalAssign": false
}
],
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-use-before-define": [
"error",
"nofunc"
],
"object-curly-newline": [
"error",
{
"multiline": true,
"consistent": true
}
],
"object-curly-spacing": [
"error",
"never"
],
"object-property-newline": [
"error",
{
"allowAllPropertiesOnSameLine": true
}
],
"object-shorthand": [
"error",
"always"
Expand All @@ -173,77 +65,13 @@
"error",
"always"
],
"padded-blocks": [
"error",
"never"
],
"quote-props": [
"error",
"consistent-as-needed"
],
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"semi": [
"error",
"always"
],
"semi-spacing": [
"error",
{
"before": false,
"after": true
}
],
"semi-style": [
"error",
"last"
],
"space-before-blocks": [
"error",
"always"
],
"space-before-function-paren": [
"error",
"always"
],
"space-in-parens": [
"error",
"never"
],
"space-unary-ops": [
"error",
{
"words": true,
"nonwords": false
}
],
"spaced-comment": [
"error",
"always"
],
"switch-colon-spacing": [
"error",
{
"before": false,
"after": true
}
],
"template-curly-spacing": [
"error",
"never"
],
"template-tag-spacing": [
"error",
"never"
],
"wrap-iife": [
"error",
"inside"
]
}
}
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# initial formatting from dprint transition
826ac79d9225a3bc4f7a5312b5f20cf993eba491
a1104a469541b44745bbc5ec2ccfcf7082ad6d33
aa5c5a24c366d37f328e190d9172d26da7fc8d52
6124856eb8878c7d7c924d3794f656bc0a2ebf33
89fd701c2ab3387516f90425b716b3aac3d1e627
24 changes: 7 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
name: tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]
jobs:
test:
# The type of runner that the job will run on
ci:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- name: Run eslint
uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm install
- run: npm run eslint
env:
CI: true
- uses: actions/setup-node@v3
- run: npm ci
- run: npm run fmt
- run: npm run lint
- run: npm run build
16 changes: 8 additions & 8 deletions PRIVACY.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Toolbox has access to the same information on reddit as the account(s) with which you use it.
Toolbox has access to the same information on reddit as the account(s) with which you use it.

The toolbox development team highly values privacy, these are the measures we have taken in order to protect the privacy of people using toolbox:
The toolbox development team highly values privacy, these are the measures we have taken in order to protect the privacy of people using toolbox:

- Toolbox purposely lacks the technical means to send back any data back to the toolbox development team. ^[1]
- Any data accessed is used for toolbox functionality.
- If accessed data needs to be stored it is either stored on reddit (user notes, toolbox subreddit configuration, settings export) or in the local browser extension settings (personal settings, cache). No data is stored outside of reddit or out of reach of the person using toolbox.
- Data stored on reddit is stored through wiki pages. It is only stored in wiki pages of subreddits where the account using toolbox has access as moderator with the permissions to edit those pages. Any write action on a wiki page is accompanied with a settings change on the wiki page that makes sure only moderators have access to the written data.
- Any data accessed is used for toolbox functionality.
- If accessed data needs to be stored it is either stored on reddit (user notes, toolbox subreddit configuration, settings export) or in the local browser extension settings (personal settings, cache). No data is stored outside of reddit or out of reach of the person using toolbox.
- Data stored on reddit is stored through wiki pages. It is only stored in wiki pages of subreddits where the account using toolbox has access as moderator with the permissions to edit those pages. Any write action on a wiki page is accompanied with a settings change on the wiki page that makes sure only moderators have access to the written data.

---

*[1]* toolbox is open-source, you can check the code and used webextension permissions on the repository here. No code is modified before the extension is released to the chrome store or mozilla AMO. Here is how you access the code of the installed version to verify this claim:
_[1]_ toolbox is open-source, you can check the code and used webextension permissions on the repository here. No code is modified before the extension is released to the chrome store or mozilla AMO. Here is how you access the code of the installed version to verify this claim:

- Edge: `C:\Program Files\WindowsApps` will contain the installed extension.
- Chrome: Open `chrome://version/` and look for `Profile Path` which is the directory containing extensions.
- Firefox: Navigate to [your profile directory](https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data) and then to the `extensions` subdirectory. You'll find `yes@jetpack.xpi` which can be opened as zip file.
- Chrome: Open `chrome://version/` and look for `Profile Path` which is the directory containing extensions.
- Firefox: Navigate to [your profile directory](https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data) and then to the `extensions` subdirectory. You'll find `yes@jetpack.xpi` which can be opened as zip file.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ All Toolbox subreddit settings and data are stored in subreddit wikis through ve
[webstore]: https://chrome.google.com/webstore/detail/moderator-toolbox-for-red/jhjpjhhkcbkmgdkahnckfboefnkgghpo
[amo]: https://addons.mozilla.org/en-US/firefox/addon/reddit-moderator-toolbox/
[edge-store]: https://microsoftedge.microsoft.com/addons/detail/moderator-toolbox-for-red/nolhfmoadpbgfeonfnjlcfmhhkmdlfcl

[discord]: https://discord.gg/8fGCykQ
[post-on-reddit]: https://new.reddit.com/r/toolbox/submit?text=true
[user-docs]: https://www.reddit.com/r/toolbox/w/docs

[nodejs]: https://nodejs.org/
[contributing]: /CONTRIBUTING.md
[third-party-docs]: https://github.com/toolbox-team/reddit-moderator-toolbox/wiki/Subreddit-Wikis
Expand Down
35 changes: 35 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"typescript": {
"lineWidth": 120,
"indentWidth": 4,
"useTabs": false,
"quoteStyle": "alwaysSingle",
"quoteProps": "consistent",
"useBraces": "always",
"arrowFunction.useParentheses": "preferNone",
"enumDeclaration.memberSpacing": "newLine",
"spaceSurroundingProperties": false,
"exportDeclaration.spaceSurroundingNamedExports": false,
"importDeclaration.spaceSurroundingNamedImports": false,
"constructor.spaceBeforeParentheses": true,
"functionDeclaration.spaceBeforeParentheses": true,
"functionExpression.spaceBeforeParentheses": true,
"getAccessor.spaceBeforeParentheses": true,
"setAccessor.spaceBeforeParentheses": true,
"method.spaceBeforeParentheses": true
},
"json": {
"indentWidth": 4
},
"markdown": {},
"excludes": [
eritbh marked this conversation as resolved.
Show resolved Hide resolved
"**/node_modules",
"**/*-lock.json",
"build"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.86.1.wasm",
"https://plugins.dprint.dev/json-0.17.4.wasm",
"https://plugins.dprint.dev/markdown-0.15.3.wasm"
]
}
2 changes: 1 addition & 1 deletion extension/chrome_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@
]
}
]
}
}
12 changes: 9 additions & 3 deletions extension/data/background/handlers/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const shortCacheList = [

async function clearCache (redditSessionUserId) {
const storage = await browser.storage.local.get();
const cacheKeys = Object.keys(storage).filter(storageKey => storageKey.startsWith(`${TB_CACHE_PREFIX}.${redditSessionUserId}`));
const cacheKeys = Object.keys(storage).filter(storageKey =>
storageKey.startsWith(`${TB_CACHE_PREFIX}.${redditSessionUserId}`)
);
await browser.storage.local.remove(cacheKeys);
}

Expand Down Expand Up @@ -125,9 +127,13 @@ messageHandlers.set('tb-cache', async (request, sender) => {
const TBsettingsObject = await browser.storage.local.get('tbsettings');
let cacheTTL;
if (longCacheList.includes(storageKey)) {
cacheTTL = TBsettingsObject.tbsettings[storageLongLengthKey] ? TBsettingsObject.tbsettings[storageLongLengthKey] : 45;
cacheTTL = TBsettingsObject.tbsettings[storageLongLengthKey]
? TBsettingsObject.tbsettings[storageLongLengthKey]
: 45;
} else {
cacheTTL = TBsettingsObject.tbsettings[storageShortLengthKey] ? TBsettingsObject.tbsettings[storageShortLengthKey] : 15;
cacheTTL = TBsettingsObject.tbsettings[storageShortLengthKey]
? TBsettingsObject.tbsettings[storageShortLengthKey]
: 15;
}

// TODO: find out if this is actually still needed.
Expand Down
2 changes: 1 addition & 1 deletion extension/data/background/handlers/globalmessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import browser from 'webextension-polyfill';

import {messageHandlers, handleMessage} from '../messageHandling';
import {handleMessage, messageHandlers} from '../messageHandling';

messageHandlers.set('tb-global', async (request, sender) => {
const message = {
Expand Down
2 changes: 1 addition & 1 deletion extension/data/background/handlers/modqueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ messageHandlers.set('tb-modqueue', async request => {
if (refreshActive) {
console.debug('Cache being refreshed, wait for it to be finished');
await waitForCacheRefresh(subreddit);
// The thing timestamp is bigger than the last refresh or cache isn't fresh anymore.
// The thing timestamp is bigger than the last refresh or cache isn't fresh anymore.
} else if (thingTimestamp * 1000 > lastRefresh || Date.now() - lastRefresh > 1000 * MODQUEUE_CACHE_TTL) {
console.debug('Cache needs a refresh');
if (subredditQueueCache) {
Expand Down
Loading