Fix some eslint js issues (#33856)

The PR fixes eslint issues in *.js files and removes the related rules from the backlist.
This commit is contained in:
Mikhail
2026-02-14 22:10:28 +04:00
committed by GitHub
parent 815fdf1ef4
commit 367be052ab
28 changed files with 83 additions and 34 deletions
-1
View File
@@ -35,7 +35,6 @@ components/ai_chat/core/browser/tools/tools.md
chromium_presubmit_config.json5
jest.config.js
snapcraft.yaml
.eslintrc.js
# Needs to be refactored before being formatted
/build/commands/lib/util.js
+4 -1
View File
@@ -356,7 +356,10 @@ exports.update = () => {
.split('\n')
let untrackedChromiumPaths = []
for (const untrackedChromiumFile of untrackedChromiumFiles) {
untrackedChromiumPath = path.join(suspectedDir, untrackedChromiumFile)
const untrackedChromiumPath = path.join(
suspectedDir,
untrackedChromiumFile,
)
if (!fs.statSync(untrackedChromiumPath).isDirectory()) {
untrackedChromiumPaths.push(untrackedChromiumPath)
+2 -2
View File
@@ -35,8 +35,8 @@ const chromiumConfigs = {
buildTargets: ['mini_installer'],
processArtifacts: () => {
// Repack it to reduce the size and use .zip instead of .7z.
input = path.join(config.outputDir, 'chrome.7z')
output = path.join(config.outputDir, `${getOutputFilename()}.zip`)
const input = path.join(config.outputDir, 'chrome.7z')
const output = path.join(config.outputDir, `${getOutputFilename()}.zip`)
util.run(
'python3',
[
+1 -1
View File
@@ -1244,7 +1244,7 @@ Object.defineProperty(Config.prototype, 'outputDir', {
return path.join(baseDir, buildConfigDir)
},
set: function (outputDir) {
return (this.__outputDir = outputDir)
this.__outputDir = outputDir
},
})
+1 -1
View File
@@ -17,7 +17,7 @@ const genGradle = (
config.buildConfig = buildConfig
config.update(options)
Log.progressScope('Generating Gradle files', () => {
braveArgs = [
let braveArgs = [
'build/android/gradle/generate_gradle.py',
'--output-directory',
config.outputDir,
+2 -2
View File
@@ -14,7 +14,7 @@ const runPerfTests = (
targetBuildConfig,
options,
) => {
args = [
const args = [
path.join(config.braveCoreDir, 'tools', 'perf', 'run_perftests.py'),
perfConfig,
]
@@ -32,7 +32,7 @@ const runPerfTests = (
config.buildConfig = targetBuildConfig
config.update(options)
binaryPath = path.join(config.outputDir, 'brave')
let binaryPath = path.join(config.outputDir, 'brave')
if (process.platform === 'win32') {
binaryPath += '.exe'
} else if (process.platform === 'darwin') {
+2 -1
View File
@@ -890,7 +890,8 @@ const util = {
return dotGitPath
}
// Returns the actual .git dir in case a worktree is used.
gitDir = util.runGit(repoDir, ['rev-parse', '--git-common-dir'], false)
const gitDir = util.runGit(repoDir, ['rev-parse', '--git-common-dir'],
false)
if (!path.isAbsolute(gitDir)) {
return path.join(repoDir, gitDir)
}
@@ -35,7 +35,7 @@ program
'src@refs/tags/' + options.tag,
])
}
args = [
const args = [
path.join(
config.srcDir,
'brave',
+1 -1
View File
@@ -190,7 +190,7 @@ const runPrettier = async (files, dryRun) => {
const options = require(path.join(config.braveCoreDir, '.prettierrc'))
const ignorePath = path.join(config.braveCoreDir, '.prettierignore')
if (!fs.existsSync(ignorePath)) {
throw new RuntimeError(`${ignorePath} file not found`)
throw new Error(`${ignorePath} file not found`)
}
const prettierIssues = []
@@ -7,5 +7,5 @@ const config = require('../lib/config')
const path = require('path')
const util = require('../lib/util')
args = [path.join(config.srcDir, 'brave', 'tools', 'crates', 'update.py')]
const args = [path.join(config.srcDir, 'brave', 'tools', 'crates', 'update.py')]
util.run('vpython3', args, config.defaultOptions)
+1 -1
View File
@@ -49,7 +49,7 @@ function loadChromiumPathFilter(filePath) {
}
}
chromiumPathFilter = loadChromiumPathFilter(
const chromiumPathFilter = loadChromiumPathFilter(
path.join(config.braveCoreDir, 'build', 'update_patches_exclusions.cfg'),
)
@@ -7,7 +7,7 @@ const config = require('../lib/config')
const path = require('path')
const util = require('../lib/util')
args = [
const args = [
path.join(
config.srcDir,
'brave',
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
/* global loadTimeDataRaw */
import { SecurityInterstitialCommandId, sendCommand } from 'chrome://interstitials/common/resources/interstitial_common.js';
function setupEvents() {
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at https://mozilla.org/MPL/2.0/.
/* global $Object */
;(function () {
if (!window.braveEthereum) {
return
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at https://mozilla.org/MPL/2.0/.
/* global $Object */
;(function () {
if (!window.braveSolana) {
return
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
/* eslint-disable no-undef */
import {
applyCompiledSelector,
compileProceduralSelector,
@@ -68,7 +68,7 @@ class speedreaderUtils {
const wpm = this.speedreaderData.averageWordsPerMinute
const minutes = Math.ceil(words / wpm)
readTimeDiv.innerText = minutes + ' ' + speedreaderData.minutesText
readTimeDiv.innerText = minutes + ' ' + this.speedreaderData.minutesText
}
static getTextContent = (element) => {
@@ -126,7 +126,7 @@ class speedreaderUtils {
button.classList.add('tts-circle')
const playButton = document.createElement('span')
playButton.classList.add('tts-paragraph-player-button', 'tts-play-icon')
playButton.title = speedreaderData.playButtonTitle
playButton.title = this.speedreaderData.playButtonTitle
playButton.onclick = button.onclick = (ev) => {
window.speedreader.ttsPlayPause(parseInt(p.getAttribute('tts-paragraph-index')))
}
@@ -157,6 +157,7 @@ class speedreaderUtils {
let currentParent = null
let paragraphs = []
let currentNode = null;
// eslint-disable-next-line no-cond-assign
while (currentNode = nodes.nextNode()) {
if (currentNode === nodes.root ||
isChildOf(currentNode, currentParent) ||
@@ -219,6 +220,7 @@ class speedreaderUtils {
let startNode = null
let endNode = null
let node = null
// eslint-disable-next-line no-cond-assign
while (node = nodes.nextNode()) {
if (!startNode) {
if (start < node.textContent.length) {
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
/* eslint-disable no-undef */
// securityOrigin is predefined by translate_script.cc.
const securityOriginHost = new URL(securityOrigin).host
+1 -1
View File
@@ -91,7 +91,7 @@ async function createDynamicGDR () {
// remove previously generated file
try {
await fs.unlink(gdrPath)
} catch (e) {}
} catch (e) {} // eslint-disable-line no-empty
// build file list from target dir
const filePaths = await getFileListDeep(targetDir)
const contents = gdrPath.endsWith('.grdp')
+17 -11
View File
@@ -13,6 +13,7 @@ import love from 'eslint-config-love'
import prettier from 'eslint-config-prettier/flat'
import tslint from 'typescript-eslint'
import eslintJs from '@eslint/js'
import globals from 'globals'
// Config layout: each plugin or override is a separate array entry.
// Guidelines:
@@ -22,6 +23,18 @@ import eslintJs from '@eslint/js'
// it targets.
// Verify changes with: npm run eslint (about 1 min).
export default defineConfig([
// Setup project-wide language options.
{
languageOptions: {
globals: {
...globals.browser,
...globals.jest,
...globals.node,
chrome: 'readonly',
},
},
},
// Turn off rules that conflict with Prettier formatting (all files).
prettier,
@@ -100,7 +113,6 @@ export default defineConfig([
'.storybook/*',
'browser/*',
'ui/webui/resources/*',
'**/*.js',
'**/*.d.ts',
'tools/chromium_src/lit_mangler/*.ts',
@@ -116,6 +128,7 @@ export default defineConfig([
// Generated by scripts, skip linting
'ios/brave-ios/Sources/AIChat/Components/Markdown/CodeHighlight/Scripts/highlight.min.js',
'components/brave_wallet/resources/solana_web3_script.js',
'test/data/ephemeral-storage/static/js/libs/js.cookie.min.js',
]),
{
@@ -278,25 +291,18 @@ export default defineConfig([
},
},
{
// Rules disabled for plain JavaScript.
// Brave JavaScript files uses require() to load modules.
files: ['**/*.{js,jsx,mjs,cjs}'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'no-cond-assign': 'off',
'no-control-regex': 'off',
'no-empty': 'off',
'no-redeclare': 'off',
'no-setter-return': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
},
},
{
// Test data files; skip license header requirement.
// Test data files; skips some non-important rules.
files: ['test/data/**/*.js'],
rules: {
'licenses/header': 'off',
'no-undef': 'off',
},
},
])
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
/* global webkit */
(() => {
"use strict"
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
/* global webkit */
(() => {
"use strict"
@@ -3,6 +3,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
/* global webkit */
(() => {
"use strict"
/**
+14
View File
@@ -108,6 +108,7 @@
"font-awesome": "4.7.0",
"fork-ts-checker-webpack-plugin": "9.0.2",
"fs-extra": "8.1.0",
"globals": "17.3.0",
"https-browserify": "1.0.0",
"identity-obj-proxy": "3.0.0",
"jest": "28.1.3",
@@ -12415,6 +12416,19 @@
"process": "^0.11.10"
}
},
"node_modules/globals": {
"version": "17.3.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-17.3.0.tgz",
"integrity": "sha512-yMqGUQVVCkD4tqjOJf3TnrvaaHDMYp4VlUSObbkIiuCPe/ofdMBFIAcBbCSRFWOnos6qRiTVStDwqPLUclaxIw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/globalthis": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz",
+1
View File
@@ -156,6 +156,7 @@
"font-awesome": "4.7.0",
"fork-ts-checker-webpack-plugin": "9.0.2",
"fs-extra": "8.1.0",
"globals": "17.3.0",
"https-browserify": "1.0.0",
"identity-obj-proxy": "3.0.0",
"jest": "28.1.3",
@@ -1,3 +1,8 @@
// Copyright (c) 2021 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
(_ => {
const W = window
const C = W.Cookies
@@ -19,7 +24,7 @@
// Last, see if we're remote by seeing if we trigger a SOP violation
// by reading the location of the parent.
try {
if (window.parent.location.href) {}
console.log(window.parent.location.href)
return false
} catch (_) {
return true
@@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
// Copyright (c) 2020 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
function getConfig(expectedSuccess, expectedConfig) {
chrome.ipfs.getConfig((success, config) => {
@@ -80,7 +81,7 @@ function compareObjects(o1, o2) {
}
}
}
for(var p in o2) {
for(p in o2) {
if (o2.hasOwnProperty(p)) {
if (o1[p] !== o2[p]) {
return false;
@@ -276,7 +276,8 @@ class TeamcityReporter {
// https://www.jetbrains.com/help/teamcity/service-messages.html#Escaped+Values
const escapedParamValue = strParamValue
// Remove ANSI escape sequences (colors, styles, etc.).
// Remove ANSI escape sequences (colors, styles, etc.)
// eslint-disable-next-line no-control-regex
.replace(/\u001B\[\d+(;\d+)*m/g, '')
// Replace Teamcity Service Messages special characters.
.replace(/[\n\r'|[\]]/g, (match) => {