Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ ignores: ['coverage/', 'lib/', '**/.yarn/**', '**/.pnp.*'] },
{ ignores: ['coverage/', 'lib/', '**/.yarn/**', '**/.pnp.*', 'dist*/'] },
eslintPluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
Expand Down
4 changes: 4 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @see https://prettier.io/docs/configuration
* @type {import("prettier").Config}
*/
export default {
singleQuote: true,
trailingComma: 'all',
Expand Down
5 changes: 1 addition & 4 deletions src/angular-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ function extractComments(text: string, shouldExtractComment: boolean) {
}),
};

return {
text: text.slice(0, commentStart),
comments: [comment],
};
return { text: text.slice(0, commentStart), comments: [comment] };
}

function createAngularParseFunction<
Expand Down
20 changes: 18 additions & 2 deletions src/source.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as angular from '@angular/compiler';
import type * as babel from '@babel/types';

import type { LocationInformation, NGNode, RawNGSpan } from './types.ts';
Expand Down Expand Up @@ -27,11 +28,26 @@ export class Source {
}

createNode<T extends NGNode>(
properties: Partial<T> & { type: T['type'] } & RawNGSpan,
properties: Partial<T> & { type: T['type'] },
location: angular.AST | RawNGSpan | [number, number],
) {
let start: number;
let end: number;
let range: [number, number];
if (Array.isArray(location)) {
range = location;
[start, end] = location;
} else {
({ start, end } =
location instanceof angular.AST ? location.sourceSpan : location);
range = [start, end];
}

const node = {
start,
end,
range,
...properties,
range: [properties.start, properties.end],
} as T & LocationInformation;

switch (node.type) {
Expand Down
Loading