# ES2015 to ES2017 syntax (let, const, arrow functions, template literals)

Source: https://findproxyforurl.net/rules/es2015-syntax/ · last updated 2026-10-15

Rule PAC-K001 (`es2015-syntax`), severity medium, category: Compatibility across engines.

Chrome, Firefox and Windows accept ES2015 to ES2017 syntax such as let, const and arrow functions, but older engines (pactester builds up to 1.4, engines embedded in appliances and agents) fail to parse the whole file, and their traffic goes DIRECT.

## Why it matters

A PAC is parsed by whatever JavaScript engine the consuming client embeds. Chromium (V8)
and Firefox (SpiderMonkey) accept current ECMAScript. Older pactester (pacparser) builds and
engines embedded in appliances and agents may not; for them `const`, `let`, `=>` or back-tick
strings are parse errors, which means mechanism (b) of the silent-DIRECT family for every
client that uses such an engine. Nothing in a PAC needs ES2015; `var` and function
declarations express everything.

Windows is not one of those engines. In the lab on Windows 11 (2026-10-11) `let`, `const`,
arrow functions, classes, template strings, array spread, destructuring, async functions and
generators all worked. Windows fails only on syntax newer than ES2017, such as `?.`, `??` or
object spread; that is a separate and more serious finding
([JavaScript syntax newer than ES2017](/rules/es2018-syntax/)).

The finding therefore lowers the compatibility score but does not cap the grade. Plain ES5
costs nothing and keeps the file working on every engine.


## How to fix

Use var instead of let/const, function expressions instead of arrows, and string concatenation instead of template literals.

## Bad

```js
const PROXY_A = "PROXY proxy.corp.example:8080";
const isCorp = (h) => dnsDomainIs(h, ".corp.example");
function FindProxyForURL(url, host) {
  if (isCorp(host)) {
    return `DIRECT`;
  }
  return PROXY_A;
}
```

## Good

```js
var PROXY_A = "PROXY proxy.corp.example:8080";
function isCorp(h) {
  return dnsDomainIs(h, ".corp.example");
}
function FindProxyForURL(url, host) {
  if (isCorp(host)) {
    return "DIRECT";
  }
  return PROXY_A;
}
```

## Engine behaviour

- chromium: V8; current ECMAScript syntax parses. (source: code, verified 2026-10-04)
- firefox: SpiderMonkey; current ECMAScript syntax parses. (source: expert, unverified)
- pacparser: Depends on the version. pacparser 1.5.0 and newer (QuickJS engine) accept ES2015 syntax such as let and arrow functions; 1.4.x (SpiderMonkey 1.7) rejects it, and the file does not load (lab, 1.5.3 and 1.4.6). (source: lab, verified 2026-10-04)
- winhttp: About ES2017. let, const, arrow functions, classes, template strings, destructuring, array spread, async functions and generators work; optional chaining (?.), ??, object spread, BigInt literals, regular-expression lookbehind and named groups are syntax errors, and then the whole file fails to load. (source: lab, verified 2026-10-11)
