-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import type { AstPath } from 'prettier'; | ||
|
||
import isAngularComponentSelector from './is-angular-component-selector.js'; | ||
import isDynamicImport from './is-dynamic-import.js'; | ||
import isImportExport from './is-import-export.js'; | ||
import isProperty from './is-property.js'; | ||
|
||
export default function (path: AstPath): boolean { | ||
return !isImportExport(path) && !isProperty(path) && !isDynamicImport(path); | ||
return ( | ||
!isImportExport(path) && | ||
!isProperty(path) && | ||
!isDynamicImport(path) && | ||
!isAngularComponentSelector(path) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { AstPath } from 'prettier'; | ||
|
||
// TODO https://youtrack.jetbrains.com/issue/WEB-56900/Angular-doesnt-parse-plain-backticks-in-decorators#focus=Comments-27-6392379.0-0 | ||
export default function (path: AstPath): boolean { | ||
const [ | ||
propertyNode, | ||
objectExpressionNode, | ||
callExpressionNode, | ||
decoratorNode, | ||
classDeclarationNode, | ||
] = path.ancestors; | ||
|
||
if ( | ||
propertyNode?.type !== 'Property' || | ||
objectExpressionNode?.type !== 'ObjectExpression' || | ||
callExpressionNode?.type !== 'CallExpression' || | ||
decoratorNode?.type !== 'Decorator' || | ||
classDeclarationNode?.type !== 'ClassDeclaration' | ||
) { | ||
return false; | ||
} | ||
|
||
{ | ||
const { | ||
key: { type, name }, | ||
} = propertyNode; | ||
|
||
if (type !== 'Identifier' || name !== 'selector') { | ||
return false; | ||
} | ||
} | ||
|
||
{ | ||
const { | ||
callee: { type, name }, | ||
} = callExpressionNode; | ||
|
||
if (type !== 'Identifier' || name !== 'Component') { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'test', | ||
templateUrl: 'test.html', | ||
}) | ||
export class TestComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "test", | ||
templateUrl: `test.html`, | ||
}) | ||
export class TestComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters