From 8c8f6234f7278a9376ddc00aafd1ce2a18876a61 Mon Sep 17 00:00:00 2001 From: Nikolay Makhonin Date: Sat, 3 Oct 2020 11:47:04 +0300 Subject: [PATCH] Added preprocess option: settings: { 'svelte3/preprocess': text => { return text.replace(/custom-style-tag/g, 'style') }, }, --- src/preprocess.js | 3 +++ src/processor_options.js | 1 + test/samples/preprocess/.eslintrc.js | 7 +++++++ test/samples/preprocess/Input.svelte | 7 +++++++ test/samples/preprocess/expected.json | 1 + 5 files changed, 19 insertions(+) create mode 100644 test/samples/preprocess/.eslintrc.js create mode 100644 test/samples/preprocess/Input.svelte create mode 100644 test/samples/preprocess/expected.json diff --git a/src/preprocess.js b/src/preprocess.js index 784bdd7..64ebd74 100644 --- a/src/preprocess.js +++ b/src/preprocess.js @@ -25,6 +25,9 @@ const find_contextual_names = (compiler, node) => { // extract scripts to lint from component definition export const preprocess = text => { const compiler = processor_options.custom_compiler || default_compiler || (default_compiler = require('svelte/compiler')); + if (processor_options.preprocess) { + text = processor_options.preprocess(text) + } if (processor_options.ignore_styles) { // wipe the appropriate