Add prettier (#1339)

This commit is contained in:
Timofey Kachalov
2025-12-04 00:09:10 +04:00
committed by GitHub
parent 01465a233c
commit 4ee4b219e5
444 changed files with 10605 additions and 13266 deletions
@@ -25,14 +25,11 @@ describe('StringArrayCallsWrapperCodeHelper', () => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
for (let i = 0; i < samplesCount; i++) {
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
stringArray: true,
stringArrayThreshold: 1
}
).getObfuscatedCode();
obfuscatedCode = JavaScriptObfuscator.obfuscate(code, {
...NO_ADDITIONAL_NODES_PRESET,
stringArray: true,
stringArrayThreshold: 1
}).getObfuscatedCode();
if (obfuscatedCode.match(stringArrayCallsWrapperAtFirstPositionRegExp)) {
stringArrayCallsWrapperAtFirstPositionMatchesCount++;
@@ -59,14 +56,11 @@ describe('StringArrayCallsWrapperCodeHelper', () => {
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
stringArray: true,
stringArrayThreshold: 1
}
).getObfuscatedCode();
obfuscatedCode = JavaScriptObfuscator.obfuscate(code, {
...NO_ADDITIONAL_NODES_PRESET,
stringArray: true,
stringArrayThreshold: 1
}).getObfuscatedCode();
});
it('should correctly append code helper into the obfuscated code', () => {
@@ -74,49 +68,45 @@ describe('StringArrayCallsWrapperCodeHelper', () => {
});
});
describe('`stringArray` option isn\'t set', () => {
describe("`stringArray` option isn't set", () => {
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
stringArray: false
}
).getObfuscatedCode();
obfuscatedCode = JavaScriptObfuscator.obfuscate(code, {
...NO_ADDITIONAL_NODES_PRESET,
stringArray: false
}).getObfuscatedCode();
});
it('shouldn\'t append code helper into the obfuscated code', () => {
it("shouldn't append code helper into the obfuscated code", () => {
assert.notMatch(obfuscatedCode, stringCallsWrapperRegExp);
});
});
describe('Preserve string array name', () => {
const callsWrapperRegExp: RegExp = new RegExp(`` +
`function *b *\\(c, *d\\) *{ *` +
`c *= *c *- *0x0; *` +
`var e *= *a *\\(\\);` +
`var f *= *e\\[c]; *` +
``);
const callsWrapperRegExp: RegExp = new RegExp(
`` +
`function *b *\\(c, *d\\) *{ *` +
`c *= *c *- *0x0; *` +
`var e *= *a *\\(\\);` +
`var f *= *e\\[c]; *` +
``
);
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
stringArray: true,
stringArrayThreshold: 1,
stringArrayEncoding: [StringArrayEncoding.Base64]
}
).getObfuscatedCode();
obfuscatedCode = JavaScriptObfuscator.obfuscate(code, {
...NO_ADDITIONAL_NODES_PRESET,
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
stringArray: true,
stringArrayThreshold: 1,
stringArrayEncoding: [StringArrayEncoding.Base64]
}).getObfuscatedCode();
});
it('should preserve string array name', () => {