From ba08b25e77fbe1c85c4c26d5743d00608db4d8be Mon Sep 17 00:00:00 2001 From: GauBen Date: Thu, 17 Feb 2022 16:52:38 +0100 Subject: [PATCH] fix(#168): fixes parse errors caused by parentheses --- src/preprocess.js | 2 +- test/samples/indentation/expected.json | 9 --------- test/samples/svelte-kit-load/Input.svelte | 9 +++++++++ test/samples/svelte-kit-load/expected.json | 1 + test/samples/typescript-indentation/expected.json | 9 --------- 5 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 test/samples/svelte-kit-load/Input.svelte create mode 100644 test/samples/svelte-kit-load/expected.json diff --git a/src/preprocess.js b/src/preprocess.js index 0be4795..eb9d9ce 100644 --- a/src/preprocess.js +++ b/src/preprocess.js @@ -73,7 +73,7 @@ export const preprocess = text => { } const { ast, warnings, vars, mapper } = result; - const references_and_reassignments = `{${vars.filter(v => v.referenced || v.name[0] === '$').map(v => v.name)};${vars.filter(v => v.reassigned || v.export_name).map(v => v.name + '=0')}}`; + const references_and_reassignments = `\n;{${vars.filter(v => v.referenced || v.name[0] === '$').map(v => v.name)};${vars.filter(v => v.reassigned || v.export_name).map(v => v.name + '=0')}}`; state.var_names = new Set(vars.map(v => v.name)); // convert warnings to linting messages diff --git a/test/samples/indentation/expected.json b/test/samples/indentation/expected.json index 6213ccf..f49fec3 100644 --- a/test/samples/indentation/expected.json +++ b/test/samples/indentation/expected.json @@ -18,14 +18,5 @@ "range": [15, 16], "text": "" } - }, - { - "ruleId": "semi", - "line": 3, - "column": 6, - "fix": { - "range": [19, 19], - "text": ";" - } } ] diff --git a/test/samples/svelte-kit-load/Input.svelte b/test/samples/svelte-kit-load/Input.svelte new file mode 100644 index 0000000..4a6bd92 --- /dev/null +++ b/test/samples/svelte-kit-load/Input.svelte @@ -0,0 +1,9 @@ + + +

Hello World!

diff --git a/test/samples/svelte-kit-load/expected.json b/test/samples/svelte-kit-load/expected.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/samples/svelte-kit-load/expected.json @@ -0,0 +1 @@ +[] diff --git a/test/samples/typescript-indentation/expected.json b/test/samples/typescript-indentation/expected.json index 374119a..17385ba 100644 --- a/test/samples/typescript-indentation/expected.json +++ b/test/samples/typescript-indentation/expected.json @@ -18,14 +18,5 @@ "range": [29, 30], "text": "" } - }, - { - "ruleId": "semi", - "line": 3, - "column": 10, - "fix": { - "range": [37, 37], - "text": ";" - } } ]