chore: Add eslint rule for object shorthand (#3955)

This commit is contained in:
Tom Moor
2022-08-11 13:18:14 +01:00
committed by GitHub
parent 7eaa8eb961
commit 1d242d44b1
17 changed files with 19 additions and 18 deletions

View File

@@ -25,6 +25,7 @@
"rules": { "rules": {
"eqeqeq": 2, "eqeqeq": 2,
"curly": 2, "curly": 2,
"object-shorthand": "error",
"no-mixed-operators": "off", "no-mixed-operators": "off",
"no-useless-escape": "off", "no-useless-escape": "off",
"es/no-regexp-lookbehind-assertions": "error", "es/no-regexp-lookbehind-assertions": "error",

View File

@@ -430,7 +430,7 @@ export class Editor extends React.PureComponent<
state: this.createState(this.props.value), state: this.createState(this.props.value),
editable: () => !this.props.readOnly, editable: () => !this.props.readOnly,
nodeViews: this.nodeViews, nodeViews: this.nodeViews,
dispatchTransaction: function (transaction) { dispatchTransaction(transaction) {
// callback is bound to have the view instance as its this binding // callback is bound to have the view instance as its this binding
const { state, transactions } = this.state.applyTransaction( const { state, transactions } = this.state.applyTransaction(
transaction transaction

View File

@@ -25,7 +25,7 @@ function GroupEdit({ group, onSubmit }: Props) {
try { try {
await group.save({ await group.save({
name: name, name,
}); });
onSubmit(); onSubmit();
} catch (err) { } catch (err) {

View File

@@ -29,7 +29,7 @@ function GroupNew({ onSubmit }: Props) {
const group = new Group( const group = new Group(
{ {
name: name, name,
}, },
groups groups
); );

View File

@@ -532,7 +532,7 @@ export default class DocumentsStore extends BaseStore<Document> {
id: documentId, id: documentId,
collectionId, collectionId,
parentDocumentId, parentDocumentId,
index: index, index,
}); });
invariant(res?.data, "Data not available"); invariant(res?.data, "Data not available");
res.data.documents.forEach(this.add); res.data.documents.forEach(this.add);

View File

@@ -20,7 +20,7 @@ let supportsPassive = false;
try { try {
const opts = Object.defineProperty({}, "passive", { const opts = Object.defineProperty({}, "passive", {
get: function () { get() {
supportsPassive = true; supportsPassive = true;
}, },
}); });

View File

@@ -35,7 +35,7 @@ export default class Queue {
createJob = function (data: any) { createJob = function (data: any) {
return { return {
data: data, data,
}; };
}; };
} }

View File

@@ -119,7 +119,7 @@ const teamUpdater = async ({ params, user, team, ip }: TeamUpdaterProps) => {
actorId: user.id, actorId: user.id,
teamId: user.teamId, teamId: user.teamId,
data, data,
ip: ip, ip,
}, },
{ {
transaction, transaction,

View File

@@ -31,7 +31,7 @@ import NotContainsUrl from "./validators/NotContainsUrl";
tableName: "groups", tableName: "groups",
modelName: "group", modelName: "group",
validate: { validate: {
isUniqueNameInTeam: async function () { async isUniqueNameInTeam() {
const foundItem = await Group.findOne({ const foundItem = await Group.findOne({
where: { where: {
teamId: this.teamId, teamId: this.teamId,

View File

@@ -33,6 +33,6 @@ export default function present({
webhookSubscriptionId: delivery.webhookSubscriptionId, webhookSubscriptionId: delivery.webhookSubscriptionId,
createdAt: delivery.createdAt, createdAt: delivery.createdAt,
event: event.name, event: event.name,
payload: payload, payload,
}; };
} }

View File

@@ -39,7 +39,7 @@ requireDirectory(__dirname).forEach(([module, id]) => {
name: config.name, name: config.name,
enabled: config.enabled, enabled: config.enabled,
authUrl: signin(id), authUrl: signin(id),
router: router, router,
}); });
} }
}); });

View File

@@ -8,7 +8,7 @@ import TurndownService from "turndown";
export default function breaks(turndownService: TurndownService) { export default function breaks(turndownService: TurndownService) {
turndownService.addRule("breaks", { turndownService.addRule("breaks", {
filter: ["br"], filter: ["br"],
replacement: function () { replacement() {
return "\n"; return "\n";
}, },
}); });

View File

@@ -10,7 +10,7 @@ const highlightRegExp = /brush: ([a-z0-9]+);/;
*/ */
export default function confluenceCodeBlock(turndownService: TurndownService) { export default function confluenceCodeBlock(turndownService: TurndownService) {
turndownService.addRule("fencedConfluenceHighlightedCodeBlock", { turndownService.addRule("fencedConfluenceHighlightedCodeBlock", {
filter: function (node) { filter(node) {
const firstChild = node.firstChild; const firstChild = node.firstChild;
return ( return (
node.nodeName === "DIV" && node.nodeName === "DIV" &&
@@ -19,7 +19,7 @@ export default function confluenceCodeBlock(turndownService: TurndownService) {
firstChild.className === "syntaxhighlighter-pre" firstChild.className === "syntaxhighlighter-pre"
); );
}, },
replacement: function (content, node) { replacement(content, node) {
const dataSyntaxhighlighterParams = const dataSyntaxhighlighterParams =
// @ts-expect-error getAttribute exists // @ts-expect-error getAttribute exists
node.firstChild?.getAttribute("data-syntaxhighlighter-params") ?? ""; node.firstChild?.getAttribute("data-syntaxhighlighter-params") ?? "";

View File

@@ -7,7 +7,7 @@ import TurndownService from "turndown";
*/ */
export default function confluenceTaskList(turndownService: TurndownService) { export default function confluenceTaskList(turndownService: TurndownService) {
turndownService.addRule("confluenceTaskList", { turndownService.addRule("confluenceTaskList", {
filter: function (node) { filter(node) {
return ( return (
node.nodeName === "LI" && node.nodeName === "LI" &&
node.parentNode?.nodeName === "UL" && node.parentNode?.nodeName === "UL" &&
@@ -15,7 +15,7 @@ export default function confluenceTaskList(turndownService: TurndownService) {
node.parentNode?.className.includes("inline-task-list") node.parentNode?.className.includes("inline-task-list")
); );
}, },
replacement: function (content, node) { replacement(content, node) {
return ( return (
// @ts-expect-error className exists // @ts-expect-error className exists
(node.className === "checked" ? "- [x]" : "- [ ]") + ` ${content} \n` (node.className === "checked" ? "- [x]" : "- [ ]") + ` ${content} \n`

View File

@@ -13,7 +13,7 @@ export function CannotUseWithout(
registerDecorator({ registerDecorator({
name: "cannotUseWithout", name: "cannotUseWithout",
target: object.constructor, target: object.constructor,
propertyName: propertyName, propertyName,
constraints: [property], constraints: [property],
options: validationOptions, options: validationOptions,
validator: { validator: {

View File

@@ -174,7 +174,7 @@ export default class Image extends Node {
src: img?.getAttribute("src"), src: img?.getAttribute("src"),
alt: img?.getAttribute("alt"), alt: img?.getAttribute("alt"),
title: img?.getAttribute("title"), title: img?.getAttribute("title"),
layoutClass: layoutClass, layoutClass,
}; };
}, },
}, },

View File

@@ -6,7 +6,7 @@ export default function notice(md: MarkdownIt): void {
return customFence(md, "notice", { return customFence(md, "notice", {
marker: ":", marker: ":",
validate: () => true, validate: () => true,
render: function (tokens: Token[], idx: number) { render(tokens: Token[], idx: number) {
const { info } = tokens[idx]; const { info } = tokens[idx];
if (tokens[idx].nesting === 1) { if (tokens[idx].nesting === 1) {