Skip to content

Commit cc8606b

Browse files
committed
style: fix no-useless-escape rule violations
1 parent a7789ef commit cc8606b

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

eslint.config.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export default tseslint.config(
7373
'@typescript-eslint/no-unsafe-return': 'off', // 74 instances
7474
'@typescript-eslint/no-misused-promises': 'off', // 53 instances
7575
'@typescript-eslint/no-floating-promises': 'off', // 48 instances
76-
'no-useless-escape': 'off', // 38 instances
7776
'no-async-promise-executor': 'off', // 25 instances
7877
'@typescript-eslint/prefer-promise-reject-errors': 'off', // 19 instances
7978
'@typescript-eslint/require-await': 'off', // 7 instances

src/backend/gdb_expansion.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { MINode } from './mi_parse';
22

3-
const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*|\[\d+\])\s*=\s*/;
4-
const variableRegex = /^[a-zA-Z_\-][a-zA-Z0-9_\-]*/;
5-
const errorRegex = /^\<.+?\>/;
3+
const resultRegex = /^([a-zA-Z_-][a-zA-Z0-9_-]*|\[\d+\])\s*=\s*/;
4+
const variableRegex = /^[a-zA-Z_-][a-zA-Z0-9_-]*/;
5+
const errorRegex = /^<.+?>/;
66
const referenceStringRegex = /^(0x[0-9a-fA-F]+\s*)"/;
77
const referenceRegex = /^0x[0-9a-fA-F]+/;
88
const nullpointerRegex = /^0x0+\b/;

src/backend/mi2/mi2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function escape(str: string) {
3232
return str.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
3333
}
3434

35-
const nonOutput = /^(?:\d*|undefined)[\*\+\=]|[\~\@\&\^]/;
35+
const nonOutput = /^(?:\d*|undefined)[*+=]|[~@&^]/;
3636
const gdbMatch = /(?:\d*|undefined)\(gdb\)/;
3737
const numRegex = /\d+/;
3838

src/backend/mi_parse.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class MINode implements MIInfo {
6262
if (!start) {
6363
return undefined;
6464
}
65-
const pathRegex = /^\.?([a-zA-Z_\-][a-zA-Z0-9_\-]*)/;
65+
const pathRegex = /^\.?([a-zA-Z_-][a-zA-Z0-9_-]*)/;
6666
const indexRegex = /^\[(\d+)\](?:$|\.)/;
6767
path = path.trim();
6868
if (!path) { return start; }
@@ -136,11 +136,11 @@ export class MINode implements MIInfo {
136136
}
137137

138138
const tokenRegex = /^\d+/;
139-
const outOfBandRecordRegex = /^(?:(\d*|undefined)([\*\+\=])|([\~\@\&]))/;
139+
const outOfBandRecordRegex = /^(?:(\d*|undefined)([*+=])|([~@&]))/;
140140
const resultRecordRegex = /^(\d*)\^(done|running|connected|error|exit)/;
141141
const newlineRegex = /^\r\n?/;
142142
const endRegex = /^\(gdb\)\r\n?/;
143-
const variableRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*)/;
143+
const variableRegex = /^([a-zA-Z_-][a-zA-Z0-9_-]*)/;
144144
const asyncClassRegex = /^(.*?),/;
145145

146146
export function parseMI(output: string): MINode {

src/backend/symbols.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { GDBDebugSession } from '../gdb';
99
import { hexFormat } from '../frontend/utils';
1010
import { MINode } from './mi_parse';
1111

12-
const OBJDUMP_SYMBOL_RE = RegExp(/^([0-9a-f]{8})\s([lg\ !])([w\ ])([C\ ])([W\ ])([I\ ])([dD\ ])([FfO\ ])\s(.*?)\t([0-9a-f]+)\s(.*)$/);
12+
const OBJDUMP_SYMBOL_RE = RegExp(/^([0-9a-f]{8})\s([lg !])([w ])([C ])([W ])([I ])([dD ])([FfO ])\s(.*?)\t([0-9a-f]+)\s(.*)$/);
1313
const NM_SYMBOL_RE = RegExp(/^([0-9a-f]+).*\t(.+):[0-9]+/); // For now, we only need two things
1414
const debugConsoleLogging = false;
1515
const TYPE_MAP: { [id: string]: SymbolType } = {

src/common.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ export function toStringDecHexOctBin(val: number /* should be an integer */): st
569569
export function parseHostPort(hostPort: string) {
570570
let port: number;
571571
let host = '127.0.0.1';
572-
const match = hostPort.match(/(.*)\:([0-9]+)/);
572+
const match = hostPort.match(/(.*):([0-9]+)/);
573573
if (match) {
574574
host = match[1] ? match[1] : host;
575575
port = parseInt(match[2], 10);
@@ -706,7 +706,7 @@ export class HrTimer {
706706
// where will need to put the string in quotes as a precaution. This is more a printing
707707
// aid rather an using for an API
708708
export function quoteShellAndCmdChars(s): string {
709-
const quote = /[\s\"\*\[\]!@#$%^&*\(\)\\:]/g.test(s) ? '"' : '';
709+
const quote = /[\s"*[\]!@#$%^&*()\\:]/g.test(s) ? '"' : '';
710710
s = s.replace(/"/g, '\\"').replace(/\\/g, '\\\\');
711711
return quote + s.replace(/"/g, '\\"') + quote;
712712
}

src/frontend/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function parseDimIndex(spec: string, count: number): string[] {
6565
return components;
6666
}
6767

68-
if (/^([0-9]+)\-([0-9]+)$/i.test(spec)) {
68+
if (/^([0-9]+)-([0-9]+)$/i.test(spec)) {
6969
const parts = spec.split('-').map((p) => parseInteger(p));
7070
const start = parts[0];
7171
const end = parts[1];
@@ -83,7 +83,7 @@ export function parseDimIndex(spec: string, count: number): string[] {
8383
return components;
8484
}
8585

86-
if (/^[a-zA-Z]\-[a-zA-Z]$/.test(spec)) {
86+
if (/^[a-zA-Z]-[a-zA-Z]$/.test(spec)) {
8787
const start = spec.charCodeAt(0);
8888
const end = spec.charCodeAt(2);
8989

0 commit comments

Comments
 (0)