mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-27 08:31:20 +02:00
Cleanup some eslint issues.
This commit is contained in:
parent
9255bd4ded
commit
c95ab685e4
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,15 +4,15 @@ import {MenuOption} from './menu'
|
||||
|
||||
class Constants {
|
||||
static menuColors: MenuOption[] = [
|
||||
{id: 'propColorDefault', name: 'Default', type: 'color'},
|
||||
{id: 'propColorDefault', name: 'Default', type: 'color'},
|
||||
{id: 'propColorGray', name: 'Gray', type: 'color'},
|
||||
{id: 'propColorBrown', name: 'Brown', type: 'color'},
|
||||
{id: 'propColorOrange', name: 'Orange', type: 'color'},
|
||||
{id: 'propColorOrange', name: 'Orange', type: 'color'},
|
||||
{id: 'propColorYellow', name: 'Yellow', type: 'color'},
|
||||
{id: 'propColorGreen', name: 'Green', type: 'color'},
|
||||
{id: 'propColorBlue', name: 'Blue', type: 'color'},
|
||||
{id: 'propColorPurple', name: 'Purple', type: 'color'},
|
||||
{id: 'propColorPink', name: 'Pink', type: 'color'},
|
||||
{id: 'propColorPink', name: 'Pink', type: 'color'},
|
||||
{id: 'propColorRed', name: 'Red', type: 'color'},
|
||||
]
|
||||
}
|
||||
|
@ -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')
|
||||
|
@ -14,84 +14,88 @@ class PropertyMenu extends Menu {
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
const typeMenuOptions = [
|
||||
const typeMenuOptions = [
|
||||
{id: 'text', name: 'Text'},
|
||||
{id: 'number', name: 'Number'},
|
||||
{id: 'number', name: 'Number'},
|
||||
{id: 'select', name: 'Select'},
|
||||
{id: 'createdTime', name: 'Created Time'},
|
||||
{id: 'updatedTime', name: 'Updated Time'},
|
||||
]
|
||||
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 ul = menu.appendChild(Utils.htmlToElement('<ul class="menu-options"></ul>'))
|
||||
|
||||
const nameTextbox = ul.appendChild(Utils.htmlToElement('<li class="menu-textbox"></li>'))
|
||||
this.nameTextbox = nameTextbox
|
||||
this.nameTextbox = nameTextbox
|
||||
let propertyValue = this.property ? this.property.name : ''
|
||||
nameTextbox.innerText = propertyValue
|
||||
nameTextbox.innerText = propertyValue
|
||||
nameTextbox.contentEditable = 'true'
|
||||
nameTextbox.onclick = (e) => {
|
||||
e.stopPropagation()
|
||||
}
|
||||
nameTextbox.onblur = () => {
|
||||
if (nameTextbox.innerText !== propertyValue) {
|
||||
propertyValue = nameTextbox.innerText
|
||||
nameTextbox.onclick = (e) => {
|
||||
e.stopPropagation()
|
||||
}
|
||||
nameTextbox.onblur = () => {
|
||||
if (nameTextbox.innerText !== propertyValue) {
|
||||
propertyValue = nameTextbox.innerText
|
||||
if (this.onNameChanged) {
|
||||
this.onNameChanged(nameTextbox.innerText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nameTextbox.onmouseenter = () => {
|
||||
this.hideSubMenu()
|
||||
}
|
||||
nameTextbox.onkeydown = (e) => {
|
||||
}
|
||||
nameTextbox.onkeydown = (e) => {
|
||||
if (e.keyCode === 13 || e.keyCode === 27) {
|
||||
nameTextbox.blur(); e.stopPropagation()
|
||||
nameTextbox.blur()
|
||||
e.stopPropagation()
|
||||
}
|
||||
}
|
||||
|
||||
ul.appendChild(Utils.htmlToElement('<li class="menu-separator"></li>'))
|
||||
ul.appendChild(Utils.htmlToElement('<li class="menu-separator"></li>'))
|
||||
|
||||
this.appendMenuOptions(ul)
|
||||
this.appendMenuOptions(ul)
|
||||
|
||||
return 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'},
|
||||
]
|
||||
]
|
||||
|
||||
super.showAt(left, top)
|
||||
super.showAt(left, top)
|
||||
setTimeout(() => {
|
||||
this.nameTextbox.focus()
|
||||
document.execCommand('selectAll', false, null)
|
||||
document.execCommand('selectAll', false, null)
|
||||
}, 20)
|
||||
}
|
||||
|
||||
private typeDisplayName(type: PropertyType): string {
|
||||
switch (type) {
|
||||
case 'text': return 'Text'
|
||||
case 'number': return 'Number'
|
||||
case 'select': return 'Select'
|
||||
case 'multiSelect': return 'Multi Select'
|
||||
case 'person': return 'Person'
|
||||
case 'text': return 'Text'
|
||||
case 'number': return 'Number'
|
||||
case 'select': return 'Select'
|
||||
case 'multiSelect': return 'Multi Select'
|
||||
case 'person': return 'Person'
|
||||
case 'file': return 'File or Media'
|
||||
case 'checkbox': return 'Checkbox'
|
||||
case 'url': return 'URL'
|
||||
case 'email': return 'Email'
|
||||
case 'email': return 'Email'
|
||||
case 'phone': return 'Phone'
|
||||
case 'createdTime': return 'Created Time'
|
||||
case 'createdTime': return 'Created Time'
|
||||
case 'createdBy': return 'Created By'
|
||||
case 'updatedTime': return 'Updated Time'
|
||||
case 'updatedBy': return 'Updated By'
|
||||
case 'updatedBy': return 'Updated By'
|
||||
default: {
|
||||
Utils.assertFailure(`typeDisplayName, unhandled type: ${type}`)
|
||||
return type
|
||||
}
|
||||
}
|
||||
Utils.assertFailure(`typeDisplayName, unhandled type: ${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))
|
||||
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,79 +1,79 @@
|
||||
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",
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: "ts-loader",
|
||||
exclude: [/node_modules/],
|
||||
},
|
||||
{
|
||||
test: /\.html$/,
|
||||
loader: "file-loader",
|
||||
},
|
||||
{
|
||||
test: /\.s[ac]ss$/i,
|
||||
use: [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
'sass-loader',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(tsx?|js|jsx|html)$/,
|
||||
use: [
|
||||
],
|
||||
exclude: [/node_modules/],
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
modules: [
|
||||
'node_modules',
|
||||
path.resolve(__dirname),
|
||||
],
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||
},
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{ 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",
|
||||
filename: 'index.html',
|
||||
publicPath: '/'
|
||||
}),
|
||||
],
|
||||
entry: {
|
||||
main: "./src/main.tsx",
|
||||
},
|
||||
output: {
|
||||
filename: "static/[name].js",
|
||||
path: outpath
|
||||
}
|
||||
}
|
||||
const commonConfig = {
|
||||
target: 'web',
|
||||
mode: 'development',
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: [/node_modules/],
|
||||
},
|
||||
{
|
||||
test: /\.html$/,
|
||||
loader: 'file-loader',
|
||||
},
|
||||
{
|
||||
test: /\.s[ac]ss$/i,
|
||||
use: [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
'sass-loader',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(tsx?|js|jsx|html)$/,
|
||||
use: [
|
||||
],
|
||||
exclude: [/node_modules/],
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
modules: [
|
||||
'node_modules',
|
||||
path.resolve(__dirname),
|
||||
],
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||
},
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{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',
|
||||
filename: 'index.html',
|
||||
publicPath: '/',
|
||||
}),
|
||||
],
|
||||
entry: {
|
||||
main: './src/main.tsx',
|
||||
},
|
||||
output: {
|
||||
filename: 'static/[name].js',
|
||||
path: outpath,
|
||||
},
|
||||
};
|
||||
|
||||
return commonConfig
|
||||
return commonConfig;
|
||||
}
|
||||
|
||||
module.exports = makeCommonConfig
|
||||
module.exports = makeCommonConfig;
|
||||
|
@ -1,17 +1,20 @@
|
||||
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",
|
||||
optimization: {
|
||||
minimize: false
|
||||
}
|
||||
mode: 'development',
|
||||
devtool: 'inline-source-map',
|
||||
optimization: {
|
||||
minimize: false,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = [
|
||||
merge.merge(config, {
|
||||
}),
|
||||
merge.merge(config, {
|
||||
}),
|
||||
];
|
||||
|
@ -1,18 +1,21 @@
|
||||
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",
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [new TerserPlugin({})]
|
||||
}
|
||||
mode: 'production',
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [new TerserPlugin({})],
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = [
|
||||
merge.merge(config, {
|
||||
}),
|
||||
merge.merge(config, {
|
||||
}),
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user