Major refactoring using ESLint with rules from AirBnb and Vue. Enable most of the ESLint rules and do necessary linting in the code. Also add more information for rules that are disabled to describe what they are and why they are disabled. Allow logging (`console.log`) in test files, and in development mode (e.g. when working with `npm run serve`), but disable it when environment is production (as pre-configured by Vue). Also add flag (`--mode production`) in `lint:eslint` command so production linting is executed earlier in lifecycle. Disable rules that requires a separate work. Such as ESLint rules that are broken in TypeScript: no-useless-constructor (eslint/eslint#14118) and no-shadow (eslint/eslint#13014).
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { IPipe } from '../IPipe';
|
|
|
|
export class EscapeDoubleQuotes implements IPipe {
|
|
public readonly name: string = 'escapeDoubleQuotes';
|
|
|
|
public apply(raw: string): string {
|
|
return raw?.replaceAll('"', '"^""');
|
|
/* eslint-disable 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 max-len */
|
|
}
|
|
}
|