mirror of
https://github.com/outline/outline.git
synced 2025-12-30 15:30:12 -06:00
chore: Remove console.log left in code and added eslint rule to prevent it happening again
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
"rules": {
|
||||
"eqeqeq": 2,
|
||||
"curly": 2,
|
||||
"no-console": "error",
|
||||
"arrow-body-style": ["error", "as-needed"],
|
||||
"spaced-comment": "error",
|
||||
"object-shorthand": "error",
|
||||
|
||||
@@ -25,6 +25,7 @@ import Item, { Actions } from "~/components/List/Item";
|
||||
import Time from "~/components/Time";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import RevisionMenu from "~/menus/RevisionMenu";
|
||||
import Logger from "~/utils/Logger";
|
||||
import { documentHistoryUrl } from "~/utils/routeHelpers";
|
||||
|
||||
type Props = {
|
||||
@@ -109,7 +110,7 @@ const EventListItem = ({ event, latest, document, ...rest }: Props) => {
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn("Unhandled event: ", event.name);
|
||||
Logger.warn("Unhandled event", { event });
|
||||
}
|
||||
|
||||
if (!meta) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import useComponentSize from "~/hooks/useComponentSize";
|
||||
import useEventListener from "~/hooks/useEventListener";
|
||||
import useMediaQuery from "~/hooks/useMediaQuery";
|
||||
import useViewportHeight from "~/hooks/useViewportHeight";
|
||||
import Logger from "~/utils/Logger";
|
||||
import { useEditor } from "./EditorContext";
|
||||
|
||||
type Props = {
|
||||
@@ -63,7 +64,7 @@ function usePosition({
|
||||
fromPos = view.coordsAtPos(selection.from);
|
||||
toPos = view.coordsAtPos(selection.to, -1);
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
Logger.warn("Unable to calculate selection position", err);
|
||||
return defaultPosition;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import { ResizingHeightContainer } from "~/components/ResizingHeightContainer";
|
||||
import Scrollable from "~/components/Scrollable";
|
||||
import { Dictionary } from "~/hooks/useDictionary";
|
||||
import { ToastOptions } from "~/types";
|
||||
import Logger from "~/utils/Logger";
|
||||
import Input from "./Input";
|
||||
import LinkSearchResult from "./LinkSearchResult";
|
||||
import ToolbarButton from "./ToolbarButton";
|
||||
@@ -223,8 +224,8 @@ class LinkEditor extends React.Component<Props, State> {
|
||||
},
|
||||
previousValue: trimmedValue,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} catch (err) {
|
||||
Logger.error("Error searching for link", err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ import { Portal } from "~/components/Portal";
|
||||
import Scrollable from "~/components/Scrollable";
|
||||
import useDictionary from "~/hooks/useDictionary";
|
||||
import useToasts from "~/hooks/useToasts";
|
||||
import Logger from "~/utils/Logger";
|
||||
import { useEditor } from "./EditorContext";
|
||||
import Input from "./Input";
|
||||
|
||||
@@ -99,7 +100,7 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
|
||||
fromPos = view.coordsAtPos(selection.from);
|
||||
toPos = view.coordsAtPos(selection.to, -1);
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
Logger.warn("Unable to calculate caret position", err);
|
||||
return {
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { pick } from "lodash";
|
||||
import { set, observable } from "mobx";
|
||||
import Logger from "~/utils/Logger";
|
||||
import { getFieldsForModel } from "./decorators/Field";
|
||||
|
||||
export default abstract class BaseModel {
|
||||
@@ -126,7 +127,7 @@ export default abstract class BaseModel {
|
||||
const attributes = this.toAPI();
|
||||
|
||||
if (Object.keys(attributes).length === 0) {
|
||||
console.warn("Checking dirty on model with no @Field decorators");
|
||||
Logger.warn("Checking dirty on model with no @Field decorators");
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -78,7 +78,6 @@ function AddGroupsToCollection(props: Props) {
|
||||
toasts.showToast(t("Could not add user"), {
|
||||
type: "error",
|
||||
});
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
import * as Sentry from "@sentry/react";
|
||||
import env from "~/env";
|
||||
|
||||
|
||||
1
build.js
1
build.js
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
/* eslint-disable no-undef */
|
||||
const { exec } = require("child_process");
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
"extends": [
|
||||
"../.eslintrc"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["scripts/*"],
|
||||
"rules": {
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
||||
],
|
||||
"env": {
|
||||
"jest": true,
|
||||
"node": true
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
import { IncomingMessage } from "http";
|
||||
import chalk from "chalk";
|
||||
import { isEmpty, isArray, isObject, isString } from "lodash";
|
||||
|
||||
@@ -32,9 +32,6 @@ if (env.SENTRY_DSN) {
|
||||
export function requestErrorHandler(error: any, ctx: AppContext) {
|
||||
// we don't need to report every time a request stops to the bug tracker
|
||||
if (error.code === "EPIPE" || error.code === "ECONNRESET") {
|
||||
console.warn("Connection error", {
|
||||
error,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,6 +66,7 @@ export function requestErrorHandler(error: any, ctx: AppContext) {
|
||||
Sentry.captureException(error);
|
||||
});
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import Logger from "@server/logging/Logger";
|
||||
|
||||
const Deprecated = (message?: string) => (
|
||||
target: Object,
|
||||
propertyKey: string
|
||||
) => {
|
||||
if (process.env[propertyKey]) {
|
||||
console.warn(
|
||||
Logger.warn(
|
||||
`The environment variable ${propertyKey} is deprecated and will be removed in a future release. ${message}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import Logger from "@server/logging/Logger";
|
||||
|
||||
export type Chunk = {
|
||||
file: string;
|
||||
@@ -17,7 +18,7 @@ export const readManifestFile = (file = "./build/app/manifest.json") => {
|
||||
try {
|
||||
manifest = fs.readFileSync(absoluteFilePath, "utf8") as string;
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
Logger.warn(
|
||||
`Can not find ${absoluteFilePath}. Try executing "yarn vite:build" before running in production mode.`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Sentry from "@sentry/react";
|
||||
import invariant from "invariant";
|
||||
import { NodeSelection } from "prosemirror-state";
|
||||
import { EditorView } from "prosemirror-view";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
@@ -43,10 +44,10 @@ const insertFiles = function (
|
||||
onShowToast,
|
||||
} = options;
|
||||
|
||||
if (!uploadFile) {
|
||||
console.warn("uploadFile callback must be defined to handle uploads.");
|
||||
return;
|
||||
}
|
||||
invariant(
|
||||
uploadFile,
|
||||
"uploadFile callback must be defined to handle uploads."
|
||||
);
|
||||
|
||||
// okay, we have some dropped files and a handler – lets stop this
|
||||
// event going any further up the stack
|
||||
|
||||
@@ -85,7 +85,6 @@ function getNewState({
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
const errorNode = document.getElementById(
|
||||
"d" + "mermaid-diagram-" + diagramId
|
||||
);
|
||||
|
||||
@@ -12,30 +12,26 @@ export default class Suggestion extends Extension {
|
||||
return [new SuggestionsMenuPlugin(this.editor, this.options)];
|
||||
}
|
||||
|
||||
inputRules = (_options: { type: NodeType; schema: Schema }) => {
|
||||
console.log(this.name, this.options.openRegex);
|
||||
|
||||
return [
|
||||
new InputRule(this.options.openRegex, (state, match) => {
|
||||
if (
|
||||
match &&
|
||||
state.selection.$from.parent.type.name === "paragraph" &&
|
||||
(!isInCode(state) || this.options.enabledInCode) &&
|
||||
(!isInTable(state) || this.options.enabledInTable)
|
||||
) {
|
||||
this.editor.events.emit(EventType.SuggestionsMenuOpen, {
|
||||
type: this.options.type,
|
||||
query: match[1],
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
new InputRule(this.options.closeRegex, (state, match) => {
|
||||
if (match) {
|
||||
this.editor.events.emit(EventType.SuggestionsMenuClose);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
];
|
||||
};
|
||||
inputRules = (_options: { type: NodeType; schema: Schema }) => [
|
||||
new InputRule(this.options.openRegex, (state, match) => {
|
||||
if (
|
||||
match &&
|
||||
state.selection.$from.parent.type.name === "paragraph" &&
|
||||
(!isInCode(state) || this.options.enabledInCode) &&
|
||||
(!isInTable(state) || this.options.enabledInTable)
|
||||
) {
|
||||
this.editor.events.emit(EventType.SuggestionsMenuOpen, {
|
||||
type: this.options.type,
|
||||
query: match[1],
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
new InputRule(this.options.closeRegex, (state, match) => {
|
||||
if (match) {
|
||||
this.editor.events.emit(EventType.SuggestionsMenuClose);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ export default abstract class Mark extends Extension {
|
||||
return [];
|
||||
}
|
||||
|
||||
toMarkdown(state: MarkdownSerializerState, node: ProsemirrorNode) {
|
||||
console.error("toMarkdown not implemented", state, node);
|
||||
toMarkdown(_state: MarkdownSerializerState, _node: ProsemirrorNode) {
|
||||
throw new Error("toMarkdown not implemented");
|
||||
}
|
||||
|
||||
parseMarkdown(): TokenConfig | void {
|
||||
|
||||
@@ -37,8 +37,8 @@ export default abstract class Node extends Extension {
|
||||
return {};
|
||||
}
|
||||
|
||||
toMarkdown(state: MarkdownSerializerState, node: ProsemirrorNode): void {
|
||||
console.error("toMarkdown not implemented", state, node);
|
||||
toMarkdown(_state: MarkdownSerializerState, _node: ProsemirrorNode) {
|
||||
throw new Error("toMarkdown not implemented");
|
||||
}
|
||||
|
||||
parseMarkdown(): TokenConfig | void {
|
||||
|
||||
Reference in New Issue
Block a user