Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
divmain committed Jun 26, 2023
1 parent 5512408 commit 044b8fb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ it('linter returns empty diagnostics on correct file', async () => {
expect(diagnostics).toEqual([]);
});

it('transform returns javascript metadata', async () => {
it('mapLwcMetadataToInternal returns expected javascript metadata', async () => {
const filepath = path.join('src', 'javascript', '__tests__', 'fixtures', 'metadata.js');
const content = fs.readFileSync(filepath, 'utf8');

Expand All @@ -120,8 +120,6 @@ it('transform returns javascript metadata', async () => {

const modernMetadata = collectBundleMetadata(options);
const metadata = mapLwcMetadataToInternal(modernMetadata.files[0] as ScriptFile);

// TODO: see if the rest of this works as expected
const properties = getProperties(metadata);

expect(metadata.doc).toBe('* Foo doc');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ it('can map new metadata to old metadata', async () => {
const filepath = path.join('src', 'javascript', '__tests__', 'fixtures', 'metadata.js');
const content = fs.readFileSync(filepath, 'utf8');

// Work with new metadata.
const newMetadataOpts: BundleConfig = {
type: 'internal',
name: 'metadata',
Expand Down
10 changes: 3 additions & 7 deletions packages/lwc-language-server/src/javascript/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ function toDiagnostic(err: any): Diagnostic {
};
}

function externalToInternalDiagnostic(ext: CompilerDiagnostic[]): Diagnostic[] {
// TODO: do this for real
return ext as unknown as Diagnostic[];
}

export async function compileSource(source: string, fileName = 'foo.js'): Promise<CompilerResult> {
const name = fileName.substring(0, fileName.lastIndexOf('.'));

Expand All @@ -142,7 +137,6 @@ export async function compileSource(source: string, fileName = 'foo.js'): Promis
diagnostics: [toDiagnostic(err)],
};
}
// TODO: should we do something with transformSync(...).warnings?

const options: BundleConfig = {
type: 'platform',
Expand All @@ -158,7 +152,9 @@ export async function compileSource(source: string, fileName = 'foo.js'): Promis
};
const modernMetadata = collectBundleMetadata(options);
if (modernMetadata?.diagnostics.length) {
return { diagnostics: externalToInternalDiagnostic(modernMetadata.diagnostics) };
return {
diagnostics: modernMetadata.diagnostics.map(toDiagnostic),
};
}

const metadata = mapLwcMetadataToInternal(modernMetadata.files[0] as ScriptFile);
Expand Down

0 comments on commit 044b8fb

Please sign in to comment.