1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-07-12 23:50:27 +02:00

Cleanup some eslint issues.

This commit is contained in:
Chen-I Lim
2020-10-20 13:26:06 -07:00
parent 9255bd4ded
commit c95ab685e4
11 changed files with 159 additions and 153 deletions

2
.gitignore vendored
View File

@ -37,3 +37,5 @@ __debug_bin
files files
octo*.db octo*.db
.eslintcache .eslintcache
.vscode/settings.json
.prettierrc.json

View File

@ -1,5 +0,0 @@
{
"tabWidth": 4,
"useTabs": true,
"semi": false
}

View File

@ -4,7 +4,7 @@ class FlashMessage {
// //
// Show a temporary status message // Show a temporary status message
// //
static show(text: string, delay = 800) { static show(text: string, delay = 800): void {
const flashPanel = document.createElement('div') const flashPanel = document.createElement('div')
flashPanel.innerText = text flashPanel.innerText = text
flashPanel.classList.add('flashPanel') flashPanel.classList.add('flashPanel')

View File

@ -24,7 +24,7 @@ class PropertyMenu extends Menu {
this.subMenuOptions.set('type', typeMenuOptions) this.subMenuOptions.set('type', typeMenuOptions)
} }
createMenuElement() { createMenuElement(): HTMLElement {
const menu = Utils.htmlToElement('<div class="menu noselect" style="min-width: 200px;"></div>') const menu = Utils.htmlToElement('<div class="menu noselect" style="min-width: 200px;"></div>')
const ul = menu.appendChild(Utils.htmlToElement('<ul class="menu-options"></ul>')) const ul = menu.appendChild(Utils.htmlToElement('<ul class="menu-options"></ul>'))
@ -50,7 +50,8 @@ class PropertyMenu extends Menu {
} }
nameTextbox.onkeydown = (e) => { nameTextbox.onkeydown = (e) => {
if (e.keyCode === 13 || e.keyCode === 27) { if (e.keyCode === 13 || e.keyCode === 27) {
nameTextbox.blur(); e.stopPropagation() nameTextbox.blur()
e.stopPropagation()
} }
} }
@ -61,7 +62,7 @@ class PropertyMenu extends Menu {
return menu return menu
} }
showAt(left: number, top: number) { showAt(left: number, top: number): void {
this.options = [ this.options = [
{id: 'type', name: this.typeDisplayName(this.property.type), type: 'submenu'}, {id: 'type', name: this.typeDisplayName(this.property.type), type: 'submenu'},
{id: 'delete', name: 'Delete'}, {id: 'delete', name: 'Delete'},
@ -90,8 +91,11 @@ class PropertyMenu extends Menu {
case 'createdBy': return 'Created By' case 'createdBy': return 'Created By'
case 'updatedTime': return 'Updated Time' case 'updatedTime': return 'Updated Time'
case 'updatedBy': return 'Updated By' case 'updatedBy': return 'Updated By'
} default: {
Utils.assertFailure(`typeDisplayName, unhandled type: ${type}`) Utils.assertFailure(`typeDisplayName, unhandled type: ${type}`)
return type
}
}
} }
} }

View File

@ -83,9 +83,7 @@ class UndoManager {
let checkpoint: number let checkpoint: number
if (isDiscardable) { if (isDiscardable) {
checkpoint = checkpoint =
this.commands.length > 1 ? this.commands.length > 1 ? this.commands[this.commands.length - 1].checkpoint : 0
this.commands[this.commands.length - 1].checkpoint :
0
} else { } else {
checkpoint = Date.now() checkpoint = Date.now()
} }

View File

@ -9,7 +9,7 @@ declare global {
} }
class Utils { class Utils {
static createGuid() { static createGuid(): string {
const crypto = window.crypto || window.msCrypto const crypto = window.crypto || window.msCrypto
function randomDigit() { function randomDigit() {
if (crypto && crypto.getRandomValues) { if (crypto && crypto.getRandomValues) {
@ -25,8 +25,7 @@ class Utils {
static htmlToElement(html: string): HTMLElement { static htmlToElement(html: string): HTMLElement {
const template = document.createElement('template') const template = document.createElement('template')
html = html.trim() template.innerHTML = html.trim()
template.innerHTML = html
return template.content.firstChild as HTMLElement return template.content.firstChild as HTMLElement
} }
@ -36,11 +35,11 @@ class Utils {
return element! return element!
} }
static htmlEncode(text: string) { static htmlEncode(text: string): string {
return String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') return String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
} }
static htmlDecode(text: string) { static htmlDecode(text: string): string {
return String(text).replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"') return String(text).replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"')
} }
@ -77,7 +76,7 @@ class Utils {
// Errors // Errors
static assertValue(valueObject: any) { static assertValue(valueObject: any): void {
const name = Object.keys(valueObject)[0] const name = Object.keys(valueObject)[0]
const value = valueObject[name] const value = valueObject[name]
if (!value) { if (!value) {
@ -85,7 +84,7 @@ class Utils {
} }
} }
static assert(condition: any, tag = '') { static assert(condition: any, tag = ''): void {
/// #!if ENV !== "production" /// #!if ENV !== "production"
if (!condition) { if (!condition) {
Utils.logError(`ASSERT [${tag ?? new Error().stack}]`) Utils.logError(`ASSERT [${tag ?? new Error().stack}]`)
@ -94,24 +93,26 @@ class Utils {
/// #!endif /// #!endif
} }
static assertFailure(tag = '') { static assertFailure(tag = ''): void {
/// #!if ENV !== "production" /// #!if ENV !== "production"
Utils.assert(false, tag) Utils.assert(false, tag)
/// #!endif /// #!endif
} }
static log(message: string) { static log(message: string): void {
/// #!if ENV !== "production" /// #!if ENV !== "production"
const timestamp = (Date.now() / 1000).toFixed(2) const timestamp = (Date.now() / 1000).toFixed(2)
// eslint-disable-next-line no-console
console.log(`[${timestamp}] ${message}`) console.log(`[${timestamp}] ${message}`)
/// #!endif /// #!endif
} }
static logError(message: any) { static logError(message: string): void {
/// #!if ENV !== "production" /// #!if ENV !== "production"
const timestamp = (Date.now() / 1000).toFixed(2) const timestamp = (Date.now() / 1000).toFixed(2)
// eslint-disable-next-line no-console
console.error(`[${timestamp}] ${message}`) console.error(`[${timestamp}] ${message}`)
/// #!endif /// #!endif
@ -119,7 +120,7 @@ class Utils {
// favicon // favicon
static setFavicon(icon?: string) { static setFavicon(icon?: string): void {
const href = icon ? const href = icon ?
`data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="90">${icon}</text></svg>` : `data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="90">${icon}</text></svg>` :
'' ''
@ -132,7 +133,7 @@ class Utils {
// File names // File names
static sanitizeFilename(filename: string) { static sanitizeFilename(filename: string): string {
// TODO: Use an industrial-strength sanitizer // TODO: Use an industrial-strength sanitizer
let sanitizedFilename = filename let sanitizedFilename = filename
const illegalCharacters = ['\\', '/', '?', ':', '<', '>', '*', '|', '"', '.'] const illegalCharacters = ['\\', '/', '?', ':', '<', '>', '*', '|', '"', '.']
@ -162,7 +163,7 @@ class Utils {
// Arrays // Arrays
static arraysEqual(a: any[], b: any[]) { static arraysEqual(a: any[], b: any[]): boolean {
if (a === b) { if (a === b) {
return true return true
} }

View File

@ -8,12 +8,12 @@ import {OctoUtils} from './octoUtils'
class WorkspaceTree { class WorkspaceTree {
boards: Board[] = [] boards: Board[] = []
async sync() { async sync(): Promise<void> {
const blocks = await octoClient.getBlocks(undefined, 'board') const blocks = await octoClient.getBlocks(undefined, 'board')
this.rebuild(OctoUtils.hydrateBlocks(blocks)) this.rebuild(OctoUtils.hydrateBlocks(blocks))
} }
private rebuild(blocks: Block[]) { private rebuild(blocks: Block[]): void {
this.boards = blocks.filter((block) => block.type === 'board') as Board[] this.boards = blocks.filter((block) => block.type === 'board') as Board[]
} }
} }

View File

@ -1,29 +1,29 @@
const webpack = require("webpack") // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
const path = require("path") // See LICENSE.txt for license information.
const CopyPlugin = require("copy-webpack-plugin") const path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin') const CopyPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const outpath = path.resolve(__dirname, "pack") const outpath = path.resolve(__dirname, 'pack');
function makeCommonConfig() { function makeCommonConfig() {
const commonConfig = { const commonConfig = {
target: "web", target: 'web',
mode: "development", mode: 'development',
entry: "./index.js",
node: { node: {
__dirname: false, __dirname: false,
__filename: false __filename: false,
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
use: "ts-loader", use: 'ts-loader',
exclude: [/node_modules/], exclude: [/node_modules/],
}, },
{ {
test: /\.html$/, test: /\.html$/,
loader: "file-loader", loader: 'file-loader',
}, },
{ {
test: /\.s[ac]ss$/i, test: /\.s[ac]ss$/i,
@ -38,8 +38,8 @@ function makeCommonConfig() {
use: [ use: [
], ],
exclude: [/node_modules/], exclude: [/node_modules/],
} },
] ],
}, },
resolve: { resolve: {
modules: [ modules: [
@ -51,29 +51,29 @@ function makeCommonConfig() {
plugins: [ plugins: [
new CopyPlugin({ new CopyPlugin({
patterns: [ patterns: [
{ from: path.resolve(__dirname, "static"), to: "static" }, {from: path.resolve(__dirname, 'static'), to: 'static'},
{ from: path.resolve(__dirname, "node_modules/easymde/dist/easymde.min.css"), to: "static" }, {from: path.resolve(__dirname, 'node_modules/easymde/dist/easymde.min.css'), to: 'static'},
], ],
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: true, inject: true,
title: "OCTO", title: 'OCTO',
chunks: ["main"], chunks: ['main'],
template: "html-templates/page.ejs", template: 'html-templates/page.ejs',
filename: 'index.html', filename: 'index.html',
publicPath: '/' publicPath: '/',
}), }),
], ],
entry: { entry: {
main: "./src/main.tsx", main: './src/main.tsx',
}, },
output: { output: {
filename: "static/[name].js", filename: 'static/[name].js',
path: outpath path: outpath,
} },
};
return commonConfig;
} }
return commonConfig module.exports = makeCommonConfig;
}
module.exports = makeCommonConfig

View File

@ -1,14 +1,17 @@
const merge = require("webpack-merge"); // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
const makeCommonConfig = require("./webpack.common.js"); // See LICENSE.txt for license information.
const merge = require('webpack-merge');
const makeCommonConfig = require('./webpack.common.js');
const commonConfig = makeCommonConfig(); const commonConfig = makeCommonConfig();
const config = merge.merge(commonConfig, { const config = merge.merge(commonConfig, {
mode: "development", mode: 'development',
devtool: "inline-source-map", devtool: 'inline-source-map',
optimization: { optimization: {
minimize: false minimize: false,
} },
}); });
module.exports = [ module.exports = [

View File

@ -1,15 +1,18 @@
const merge = require("webpack-merge"); // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
const TerserPlugin = require("terser-webpack-plugin"); // See LICENSE.txt for license information.
const makeCommonConfig = require("./webpack.common.js"); const merge = require('webpack-merge');
const TerserPlugin = require('terser-webpack-plugin');
const makeCommonConfig = require('./webpack.common.js');
const commonConfig = makeCommonConfig(); const commonConfig = makeCommonConfig();
const config = merge.merge(commonConfig, { const config = merge.merge(commonConfig, {
mode: "production", mode: 'production',
optimization: { optimization: {
minimize: true, minimize: true,
minimizer: [new TerserPlugin({})] minimizer: [new TerserPlugin({})],
} },
}); });
module.exports = [ module.exports = [