You've already forked focalboard
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:
2
.gitignore
vendored
2
.gitignore
vendored
@ -37,3 +37,5 @@ __debug_bin
|
||||
files
|
||||
octo*.db
|
||||
.eslintcache
|
||||
.vscode/settings.json
|
||||
.prettierrc.json
|
||||
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"useTabs": true,
|
||||
"semi": false
|
||||
}
|
@ -4,7 +4,7 @@ class FlashMessage {
|
||||
//
|
||||
// Show a temporary status message
|
||||
//
|
||||
static show(text: string, delay = 800) {
|
||||
static show(text: string, delay = 800): void {
|
||||
const flashPanel = document.createElement('div')
|
||||
flashPanel.innerText = text
|
||||
flashPanel.classList.add('flashPanel')
|
||||
|
@ -24,7 +24,7 @@ class PropertyMenu extends Menu {
|
||||
this.subMenuOptions.set('type', typeMenuOptions)
|
||||
}
|
||||
|
||||
createMenuElement() {
|
||||
createMenuElement(): HTMLElement {
|
||||
const menu = Utils.htmlToElement('<div class="menu noselect" style="min-width: 200px;"></div>')
|
||||
|
||||
const ul = menu.appendChild(Utils.htmlToElement('<ul class="menu-options"></ul>'))
|
||||
@ -50,7 +50,8 @@ class PropertyMenu extends Menu {
|
||||
}
|
||||
nameTextbox.onkeydown = (e) => {
|
||||
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
|
||||
}
|
||||
|
||||
showAt(left: number, top: number) {
|
||||
showAt(left: number, top: number): void {
|
||||
this.options = [
|
||||
{id: 'type', name: this.typeDisplayName(this.property.type), type: 'submenu'},
|
||||
{id: 'delete', name: 'Delete'},
|
||||
@ -90,8 +91,11 @@ class PropertyMenu extends Menu {
|
||||
case 'createdBy': return 'Created By'
|
||||
case 'updatedTime': return 'Updated Time'
|
||||
case 'updatedBy': return 'Updated By'
|
||||
}
|
||||
default: {
|
||||
Utils.assertFailure(`typeDisplayName, unhandled type: ${type}`)
|
||||
return type
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,7 @@ class UndoManager {
|
||||
let checkpoint: number
|
||||
if (isDiscardable) {
|
||||
checkpoint =
|
||||
this.commands.length > 1 ?
|
||||
this.commands[this.commands.length - 1].checkpoint :
|
||||
0
|
||||
this.commands.length > 1 ? this.commands[this.commands.length - 1].checkpoint : 0
|
||||
} else {
|
||||
checkpoint = Date.now()
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ declare global {
|
||||
}
|
||||
|
||||
class Utils {
|
||||
static createGuid() {
|
||||
static createGuid(): string {
|
||||
const crypto = window.crypto || window.msCrypto
|
||||
function randomDigit() {
|
||||
if (crypto && crypto.getRandomValues) {
|
||||
@ -25,8 +25,7 @@ class Utils {
|
||||
|
||||
static htmlToElement(html: string): HTMLElement {
|
||||
const template = document.createElement('template')
|
||||
html = html.trim()
|
||||
template.innerHTML = html
|
||||
template.innerHTML = html.trim()
|
||||
return template.content.firstChild as HTMLElement
|
||||
}
|
||||
|
||||
@ -36,11 +35,11 @@ class Utils {
|
||||
return element!
|
||||
}
|
||||
|
||||
static htmlEncode(text: string) {
|
||||
static htmlEncode(text: string): string {
|
||||
return String(text).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
||||
}
|
||||
|
||||
static htmlDecode(text: string) {
|
||||
static htmlDecode(text: string): string {
|
||||
return String(text).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ class Utils {
|
||||
|
||||
// Errors
|
||||
|
||||
static assertValue(valueObject: any) {
|
||||
static assertValue(valueObject: any): void {
|
||||
const name = Object.keys(valueObject)[0]
|
||||
const value = valueObject[name]
|
||||
if (!value) {
|
||||
@ -85,7 +84,7 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static assert(condition: any, tag = '') {
|
||||
static assert(condition: any, tag = ''): void {
|
||||
/// #!if ENV !== "production"
|
||||
if (!condition) {
|
||||
Utils.logError(`ASSERT [${tag ?? new Error().stack}]`)
|
||||
@ -94,24 +93,26 @@ class Utils {
|
||||
/// #!endif
|
||||
}
|
||||
|
||||
static assertFailure(tag = '') {
|
||||
static assertFailure(tag = ''): void {
|
||||
/// #!if ENV !== "production"
|
||||
Utils.assert(false, tag)
|
||||
|
||||
/// #!endif
|
||||
}
|
||||
|
||||
static log(message: string) {
|
||||
static log(message: string): void {
|
||||
/// #!if ENV !== "production"
|
||||
const timestamp = (Date.now() / 1000).toFixed(2)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`[${timestamp}] ${message}`)
|
||||
|
||||
/// #!endif
|
||||
}
|
||||
|
||||
static logError(message: any) {
|
||||
static logError(message: string): void {
|
||||
/// #!if ENV !== "production"
|
||||
const timestamp = (Date.now() / 1000).toFixed(2)
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`[${timestamp}] ${message}`)
|
||||
|
||||
/// #!endif
|
||||
@ -119,7 +120,7 @@ class Utils {
|
||||
|
||||
// favicon
|
||||
|
||||
static setFavicon(icon?: string) {
|
||||
static setFavicon(icon?: string): void {
|
||||
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>` :
|
||||
''
|
||||
@ -132,7 +133,7 @@ class Utils {
|
||||
|
||||
// File names
|
||||
|
||||
static sanitizeFilename(filename: string) {
|
||||
static sanitizeFilename(filename: string): string {
|
||||
// TODO: Use an industrial-strength sanitizer
|
||||
let sanitizedFilename = filename
|
||||
const illegalCharacters = ['\\', '/', '?', ':', '<', '>', '*', '|', '"', '.']
|
||||
@ -162,7 +163,7 @@ class Utils {
|
||||
|
||||
// Arrays
|
||||
|
||||
static arraysEqual(a: any[], b: any[]) {
|
||||
static arraysEqual(a: any[], b: any[]): boolean {
|
||||
if (a === b) {
|
||||
return true
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ import {OctoUtils} from './octoUtils'
|
||||
class WorkspaceTree {
|
||||
boards: Board[] = []
|
||||
|
||||
async sync() {
|
||||
async sync(): Promise<void> {
|
||||
const blocks = await octoClient.getBlocks(undefined, 'board')
|
||||
this.rebuild(OctoUtils.hydrateBlocks(blocks))
|
||||
}
|
||||
|
||||
private rebuild(blocks: Block[]) {
|
||||
private rebuild(blocks: Block[]): void {
|
||||
this.boards = blocks.filter((block) => block.type === 'board') as Board[]
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
const webpack = require("webpack")
|
||||
const path = require("path")
|
||||
const CopyPlugin = require("copy-webpack-plugin")
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
const path = require('path');
|
||||
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() {
|
||||
const commonConfig = {
|
||||
target: "web",
|
||||
mode: "development",
|
||||
entry: "./index.js",
|
||||
target: 'web',
|
||||
mode: 'development',
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false
|
||||
__filename: false,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: "ts-loader",
|
||||
use: 'ts-loader',
|
||||
exclude: [/node_modules/],
|
||||
},
|
||||
{
|
||||
test: /\.html$/,
|
||||
loader: "file-loader",
|
||||
loader: 'file-loader',
|
||||
},
|
||||
{
|
||||
test: /\.s[ac]ss$/i,
|
||||
@ -38,8 +38,8 @@ function makeCommonConfig() {
|
||||
use: [
|
||||
],
|
||||
exclude: [/node_modules/],
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
modules: [
|
||||
@ -51,29 +51,29 @@ function makeCommonConfig() {
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{ from: path.resolve(__dirname, "static"), to: "static" },
|
||||
{ from: path.resolve(__dirname, "node_modules/easymde/dist/easymde.min.css"), to: "static" },
|
||||
{from: path.resolve(__dirname, 'static'), to: 'static'},
|
||||
{from: path.resolve(__dirname, 'node_modules/easymde/dist/easymde.min.css'), to: 'static'},
|
||||
],
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true,
|
||||
title: "OCTO",
|
||||
chunks: ["main"],
|
||||
template: "html-templates/page.ejs",
|
||||
title: 'OCTO',
|
||||
chunks: ['main'],
|
||||
template: 'html-templates/page.ejs',
|
||||
filename: 'index.html',
|
||||
publicPath: '/'
|
||||
publicPath: '/',
|
||||
}),
|
||||
],
|
||||
entry: {
|
||||
main: "./src/main.tsx",
|
||||
main: './src/main.tsx',
|
||||
},
|
||||
output: {
|
||||
filename: "static/[name].js",
|
||||
path: outpath
|
||||
}
|
||||
}
|
||||
filename: 'static/[name].js',
|
||||
path: outpath,
|
||||
},
|
||||
};
|
||||
|
||||
return commonConfig
|
||||
return commonConfig;
|
||||
}
|
||||
|
||||
module.exports = makeCommonConfig
|
||||
module.exports = makeCommonConfig;
|
||||
|
@ -1,14 +1,17 @@
|
||||
const merge = require("webpack-merge");
|
||||
const makeCommonConfig = require("./webpack.common.js");
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
const merge = require('webpack-merge');
|
||||
|
||||
const makeCommonConfig = require('./webpack.common.js');
|
||||
|
||||
const commonConfig = makeCommonConfig();
|
||||
|
||||
const config = merge.merge(commonConfig, {
|
||||
mode: "development",
|
||||
devtool: "inline-source-map",
|
||||
mode: 'development',
|
||||
devtool: 'inline-source-map',
|
||||
optimization: {
|
||||
minimize: false
|
||||
}
|
||||
minimize: false,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = [
|
||||
|
@ -1,15 +1,18 @@
|
||||
const merge = require("webpack-merge");
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
const makeCommonConfig = require("./webpack.common.js");
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
const merge = require('webpack-merge');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
const makeCommonConfig = require('./webpack.common.js');
|
||||
|
||||
const commonConfig = makeCommonConfig();
|
||||
|
||||
const config = merge.merge(commonConfig, {
|
||||
mode: "production",
|
||||
mode: 'production',
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [new TerserPlugin({})]
|
||||
}
|
||||
minimizer: [new TerserPlugin({})],
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = [
|
||||
|
Reference in New Issue
Block a user