Disallow and suppress unsafe assignment (#19736)

This commit is contained in:
Christian Gunderman
2026-02-20 22:28:55 +00:00
committed by GitHub
parent b746524a1b
commit 58d637f919
71 changed files with 149 additions and 22 deletions

View File

@@ -23,6 +23,7 @@ export function resolveEnvVarsInString(
): string {
const envVarRegex = /\$(?:(\w+)|{([^}]+)})/g; // Find $VAR_NAME or ${VAR_NAME}
return value.replace(envVarRegex, (match, varName1, varName2) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const varName = varName1 || varName2;
if (customEnv && typeof customEnv[varName] === 'string') {
return customEnv[varName];

View File

@@ -78,6 +78,7 @@ export const getLatestGitHubRelease = async (
);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const releaseTag = (await response.json()).tag_name;
if (!releaseTag) {
throw new Error(`Response did not include tag_name field`);

View File

@@ -29,6 +29,7 @@ export function tryParseJSON(input: string): object | null {
if (!checkInput(input)) return null;
const trimmed = input.trim();
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const parsed = JSON.parse(trimmed);
if (parsed === null || typeof parsed !== 'object') {
return null;

View File

@@ -38,6 +38,7 @@ export class PersistentState {
const filePath = this.getPath();
if (fs.existsSync(filePath)) {
const content = fs.readFileSync(filePath, 'utf-8');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.cache = JSON.parse(content);
} else {
this.cache = {};

View File

@@ -23,6 +23,7 @@ export async function readStdin(): Promise<string> {
const onReadable = () => {
let chunk;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
while ((chunk = process.stdin.read()) !== null) {
if (pipedInputTimerId) {
clearTimeout(pipedInputTimerId);

View File

@@ -254,6 +254,7 @@ export const getAllSessionFiles = async (
async (file): Promise<SessionFileEntry> => {
const filePath = path.join(chatsDir, file);
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const content: ConversationRecord = JSON.parse(
await fs.readFile(filePath, 'utf8'),
);
@@ -498,6 +499,7 @@ export class SessionSelector {
const sessionPath = path.join(chatsDir, sessionInfo.fileName);
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const sessionData: ConversationRecord = JSON.parse(
await fs.readFile(sessionPath, 'utf8'),
);

View File

@@ -371,6 +371,7 @@ export function setPendingSettingValue(
pendingSettings: Settings,
): Settings {
const path = key.split('.');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const newSettings = JSON.parse(JSON.stringify(pendingSettings));
setNestedValue(newSettings, path, value);
return newSettings;