TSLint: re-enable no-string-literal rule

This commit is contained in:
glacambre 2019-04-03 19:09:49 +02:00
parent 600a324941
commit fd09bd6c1d
No known key found for this signature in database
GPG key ID: B9625DB1767553AC
10 changed files with 21 additions and 22 deletions

View file

@ -100,8 +100,7 @@ export class HistoryCompletionSource extends Completions.CompletionSourceFuse {
} }
private async scoreOptions(query: string, n: number) { private async scoreOptions(query: string, n: number) {
const newtab = browser.runtime.getManifest()["chrome_url_overrides"] const newtab = (browser.runtime.getManifest()).chrome_url_overrides.newtab
.newtab
const newtaburl = browser.extension.getURL(newtab) const newtaburl = browser.extension.getURL(newtab)
if (!query || config.get("historyresults") == 0) { if (!query || config.get("historyresults") == 0) {
return (await browserBg.topSites.get()) return (await browserBg.topSites.get())

View file

@ -56,7 +56,7 @@ export const contentState = (new Proxy(
logger.debug("Content state changed!", property, newValue) logger.debug("Content state changed!", property, newValue)
const oldValue = target[property] const oldValue = target[property]
const mode = target["mode"] const mode = target.mode
target[property] = newValue target[property] = newValue
for (let listener of onChangedListeners) { for (let listener of onChangedListeners) {

View file

@ -662,11 +662,11 @@ export async function restart() {
if ((await browser.runtime.getPlatformInfo()).os === "win") { if ((await browser.runtime.getPlatformInfo()).os === "win") {
let reply = await Native.winFirefoxRestart(profiledir, browsercmd) let reply = await Native.winFirefoxRestart(profiledir, browsercmd)
logger.info("[+] win_firefox_restart 'reply' = " + JSON.stringify(reply)) logger.info("[+] win_firefox_restart 'reply' = " + JSON.stringify(reply))
if (Number(reply["code"]) === 0) { if (Number(reply.code) === 0) {
fillcmdline("#" + reply["content"]) fillcmdline("#" + reply.content)
qall() qall()
} else { } else {
fillcmdline("#" + reply["error"]) fillcmdline("#" + reply.error)
} }
} else { } else {
const firefox = (await Native.ff_cmdline()).join(" ") const firefox = (await Native.ff_cmdline()).join(" ")
@ -1898,7 +1898,7 @@ export async function tabopen(...addressarr: string[]) {
} else if (args[0] === "-c") { } else if (args[0] === "-c") {
// Ignore the -c flag if incognito as containers are disabled. // Ignore the -c flag if incognito as containers are disabled.
let win = await browser.windows.getCurrent() let win = await browser.windows.getCurrent()
if (!win["incognito"]) container = await Container.fuzzyMatch(args[1]) if (!win.incognito) container = await Container.fuzzyMatch(args[1])
else logger.error("[tabopen] can't open a container in a private browsing window.") else logger.error("[tabopen] can't open a container in a private browsing window.")
args.shift() args.shift()
@ -2279,19 +2279,19 @@ export async function mute(...muteArgs: string[]): Promise<void> {
*/ */
//#background //#background
export async function winopen(...args: string[]) { export async function winopen(...args: string[]) {
const createData = {} const createData = {} as any
let firefoxArgs = "--new-window" let firefoxArgs = "--new-window"
let done = false let done = false
while (!done) { while (!done) {
switch (args[0]) { switch (args[0]) {
case "-private": case "-private":
createData["incognito"] = true createData.incognito = true
args = args.slice(1, args.length) args = args.slice(1, args.length)
firefoxArgs = "--private-window" firefoxArgs = "--private-window"
break break
case "-popup": case "-popup":
createData["type"] = "popup" createData.type = "popup"
args = args.slice(1, args.length) args = args.slice(1, args.length)
break break
@ -3599,7 +3599,7 @@ export async function hint(option?: string, selectors?: string, ...rest: string[
DOM.HINTTAGS_selectors, DOM.HINTTAGS_selectors,
elem => { elem => {
// /!\ Warning: This is racy! This can easily be fixed by adding an await but do we want this? yank can be pretty slow, especially with yankto=selection // /!\ Warning: This is racy! This can easily be fixed by adding an await but do we want this? yank can be pretty slow, especially with yankto=selection
run_exstr("yank " + elem["href"]) run_exstr("yank " + elem.href)
return elem return elem
}, },
rapid, rapid,
@ -3613,7 +3613,7 @@ export async function hint(option?: string, selectors?: string, ...rest: string[
DOM.elementsWithText(), DOM.elementsWithText(),
elem => { elem => {
// /!\ Warning: This is racy! This can easily be fixed by adding an await but do we want this? yank can be pretty slow, especially with yankto=selection // /!\ Warning: This is racy! This can easily be fixed by adding an await but do we want this? yank can be pretty slow, especially with yankto=selection
run_exstr("yank " + elem["textContent"]) run_exstr("yank " + elem.textContent)
return elem return elem
}, },
rapid, rapid,

View file

@ -39,7 +39,7 @@ function getCommandElements() {
async function addSetting(settingName: string) { async function addSetting(settingName: string) {
let commandElems = getCommandElements() let commandElems = getCommandElements()
// We're ignoring composite because it combines multiple excmds // We're ignoring composite because it combines multiple excmds
delete commandElems["composite"] delete (commandElems as any).composite
// Initialize or reset the <p> element that will contain settings in each commandElem // Initialize or reset the <p> element that will contain settings in each commandElem
let settingElems = Object.keys(commandElems).reduce( let settingElems = Object.keys(commandElems).reduce(

View file

@ -1087,9 +1087,9 @@ export async function update() {
// root namespace because we were young and bold. // root namespace because we were young and bold.
let legacy_nmaps = await browser.storage.sync.get("nmaps") let legacy_nmaps = await browser.storage.sync.get("nmaps")
if (Object.keys(legacy_nmaps).length > 0) { if (Object.keys(legacy_nmaps).length > 0) {
USERCONFIG["nmaps"] = Object.assign( USERCONFIG.nmaps = Object.assign(
legacy_nmaps["nmaps"], legacy_nmaps.nmaps,
USERCONFIG["nmaps"], USERCONFIG.nmaps,
) )
} }
} finally { } finally {

View file

@ -96,7 +96,7 @@ export async function update(
icon: browser.contextualIdentities.IdentityIcon icon: browser.contextualIdentities.IdentityIcon
}, },
) { ) {
if (isValidColor(updateObj["color"]) && isValidIcon(updateObj["icon"])) { if (isValidColor(updateObj.color) && isValidIcon(updateObj.icon)) {
try { try {
browser.contextualIdentities.update(containerId, updateObj) browser.contextualIdentities.update(containerId, updateObj)
} catch (e) { } catch (e) {
@ -193,7 +193,7 @@ export async function getId(name: string): Promise<string> {
if (res.length !== 1) { if (res.length !== 1) {
throw new Error("") throw new Error("")
} else { } else {
return res[0]["cookieStoreId"] return res[0].cookieStoreId
} }
} catch (e) { } catch (e) {
logger.error( logger.error(

View file

@ -1,3 +1,4 @@
/* tslint:disable:no-string-literal */
import * as CSS from "css" import * as CSS from "css"
// Layout (of bits we care about: // Layout (of bits we care about:

View file

@ -33,7 +33,7 @@ class DefaultMap extends Map {
* it when they fix the bug. * it when they fix the bug.
*/ */
export function clobberCSP(response) { export function clobberCSP(response) {
const headers = response["responseHeaders"] const headers = response.responseHeaders
const cspHeader = headers.find( const cspHeader = headers.find(
header => header.name.toLowerCase() === "content-security-policy", header => header.name.toLowerCase() === "content-security-policy",
) )

View file

@ -12,7 +12,7 @@ function getChangelogDiv() {
function updateChangelogStatus() { function updateChangelogStatus() {
const changelogDiv = getChangelogDiv() const changelogDiv = getChangelogDiv()
const changelogContent = changelogDiv.textContent const changelogContent = changelogDiv.textContent
if (localStorage["changelogContent"] == changelogContent) { if (localStorage.changelogContent == changelogContent) {
const changelogButton = document.querySelector('input[id^="spoiler"]') const changelogButton = document.querySelector('input[id^="spoiler"]')
if (!changelogButton) { if (!changelogButton) {
console.error("Couldn't find changelog button!") console.error("Couldn't find changelog button!")
@ -24,7 +24,7 @@ function updateChangelogStatus() {
function readChangelog() { function readChangelog() {
const changelogDiv = getChangelogDiv() const changelogDiv = getChangelogDiv()
localStorage["changelogContent"] = changelogDiv.textContent localStorage.changelogContent = changelogDiv.textContent
updateChangelogStatus() updateChangelogStatus()
} }

View file

@ -24,7 +24,6 @@
"no-extra-semicolon": false, "no-extra-semicolon": false,
"no-identical-functions": false, "no-identical-functions": false,
"no-shadowed-variable": false, "no-shadowed-variable": false,
"no-string-literal": false,
"no-string-throw": false, "no-string-throw": false,
"no-trailing-whitespace": false, "no-trailing-whitespace": false,
"no-try-promise": false, "no-try-promise": false,