- Migrate to newer `eslint-config-airbnb-with-typescript` from `eslint-config-airbnb`. - Add also `rushstack/eslint-patch` as per instructed by `eslint-config-airbnb-with-typescript` docs. - Update codebase to align with new linting standards. - Add script to configure VS Code for effective linting for project developers, move it to `scripts` directory along with clean npm install script for better organization.
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { IPipe } from '../IPipe';
|
|
|
|
export class EscapeDoubleQuotes implements IPipe {
|
|
public readonly name: string = 'escapeDoubleQuotes';
|
|
|
|
public apply(raw: string): string {
|
|
if (!raw) {
|
|
return raw;
|
|
}
|
|
return raw.replaceAll('"', '"^""');
|
|
/* eslint-disable vue/max-len */
|
|
/*
|
|
"^"" is the most robust and stable choice.
|
|
Other options:
|
|
""
|
|
Breaks, because it is fundamentally unsupported
|
|
""""
|
|
Does not work with consecutive double quotes.
|
|
E.g. `PowerShell -Command "$name='aq'; Write-Host """"Disabled `""""$name`"""""""";"`
|
|
Works when using: `PowerShell -Command "$name='aq'; Write-Host "^""Disabled `"^""$name`"^"" "^"";"`
|
|
\"
|
|
May break as they are interpreted by cmd.exe as metacharacters breaking the command
|
|
E.g. `PowerShell -Command "Write-Host 'Hello \"w&orld\"'"` does not work due to unescaped "&"
|
|
Works when using: `PowerShell -Command "Write-Host 'Hello "^""w&orld"^""'"`
|
|
\""
|
|
Normalizes interior whitespace
|
|
E.g. `PowerShell -Command "\""a& c\"".length"`, outputs 4 and discards one of two whitespaces
|
|
Works when using "^"": `PowerShell -Command ""^""a& c"^"".length"`
|
|
A good explanation: https://stackoverflow.com/a/31413730
|
|
*/
|
|
/* eslint-enable vue/max-len */
|
|
}
|
|
}
|