mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
TSLint: re-enable forin rule
The forin rule forbids using the `for (let key in object)` syntax. This is because iterating with `for in` also iterates over keys obtained from prototypal inheritance. This is most of the time wrong and using `for (let key of Object.keys(object)` protects against that.
This commit is contained in:
parent
071e5a9eff
commit
3c9c3867e2
6 changed files with 14 additions and 16 deletions
|
@ -1102,7 +1102,7 @@ export async function url2args() {
|
|||
let searchurls = await config.getAsync("searchurls")
|
||||
let result = url
|
||||
|
||||
for (let engine in searchurls) {
|
||||
for (let engine of Object.keys(searchurls)) {
|
||||
let [beginning, end] = [...searchurls[engine].split("%s"), ""]
|
||||
if (url.startsWith(beginning) && url.endsWith(end)) {
|
||||
// Get the string matching %s
|
||||
|
@ -2637,14 +2637,14 @@ import * as tri_editor from "@src/lib/editor"
|
|||
|
||||
//#content_helper
|
||||
// {
|
||||
for (let editorfn in tri_editor) {
|
||||
for (let editorfn of Object.keys(tri_editor)) {
|
||||
// Re-expose every editor function as a text.$fn excmd that will forward the call to $fn to the commandline frame if it is selected or apply $fn to the last used input if it isn't
|
||||
SELF["text." + editorfn] = arg => {
|
||||
if ((document.activeElement as any).src === browser.extension.getURL("static/commandline.html")) return Messaging.messageOwnTab("commandline_frame", "editor_function", [editorfn].concat(arg))
|
||||
return tri_editor[editorfn](DOM.getLastUsedInput(), arg)
|
||||
}
|
||||
}
|
||||
for (let fn in cmdframe_fns) {
|
||||
for (let fn of Object.keys(cmdframe_fns)) {
|
||||
SELF["ex." + fn] = (...args) => (Messaging.messageOwnTab as any)("commandline_frame", cmdframe_fns[fn][0], cmdframe_fns[fn][1].concat(args))
|
||||
}
|
||||
|
||||
|
@ -2652,12 +2652,12 @@ for (let fn in cmdframe_fns) {
|
|||
|
||||
//#background_helper
|
||||
// {
|
||||
for (let editorfn in tri_editor) {
|
||||
for (let editorfn of Object.keys(tri_editor)) {
|
||||
let name = "text." + editorfn
|
||||
cmd_params.set(name, new Map([["arr", "string[]"]]))
|
||||
BGSELF[name] = (...args) => messageActiveTab("excmd_content", name, args)
|
||||
}
|
||||
for (let fn in cmdframe_fns) {
|
||||
for (let fn of Object.keys(cmdframe_fns)) {
|
||||
cmd_params.set("ex." + fn, new Map(cmdframe_fns[fn][1].map((a, i) => [`${i}`, typeof a] as [string, string])))
|
||||
BGSELF["ex." + fn] = (...args) => messageActiveTab("commandline_frame", cmdframe_fns[fn][0], cmdframe_fns[fn][1].concat(args))
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ async function addSetting(settingName: string) {
|
|||
|
||||
let settings = await config.getAsync(settingName)
|
||||
// For each setting
|
||||
for (let setting in settings) {
|
||||
for (let setting of Object.keys(settings)) {
|
||||
let excmd = settings[setting].split(" ")
|
||||
// How can we automatically detect what commands can be skipped?
|
||||
excmd = ["composite", "fillcmdline", "current_url"].includes(excmd[0])
|
||||
|
|
|
@ -47,7 +47,7 @@ export function getCmdAliasMapping(
|
|||
let commands = {}
|
||||
// aliases look like this: {alias: command} but what we really need is this: {command: [alias1, alias2...]}
|
||||
// This is what this loop builds
|
||||
for (let alias in aliases) {
|
||||
for (let alias of Object.keys(aliases)) {
|
||||
let cmd = expandExstr(alias, aliases).trim()
|
||||
if (!commands[cmd]) commands[cmd] = []
|
||||
commands[cmd].push(alias.trim())
|
||||
|
|
|
@ -42,7 +42,7 @@ export class MinimalKey {
|
|||
readonly shiftKey = false
|
||||
|
||||
constructor(readonly key: string, modifiers?: KeyModifiers) {
|
||||
for (let mod in modifiers) {
|
||||
for (let mod of Object.keys(modifiers)) {
|
||||
this[mod] = modifiers[mod]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@ export function parseProfilesIni(content: string, basePath: string) {
|
|||
result[current][match[1]] = match[2]
|
||||
}
|
||||
}
|
||||
for (let profileName in result) {
|
||||
for (let profileName of Object.keys(result)) {
|
||||
let profile = result[profileName]
|
||||
// profile.IsRelative can be 0, 1 or undefined
|
||||
if (profile.IsRelative == 1) {
|
||||
|
@ -456,7 +456,7 @@ export async function getProfile() {
|
|||
|
||||
// First, try to see if the 'profiledir' setting matches a profile in profile.ini
|
||||
if (curProfileDir != "auto") {
|
||||
for (let profileName in iniObject) {
|
||||
for (let profileName of Object.keys(iniObject)) {
|
||||
let profile = iniObject[profileName]
|
||||
if (profile.absolutePath == curProfileDir) {
|
||||
return profile
|
||||
|
@ -472,7 +472,7 @@ export async function getProfile() {
|
|||
const profile = cmdline.indexOf("--profile")
|
||||
if (profile >= 0 && profile < cmdline.length - 1) {
|
||||
const profilePath = cmdline[profile + 1]
|
||||
for (let profileName in iniObject) {
|
||||
for (let profileName of Object.keys(iniObject)) {
|
||||
let profile = iniObject[profileName]
|
||||
if (profile.absolutePath == profilePath) {
|
||||
return profile
|
||||
|
@ -488,7 +488,7 @@ export async function getProfile() {
|
|||
if (p == -1) p = cmdline.indexOf("-P")
|
||||
if (p >= 0 && p < cmdline.length - 1) {
|
||||
const pName = cmdline[p + 1]
|
||||
for (let profileName in iniObject) {
|
||||
for (let profileName of Object.keys(iniObject)) {
|
||||
let profile = iniObject[profileName]
|
||||
if (profile.Name == pName) {
|
||||
return profile
|
||||
|
@ -515,7 +515,7 @@ export async function getProfile() {
|
|||
.split("/")
|
||||
.slice(0, -1)
|
||||
.join("/")
|
||||
for (let profileName in iniObject) {
|
||||
for (let profileName of Object.keys(iniObject)) {
|
||||
let profile = iniObject[profileName]
|
||||
if (profile.absolutePath == path) {
|
||||
return profile
|
||||
|
@ -528,7 +528,7 @@ export async function getProfile() {
|
|||
}
|
||||
|
||||
// Multiple profiles used but no -p or --profile, this means that we're using the default profile
|
||||
for (let profileName in iniObject) {
|
||||
for (let profileName of Object.keys(iniObject)) {
|
||||
let profile = iniObject[profileName]
|
||||
if (profile.Default == 1) {
|
||||
return profile
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
"class-name": false,
|
||||
"cognitive-complexity": false,
|
||||
"curly": false,
|
||||
"forin": false,
|
||||
"if-filter": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
|
|
Loading…
Add table
Reference in a new issue