mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Cheer up eslint
This commit is contained in:
parent
6f905a5e8a
commit
cbe331e796
9 changed files with 68 additions and 63 deletions
|
@ -58,6 +58,10 @@ export abstract class CompletionSource {
|
||||||
this.prefixes = this.prefixes.map(p => p + " ")
|
this.prefixes = this.prefixes.map(p => p + " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get state() {
|
||||||
|
return this._state
|
||||||
|
}
|
||||||
|
|
||||||
/** Control presentation of Source */
|
/** Control presentation of Source */
|
||||||
set state(newstate: OptionState) {
|
set state(newstate: OptionState) {
|
||||||
switch (newstate) {
|
switch (newstate) {
|
||||||
|
@ -73,10 +77,6 @@ export abstract class CompletionSource {
|
||||||
this._state = newstate
|
this._state = newstate
|
||||||
}
|
}
|
||||||
|
|
||||||
get state() {
|
|
||||||
return this._state
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldRefresh() {
|
shouldRefresh() {
|
||||||
// A completion source should be refreshed if it is not hidden or if it just became hidden
|
// A completion source should be refreshed if it is not hidden or if it just became hidden
|
||||||
return this._state !== "hidden" || this.state !== this._prevState
|
return this._state !== "hidden" || this.state !== this._prevState
|
||||||
|
@ -105,6 +105,10 @@ export abstract class CompletionOptionHTML extends CompletionOption {
|
||||||
|
|
||||||
private _state: OptionState = "hidden"
|
private _state: OptionState = "hidden"
|
||||||
|
|
||||||
|
get state() {
|
||||||
|
return this._state
|
||||||
|
}
|
||||||
|
|
||||||
/** Control presentation of element */
|
/** Control presentation of element */
|
||||||
set state(newstate: OptionState) {
|
set state(newstate: OptionState) {
|
||||||
// console.log("state from to", this._state, newstate)
|
// console.log("state from to", this._state, newstate)
|
||||||
|
@ -133,10 +137,6 @@ export abstract class CompletionOptionHTML extends CompletionOption {
|
||||||
}
|
}
|
||||||
this._state = newstate
|
this._state = newstate
|
||||||
}
|
}
|
||||||
|
|
||||||
get state() {
|
|
||||||
return this._state
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompletionOptionFuse extends CompletionOptionHTML {
|
export interface CompletionOptionFuse extends CompletionOptionHTML {
|
||||||
|
@ -332,7 +332,7 @@ export abstract class CompletionSourceFuse extends CompletionSource {
|
||||||
/* abstract onUpdate(query: string, prefix: string, options: CompletionOptionFuse[]) */
|
/* abstract onUpdate(query: string, prefix: string, options: CompletionOptionFuse[]) */
|
||||||
|
|
||||||
// Lots of methods don't need this but some do
|
// Lots of methods don't need this but some do
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars-experimental
|
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars
|
||||||
async onInput(exstr: string) {}
|
async onInput(exstr: string) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ export class CompositeCompletionSource extends Completions.CompletionSourceFuse
|
||||||
return this.updateOptions(exstr)
|
return this.updateOptions(exstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
updateChain(exstr = this.lastExstr, options = this.options) {
|
updateChain(exstr = this.lastExstr, options = this.options) {
|
||||||
if (this.options.length > 0) this.state = "normal"
|
if (this.options.length > 0) this.state = "normal"
|
||||||
else this.state = "hidden"
|
else this.state = "hidden"
|
||||||
|
|
|
@ -37,7 +37,7 @@ export class ExcmdCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
return this.updateOptions(exstr)
|
return this.updateOptions(exstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
updateChain(exstr = this.lastExstr, options = this.options) {
|
updateChain(exstr = this.lastExstr, options = this.options) {
|
||||||
if (this.options.length > 0) this.state = "normal"
|
if (this.options.length > 0) this.state = "normal"
|
||||||
else this.state = "hidden"
|
else this.state = "hidden"
|
||||||
|
|
|
@ -717,7 +717,7 @@ class Hint {
|
||||||
height: rect.height,
|
height: rect.height,
|
||||||
x: undefined,
|
x: undefined,
|
||||||
y: undefined,
|
y: undefined,
|
||||||
toJSON: () => {},
|
toJSON: () => {/* just to make typescript happy, never used */},
|
||||||
}
|
}
|
||||||
|
|
||||||
this.flag.textContent = name
|
this.flag.textContent = name
|
||||||
|
@ -737,13 +737,25 @@ class Hint {
|
||||||
this.hidden = false
|
this.hidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isHintable(target: Element): boolean {
|
get x() {
|
||||||
return target.getClientRects().length > 0
|
return this._x
|
||||||
}
|
}
|
||||||
|
|
||||||
setName(n: string) {
|
set x(X: number) {
|
||||||
this.name = n
|
this._x = X
|
||||||
this.flag.textContent = this.name
|
this.updatePosition()
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint wants all gets to be before all sets but also wants all overloads to be grouped
|
||||||
|
// which isn't possible afaict
|
||||||
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
||||||
|
get y() {
|
||||||
|
return this._y
|
||||||
|
}
|
||||||
|
|
||||||
|
set y(Y: number) {
|
||||||
|
this._y = Y
|
||||||
|
this.updatePosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
// These styles would be better with pseudo selectors. Can we do custom ones?
|
// These styles would be better with pseudo selectors. Can we do custom ones?
|
||||||
|
@ -768,28 +780,19 @@ class Hint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static isHintable(target: Element): boolean {
|
||||||
|
return target.getClientRects().length > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(n: string) {
|
||||||
|
this.name = n
|
||||||
|
this.flag.textContent = this.name
|
||||||
|
}
|
||||||
|
|
||||||
select() {
|
select() {
|
||||||
this.onSelect(this)
|
this.onSelect(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
set x(X: number) {
|
|
||||||
this._x = X
|
|
||||||
this.updatePosition()
|
|
||||||
}
|
|
||||||
|
|
||||||
get x() {
|
|
||||||
return this._x
|
|
||||||
}
|
|
||||||
|
|
||||||
set y(Y: number) {
|
|
||||||
this._y = Y
|
|
||||||
this.updatePosition()
|
|
||||||
}
|
|
||||||
|
|
||||||
get y() {
|
|
||||||
return this._y
|
|
||||||
}
|
|
||||||
|
|
||||||
public overlapsWith(h: Hint) {
|
public overlapsWith(h: Hint) {
|
||||||
if (h.width == 0) h.width = h.flag.getClientRects()[0].width
|
if (h.width == 0) h.width = h.flag.getClientRects()[0].width
|
||||||
if (h.height == 0) h.height = h.flag.getClientRects()[0].height
|
if (h.height == 0) h.height = h.flag.getClientRects()[0].height
|
||||||
|
|
|
@ -5688,9 +5688,9 @@ export function echo(...str: string[]) {
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
async function js_helper(str: string[]) {
|
async function js_helper(str: string[]) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
let JS_ARG = null
|
let JS_ARG = null
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
let JS_ARGS = []
|
let JS_ARGS = []
|
||||||
let jsContent: string = null
|
let jsContent: string = null
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ export function wrap_input(
|
||||||
/**
|
/**
|
||||||
* Take an editor function as parameter and wrap it in a function that will handle error conditions
|
* Take an editor function as parameter and wrap it in a function that will handle error conditions
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function needs_text(fn: editor_function, arg?: any): editor_function {
|
export function needs_text(fn: editor_function, arg?: any): editor_function {
|
||||||
return (
|
return (
|
||||||
text: string,
|
text: string,
|
||||||
|
|
|
@ -68,6 +68,15 @@ export class HintConfig implements HintOptions {
|
||||||
public selectorsExclude = []
|
public selectorsExclude = []
|
||||||
public warnings = []
|
public warnings = []
|
||||||
|
|
||||||
|
public get isYank() {
|
||||||
|
return (
|
||||||
|
this.openMode === OpenMode.YankAnchor ||
|
||||||
|
this.openMode === OpenMode.YankAlt ||
|
||||||
|
this.openMode === OpenMode.YankLink ||
|
||||||
|
this.openMode === OpenMode.YankText
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
public static parse(args: string[]): HintConfig {
|
public static parse(args: string[]): HintConfig {
|
||||||
// Argument parser state
|
// Argument parser state
|
||||||
enum State {
|
enum State {
|
||||||
|
@ -430,13 +439,4 @@ export class HintConfig implements HintOptions {
|
||||||
|
|
||||||
return hintables
|
return hintables
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isYank() {
|
|
||||||
return (
|
|
||||||
this.openMode === OpenMode.YankAnchor ||
|
|
||||||
this.openMode === OpenMode.YankAlt ||
|
|
||||||
this.openMode === OpenMode.YankLink ||
|
|
||||||
this.openMode === OpenMode.YankText
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,22 @@ export class Logger {
|
||||||
*/
|
*/
|
||||||
constructor(private logModule) {}
|
constructor(private logModule) {}
|
||||||
|
|
||||||
|
// These are all getters so that logger.debug = console.debug and
|
||||||
|
// logger.debug('blah') translates into console.debug('blah') with the
|
||||||
|
// filename and line correct.
|
||||||
|
public get debug() {
|
||||||
|
return this.log("debug")
|
||||||
|
}
|
||||||
|
public get info() {
|
||||||
|
return this.log("info")
|
||||||
|
}
|
||||||
|
public get warning() {
|
||||||
|
return this.log("warning")
|
||||||
|
}
|
||||||
|
public get error() {
|
||||||
|
return this.log("error")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config-aware logging function.
|
* Config-aware logging function.
|
||||||
*
|
*
|
||||||
|
@ -61,22 +77,6 @@ export class Logger {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
return function() {}
|
return function() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are all getters so that logger.debug = console.debug and
|
|
||||||
// logger.debug('blah') translates into console.debug('blah') with the
|
|
||||||
// filename and line correct.
|
|
||||||
public get debug() {
|
|
||||||
return this.log("debug")
|
|
||||||
}
|
|
||||||
public get info() {
|
|
||||||
return this.log("info")
|
|
||||||
}
|
|
||||||
public get warning() {
|
|
||||||
return this.log("warning")
|
|
||||||
}
|
|
||||||
public get error() {
|
|
||||||
return this.log("error")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Logger
|
export default Logger
|
||||||
|
|
2
src/tridactyl.d.ts
vendored
2
src/tridactyl.d.ts
vendored
|
@ -3,6 +3,8 @@
|
||||||
// For some obscure reason, tsc doesn't like .d.ts files to share a name with
|
// For some obscure reason, tsc doesn't like .d.ts files to share a name with
|
||||||
// .ts files. So don't do that.
|
// .ts files. So don't do that.
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
|
||||||
// Ill-advised monkeypatching
|
// Ill-advised monkeypatching
|
||||||
interface Number {
|
interface Number {
|
||||||
mod(n: number): number
|
mod(n: number): number
|
||||||
|
|
Loading…
Add table
Reference in a new issue