Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-estree-parser

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-estree-parser - npm Package Compare versions

Comparing version 3.0.3 to 4.0.0

16

CHANGELOG.md

@@ -5,2 +5,18 @@ # Changelog

## [4.0.0](https://github.com/prettier/angular-estree-parser/compare/v3.0.3...v4.0.0) (2022-10-10)
### ⚠ BREAKING CHANGES
* support for `@angular/compiler@14`, drop support for `@angular/compiler<14` (#233)
### Features
* support for `@angular/compiler@14`, drop support for `@angular/compiler<14` ([#233](https://github.com/prettier/angular-estree-parser/issues/233)) ([ce31031](https://github.com/prettier/angular-estree-parser/commit/ce31031fe7df73007b0de39b20e10c94c1e431ef))
### Bug Fixes
* fix shorthand object property detection ([#235](https://github.com/prettier/angular-estree-parser/issues/235)) ([5ebb640](https://github.com/prettier/angular-estree-parser/commit/5ebb64041b0e48ae0fba6580b68bff0bff4f7026))
### [3.0.3](https://github.com/prettier/angular-estree-parser/compare/v3.0.2...v3.0.3) (2022-10-09)

@@ -7,0 +23,0 @@

4

lib/transform-microsyntax.d.ts

@@ -1,4 +0,4 @@

import * as ng from '@angular/compiler/src/expression_parser/ast.js';
import type * as ng from '@angular/compiler';
import { Context } from './context.js';
import { NGMicrosyntax } from './types.js';
import type { NGMicrosyntax } from './types.js';
export declare function transformTemplateBindings(rawTemplateBindings: ng.TemplateBinding[], context: Context): NGMicrosyntax;

@@ -1,2 +0,2 @@

import * as ng from '@angular/compiler/src/expression_parser/ast.js';
import { ExpressionBinding as NGExpressionBinding, VariableBinding as NGVariableBinding, } from '@angular/compiler';
import { transform, transformSpan, } from './transform.js';

@@ -108,6 +108,6 @@ import { findBackChar, NG_PARSE_TEMPLATE_BINDINGS_FAKE_PREFIX, toLowerCamelCase, } from './utils.js';

function isExpressionBinding(templateBinding) {
return templateBinding instanceof ng.ExpressionBinding;
return templateBinding instanceof NGExpressionBinding;
}
function isVariableBinding(templateBinding) {
return templateBinding instanceof ng.VariableBinding;
return templateBinding instanceof NGVariableBinding;
}

@@ -114,0 +114,0 @@ function fixTemplateBindingSpan(templateBinding) {

@@ -1,2 +0,2 @@

import type * as ng from '@angular/compiler/src/expression_parser/ast.js';
import type * as ng from '@angular/compiler';
import type * as b from '@babel/types';

@@ -3,0 +3,0 @@ import { Context } from './context.js';

@@ -6,3 +6,2 @@ import { findBackChar, findFrontChar, fitSpans, getLast, getNgType, } from './utils.js';

case 'Unary': {
// @ts-ignore: there is no `Unary` in `@angular/compiler@<10.1.0`
const { operator, expr } = node;

@@ -18,19 +17,2 @@ const tArgument = _t(expr);

const { left, operation, right } = node;
const isPrefixAdd = right.span.start === right.span.end; // +1 === 1 - 0
const isPrefixMinus = left.span.start === left.span.end; // -1 === 0 - 1
// `@angular/compiler` changed this to `Unary` since `v10.1.0`
// istanbul ignore next
if (isPrefixAdd || isPrefixMinus) {
const tArgument = left.span.start === left.span.end
? _t(right)
: _t(left);
return _c('UnaryExpression', {
prefix: true,
argument: tArgument,
operator: isPrefixAdd ? '+' : '-',
}, {
start: node.span.start,
end: _getOuterEnd(tArgument),
}, { hasParentParens: isInParentParens });
}
const tLeft = _t(left);

@@ -87,16 +69,2 @@ const tRight = _t(right);

});
case 'FunctionCall': {
const { target, args } = node;
const tArgs = args.length === 1
? [_transformHasParentParens(args[0])]
: args.map(_t);
const tTarget = _t(target);
return _c('CallExpression', {
callee: tTarget,
arguments: tArgs,
}, {
start: _getOuterStart(tTarget),
end: node.span.end, // )
}, { hasParentParens: isInParentParens });
}
case 'ImplicitReceiver': {

@@ -176,18 +144,11 @@ return _c('ThisExpression', {}, node.span, {

}
case 'MethodCall':
case 'SafeMethodCall': {
const isOptionalType = type === 'SafeMethodCall';
const { receiver, name, args } = node;
case 'Call':
case 'SafeCall': {
const isOptionalType = type === 'SafeCall';
const { receiver, args } = node;
const tArgs = args.length === 1
? [_transformHasParentParens(args[0])]
: args.map(_t);
const nameEnd = _findFrontChar(/\S/, _findFrontChar(/\(/, (tArgs.length === 0
? _findFrontChar(/\)/, node.span.end - 1)
: _getOuterStart(tArgs[0])) - 1) - 1) + 1;
const tName = _c('Identifier', { name }, { start: nameEnd - name.length, end: nameEnd });
const tReceiverAndName = _transformReceiverAndName(receiver, tName, {
computed: false,
optional: isOptionalType,
});
const isOptionalReceiver = _isOptionalReceiver(tReceiverAndName);
const tReceiver = _t(receiver);
const isOptionalReceiver = _isOptionalReceiver(tReceiver);
const nodeType = isOptionalType || isOptionalReceiver

@@ -197,7 +158,7 @@ ? 'OptionalCallExpression'

return _c(nodeType, {
callee: tReceiverAndName,
callee: tReceiver,
arguments: tArgs,
optional: nodeType === 'OptionalCallExpression' ? false : undefined,
optional: nodeType === 'OptionalCallExpression' ? isOptionalType : undefined,
}, {
start: _getOuterStart(tReceiverAndName),
start: _getOuterStart(tReceiver),
end: node.span.end, // )

@@ -270,9 +231,2 @@ }, { hasParentParens: isInParentParens });

}
case 'Quote': {
const { prefix, uninterpretedExpression } = node;
return _c('NGQuotedExpression', {
prefix,
value: uninterpretedExpression,
}, node.span, { hasParentParens: isInParentParens });
}
// istanbul ignore next

@@ -279,0 +233,0 @@ default:

@@ -1,3 +0,3 @@

import * as ng from '@angular/compiler/src/expression_parser/ast.js';
import type { RawNGComment, RawNGSpan } from './types';
import * as ng from '@angular/compiler';
import type { RawNGComment, RawNGSpan } from './types.js';
export declare const NG_PARSE_TEMPLATE_BINDINGS_FAKE_PREFIX = "NgEstreeParser";

@@ -4,0 +4,0 @@ export declare function parseNgBinding(input: string): {

@@ -1,4 +0,3 @@

import * as ng from '@angular/compiler/src/expression_parser/ast.js';
import { Lexer } from '@angular/compiler/src/expression_parser/lexer.js';
import { Parser } from '@angular/compiler/src/expression_parser/parser.js';
import * as ng from '@angular/compiler';
import { Lexer, Parser } from '@angular/compiler';
const NG_PARSE_FAKE_LOCATION = 'angular-estree-parser';

@@ -28,3 +27,3 @@ export const NG_PARSE_TEMPLATE_BINDINGS_FAKE_PREFIX = 'NgEstreeParser';

export function parseNgAction(input) {
return parseNg(input, (astInput, ngParser) => ngParser.parseAction(astInput, ...NG_PARSE_SHARED_PARAMS));
return parseNg(input, (astInput, ngParser) => ngParser.parseAction(astInput, false, ...NG_PARSE_SHARED_PARAMS));
}

@@ -42,3 +41,3 @@ export function parseNgTemplateBindings(input) {

const suffix = '}}';
const { ast: rawAst, errors } = ngParser.parseInterpolation(prefix + astInput + suffix, ...NG_PARSE_SHARED_PARAMS);
const { ast: rawAst, errors } = ngParser.parseInterpolation(prefix + astInput + suffix, ...NG_PARSE_SHARED_PARAMS, null);
assertAstErrors(errors);

@@ -97,4 +96,3 @@ const ast = rawAst.expressions[0];

export function getNgType(node) {
// @ts-ignore: there is no `Unary` in `@angular/compiler@<10.1.0`
if (ng.Unary && node instanceof ng.Unary) {
if (node instanceof ng.Unary) {
return 'Unary';

@@ -108,2 +106,5 @@ }

}
if (node instanceof ng.Call) {
return "Call";
}
if (node instanceof ng.Chain) {

@@ -118,5 +119,2 @@ return "Chain";

}
if (node instanceof ng.FunctionCall) {
return "FunctionCall";
}
if (node instanceof ng.ImplicitReceiver) {

@@ -140,5 +138,2 @@ return "ImplicitReceiver";

}
if (node instanceof ng.MethodCall) {
return "MethodCall";
}
if (node instanceof ng.NonNullAssert) {

@@ -156,8 +151,5 @@ return "NonNullAssert";

}
if (node instanceof ng.Quote) {
return "Quote";
if (node instanceof ng.SafeCall) {
return "SafeCall";
}
if (node instanceof ng.SafeMethodCall) {
return "SafeMethodCall";
}
if (node instanceof ng.SafePropertyRead) {

@@ -164,0 +156,0 @@ return "SafePropertyRead";

{
"name": "angular-estree-parser",
"version": "3.0.3",
"version": "4.0.0",
"description": "A parser that converts Angular source code into an ESTree-compatible form",

@@ -20,3 +20,3 @@ "keywords": [],

"lint": "yarn prettier . --check && tslint -p ./tsconfig.json",
"test": "jest",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"prebuild": "rm -rf ./lib",

@@ -31,3 +31,3 @@ "build": "tsc -p ./tsconfig.build.json",

"devDependencies": {
"@angular/compiler": "12.1.0",
"@angular/compiler": "14.2.5",
"@babel/code-frame": "7.18.6",

@@ -51,3 +51,3 @@ "@babel/parser": "7.19.3",

"peerDependencies": {
"@angular/compiler": "^9.1.0 || ^10.0.0 || ^11.0.0 || ^12.0.0"
"@angular/compiler": "^14.0.0"
},

@@ -54,0 +54,0 @@ "engines": {

# angular-estree-parser
[![npm](https://img.shields.io/npm/v/angular-estree-parser.svg)](https://www.npmjs.com/package/angular-estree-parser)
[![build](https://img.shields.io/travis/com/prettier/angular-estree-parser/main.svg)](https://travis-ci.com/prettier/angular-estree-parser/builds)
[![build](https://img.shields.io/github/workflow/status/prettier/angular-estree-parser/CI)](https://github.com/prettier/angular-estree-parser/actions?query=workflow%3ACI+branch%3Amain)
[![coverage](https://img.shields.io/codecov/c/github/prettier/angular-estree-parser/main.svg)](https://codecov.io/gh/prettier/angular-estree-parser)

@@ -24,3 +24,3 @@

```js
const ngEstreeParser = require('angular-estree-parser');
import * as ngEstreeParser from 'angular-estree-parser';

@@ -27,0 +27,0 @@ const ast = ngEstreeParser.parseBinding('a | b:c');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc