Skip to content

Commit

Permalink
clipper(web): fix all eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Dec 5, 2022
1 parent e17bd79 commit 7cd6a6e
Show file tree
Hide file tree
Showing 29 changed files with 500 additions and 65 deletions.
5 changes: 1 addition & 4 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Your private note taking space",
"version": "2.2.4",
"private": true,
"main": "./src/App.js",
"main": "./src/app.js",
"homepage": "https://notesnook.com/",
"repository": "https://github.com/streetwriters/notesnook",
"license": "GPL-3.0-or-later",
Expand Down Expand Up @@ -136,8 +136,5 @@
"name": "Streetwriters (Private) Ltd.",
"email": "support@streetwriters.co",
"url": "https://streetwriters.co"
},
"volta": {
"node": "16.15.1"
}
}
19 changes: 18 additions & 1 deletion extensions/web-clipper/build-utils/build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
// Do this as the first thing so that any code reading it knows the right env.
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
process.env.BABEL_ENV = "production";
process.env.NODE_ENV = "production";
process.env.ASSET_PATH = "/";
Expand Down
19 changes: 18 additions & 1 deletion extensions/web-clipper/build-utils/dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
// Do this as the first thing so that any code reading it knows the right env.
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
process.env.BABEL_ENV = "development";
process.env.NODE_ENV = "development";
process.env.ASSET_PATH = "/";
Expand Down
19 changes: 18 additions & 1 deletion extensions/web-clipper/build-utils/env.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
// tiny wrapper with default env vars
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module.exports = {
NODE_ENV: process.env.NODE_ENV || "development",
PORT: process.env.PORT || 3000,
Expand Down
18 changes: 18 additions & 0 deletions extensions/web-clipper/build-utils/manifest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const ICONS = {
16: "16x16.png",
32: "32x32.png",
Expand Down
18 changes: 18 additions & 0 deletions extensions/web-clipper/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
declare module "*.svg" {
import React = require("react");
export const ReactComponent: React.SFC<React.SVGProps<SVGSVGElement>>;
Expand Down
20 changes: 9 additions & 11 deletions extensions/web-clipper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@
"dev:firefox": "MANIFEST_VERSION=2 node build-utils/dev.js",
"build": "tsc"
},
"eslintConfig": {
"extends": "react-app",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"webextensions": true
}
},
"browserslist": {
"production": [
">0.2%",
Expand Down Expand Up @@ -106,5 +96,13 @@
],
"extensions": "ts,js,json,tsx,jsx"
}
}
},
"license": "GPL-3.0-or-later",
"author": {
"name": "Streetwriters (Private) Ltd.",
"email": "support@streetwriters.co",
"url": "https://streetwriters.co"
},
"homepage": "https://notesnook.com/",
"repository": "https://github.com/streetwriters/notesnook"
}
40 changes: 31 additions & 9 deletions extensions/web-clipper/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, Runtime } from "webextension-polyfill-ts";
import { Remote, wrap } from "comlink";
import { createEndpoint } from "./utils/comlink-extension";
import { Server } from "./common/bridge";
import { APP_URL, APP_URL_FILTER } from "./common/constants";

type WebExtensionChannelMessage = { success: boolean };

let api: Remote<Server> | undefined;
export async function connectApi(openNew = false, onDisconnect?: () => void) {
if (api) return api;

const tab = await getTab(openNew);
if (!tab || !tab.id) return false;
if (!tab) return false;

return await new Promise<Remote<Server> | false>(function connect(resolve) {
if (!tab.id) return resolve(false);

return await new Promise<Remote<Server> | undefined>(function connect(
resolve,
reject
) {
const port = browser.tabs.connect(tab.id!);
const port = browser.tabs.connect(tab.id);

port.onDisconnect.addListener(() => {
api = undefined;
onDisconnect?.();
});

async function onMessage(message: any, port: Runtime.Port) {
if (message?.success) {
async function onMessage(
message: WebExtensionChannelMessage,
port: Runtime.Port
) {
if (message.success) {
port.onMessage.removeListener(onMessage);
api = wrap<Server>(createEndpoint(port));
resolve(api);
} else {
resolve(undefined);
resolve(false);
}
}

Expand Down
18 changes: 18 additions & 0 deletions extensions/web-clipper/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ThemeProvider } from "./components/theme-provider";
import { useAppStore } from "./stores/app-store";
import { Login } from "./views/login";
Expand Down
18 changes: 18 additions & 0 deletions extensions/web-clipper/src/background.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from "webextension-polyfill-ts";
import { storeClip } from "./utils/storage";

Expand Down
18 changes: 18 additions & 0 deletions extensions/web-clipper/src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export const APP_URL =
process.env.NODE_ENV === "production"
? "https://app.notesnook.com"
Expand Down
20 changes: 19 additions & 1 deletion extensions/web-clipper/src/components/filtered-list/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import React, { useCallback, useEffect, useRef, useState } from "react";
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useCallback, useEffect, useRef, useState } from "react";
import { Button, Flex, Input, Text } from "@theme-ui/components";
import { Icon } from "../icons/icon";
import { Icons } from "../icons";
Expand Down
19 changes: 18 additions & 1 deletion extensions/web-clipper/src/components/icons/icon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import React from "react";
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import MDIIcon from "@mdi/react";
import { SchemeColors } from "@notesnook/theme/dist/theme/colorscheme";
import { Flex, FlexProps } from "@theme-ui/components";
Expand Down
18 changes: 18 additions & 0 deletions extensions/web-clipper/src/components/icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {
mdiCheck,
mdiChevronDown,
Expand Down
18 changes: 18 additions & 0 deletions extensions/web-clipper/src/components/note-picker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useState } from "react";
import { Button, Flex, Text } from "@theme-ui/components";
import { FilteredList } from "../filtered-list";
Expand Down
Loading

0 comments on commit 7cd6a6e

Please sign in to comment.