diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ast.ts | 2 | ||||
-rw-r--r-- | src/build/bundle.ts | 5 | ||||
-rw-r--r-- | src/build/static.ts | 1 | ||||
-rw-r--r-- | src/cli.ts | 2 | ||||
-rw-r--r-- | src/compiler/codegen.ts | 5 | ||||
-rw-r--r-- | src/compiler/transform/doctype.ts | 1 | ||||
-rw-r--r-- | src/compiler/transform/index.ts | 2 | ||||
-rw-r--r-- | src/compiler/transform/prism.ts | 4 | ||||
-rw-r--r-- | src/compiler/transform/styles.ts | 1 | ||||
-rw-r--r-- | src/dev.ts | 1 | ||||
-rw-r--r-- | src/parser/utils/link.ts | 1 | ||||
-rw-r--r-- | src/search.ts | 4 |
12 files changed, 25 insertions, 4 deletions
diff --git a/src/ast.ts b/src/ast.ts index 88178d399..faf4b3eb6 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -20,7 +20,9 @@ export function getAttrValue(attributes: Attribute[], name: string): string | un export function setAttrValue(attributes: Attribute[], name: string, value: string): void { const attr = attributes.find((a) => a.name === name); if (attr) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion attr.value[0]!.data = value; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion attr.value[0]!.raw = value; } } diff --git a/src/build/bundle.ts b/src/build/bundle.ts index b55828c2e..e447097a2 100644 --- a/src/build/bundle.ts +++ b/src/build/bundle.ts @@ -147,17 +147,21 @@ export async function collectDynamicImports(filename: URL, { astroConfig, loggin switch (defn.plugin) { case 'preact': { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion imports.add(dynamic.get('preact')!); rel = rel.replace(/\.[^.]+$/, '.js'); break; } case 'react': { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion imports.add(dynamic.get('react')!); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion imports.add(dynamic.get('react-dom')!); rel = rel.replace(/\.[^.]+$/, '.js'); break; } case 'vue': { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion imports.add(dynamic.get('vue')!); rel = rel.replace(/\.[^.]+$/, '.vue.js'); break; @@ -275,6 +279,7 @@ export async function bundle(imports: Set<string>, { runtime, dist }: BundleOpti format: 'esm', exports: 'named', entryFileNames(chunk) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return chunk.facadeModuleId!.substr(1); }, plugins: [ diff --git a/src/build/static.ts b/src/build/static.ts index b24ce7729..96cb72b7f 100644 --- a/src/build/static.ts +++ b/src/build/static.ts @@ -8,6 +8,7 @@ export function collectStatics(html: string) { const $ = cheerio.load(html); const append = (el: Element, attr: string) => { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const value: string = $(el).attr(attr)!; if (value.startsWith('http')) { return; diff --git a/src/cli.ts b/src/cli.ts index 71c9691d7..7adf0c810 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import type { AstroConfig } from './@types/astro'; import * as colors from 'kleur/colors'; @@ -90,6 +91,7 @@ export async function cli(args: string[]) { } case 'build': case 'dev': { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const cmd = cmdMap.get(state)!; runCommand(flags._[3], cmd); } 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.`); } diff --git a/src/dev.ts b/src/dev.ts index 851379d7b..8c4140259 100644 --- a/src/dev.ts +++ b/src/dev.ts @@ -66,6 +66,7 @@ export default async function dev(astroConfig: AstroConfig) { }); server.listen(port, hostname, () => { + // eslint-disable-next-line no-console console.log(`Server running at http://${hostname}:${port}/`); }); } diff --git a/src/parser/utils/link.ts b/src/parser/utils/link.ts index 0dc5af1b7..4e2ed662f 100644 --- a/src/parser/utils/link.ts +++ b/src/parser/utils/link.ts @@ -1,3 +1,4 @@ +/** Linked list */ export function link<T extends { next?: T; prev?: T }>(next: T, prev: T) { prev.next = next; if (next) next.prev = prev; diff --git a/src/search.ts b/src/search.ts index 043b5c347..963f8223b 100644 --- a/src/search.ts +++ b/src/search.ts @@ -4,7 +4,7 @@ interface PageLocation { fileURL: URL; snowpackURL: string; } - +/** findAnyPage and return the _astro candidate for snowpack */ function findAnyPage(candidates: Array<string>, astroRoot: URL): PageLocation | false { for (let candidate of candidates) { const url = new URL(`./pages/${candidate}`, astroRoot); @@ -32,7 +32,7 @@ type SearchResult = | { statusCode: 404; }; - +/** searchForPage - look for astro or md pages */ export function searchForPage(url: URL, astroRoot: URL): SearchResult { const reqPath = decodeURI(url.pathname); const base = reqPath.substr(1); |