summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/codegen.ts5
-rw-r--r--src/compiler/transform/doctype.ts1
-rw-r--r--src/compiler/transform/index.ts2
-rw-r--r--src/compiler/transform/prism.ts4
-rw-r--r--src/compiler/transform/styles.ts1
5 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/codegen.ts b/src/compiler/codegen.ts
index be9493435..3e14ba069 100644
--- a/src/compiler/codegen.ts
+++ b/src/compiler/codegen.ts
@@ -381,9 +381,11 @@ function compileModule(module: Script, state: CodegenState, compileOptions: Comp
if (plugin) {
componentPlugins.add(plugin);
}
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
state.importExportStatements.add(module.content.slice(componentImport.start!, componentImport.end!));
}
for (const componentImport of componentExports) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
state.importExportStatements.add(module.content.slice(componentImport.start!, componentImport.end!));
}
@@ -392,6 +394,7 @@ function compileModule(module: Script, state: CodegenState, compileOptions: Comp
for (const componentExport of componentProps) {
propsStatement += `${(componentExport.id as Identifier).name}`;
if (componentExport.init) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
propsStatement += `= ${babelGenerator(componentExport.init!).code}`;
}
propsStatement += `,`;
@@ -482,7 +485,9 @@ function compileHtml(enterNode: TemplateNode, state: CodegenState, compileOption
switch (node.type) {
case 'Expression': {
let child = '';
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (node.children!.length) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
child = compileHtml(node.children![0], state, compileOptions);
}
let raw = node.codeStart + child + node.codeEnd;
diff --git a/src/compiler/transform/doctype.ts b/src/compiler/transform/doctype.ts
index d19b01f81..e871f5b48 100644
--- a/src/compiler/transform/doctype.ts
+++ b/src/compiler/transform/doctype.ts
@@ -21,6 +21,7 @@ export default function (_opts: { filename: string; fileID: string }): Transform
name: '!doctype',
type: 'Element',
};
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
parent.children!.splice(index, 0, dtNode);
hasDoctype = true;
}
diff --git a/src/compiler/transform/index.ts b/src/compiler/transform/index.ts
index 6a81b92b0..02a98709b 100644
--- a/src/compiler/transform/index.ts
+++ b/src/compiler/transform/index.ts
@@ -56,6 +56,7 @@ function walkAstWithVisitors(tmpl: TemplateNode, collection: VisitorCollection)
walk(tmpl, {
enter(node, parent, key, index) {
if (collection.enter.has(node.type)) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const fns = collection.enter.get(node.type)!;
for (let fn of fns) {
fn.call(this, node, parent, key, index);
@@ -64,6 +65,7 @@ function walkAstWithVisitors(tmpl: TemplateNode, collection: VisitorCollection)
},
leave(node, parent, key, index) {
if (collection.leave.has(node.type)) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const fns = collection.leave.get(node.type)!;
for (let fn of fns) {
fn.call(this, node, parent, key, index);
diff --git a/src/compiler/transform/prism.ts b/src/compiler/transform/prism.ts
index 5433f3586..7848e1672 100644
--- a/src/compiler/transform/prism.ts
+++ b/src/compiler/transform/prism.ts
@@ -4,13 +4,13 @@ import { getAttrValue } from '../../ast.js';
const PRISM_IMPORT = `import Prism from 'astro/components/Prism.astro';\n`;
const prismImportExp = /import Prism from ['"]astro\/components\/Prism.astro['"]/;
-
+/** escaping code samples that contain template string replacement parts, ${foo} or example. */
function escape(code: string) {
return code.replace(/[`$]/g, (match) => {
return '\\' + match;
});
}
-
+/** default export - Transform prism */
export default function (module: Script): Transformer {
let usesPrism = false;
diff --git a/src/compiler/transform/styles.ts b/src/compiler/transform/styles.ts
index d8e3196a1..0c7b4c3c1 100644
--- a/src/compiler/transform/styles.ts
+++ b/src/compiler/transform/styles.ts
@@ -124,6 +124,7 @@ async function transformStyle(code: string, { type, filename, scopedClass, mode
const { default: tailwindcss } = await import('@tailwindcss/jit');
postcssPlugins.push(tailwindcss());
} catch (err) {
+ // eslint-disable-next-line no-console
console.error(err);
throw new Error(`tailwindcss not installed. Try running \`npm install tailwindcss\` and trying again.`);
}