-
-
Notifications
You must be signed in to change notification settings - Fork 244
8000
Show file tree
Hide file tree
Sep 20, 2021
Sep 20, 2021
Sep 22, 2021
Sep 22, 2021
Sep 22, 2021
8000
280 changes: 280 additions & 0 deletions
280
packages/eslint-plugin-template/docs/rules/no-restricted-syntax.md
View file
Edit file
Delete file
Open in desktop
View file
Edit file
Delete file
Open in desktop
View file
Edit file
Delete file
Open in desktop
Loading
Toggle all file notes
Toggle all file annotations
feat(eslint-plugin-template): [no-restricted-syntax] add rule #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
rafaelss95
wants to merge
5
commits into
angular-eslint:main
from
rafaelss95:feat/template/no-restricted-syntax
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6d03583
feat(eslint-plugin-template): add utility
rafaelss95 eb554a1
feat(eslint-plugin-template): [no-restricted-syntax] add rule
rafaelss95 3e9ac6c
refactor: changes to make TS 4.3 happy
rafaelss95 c74013d
docs: update
rafaelss95 319c778
docs: add to config
rafaelss95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,280 @@ | ||
<!-- | ||
|
||
DO NOT EDIT. | ||
|
||
This markdown file was autogenerated using a mixture of the following files as the source of truth for its data: | ||
- ../../src/rules/no-restricted-syntax.ts | ||
- ../../tests/rules/no-restricted-syntax/cases.ts | ||
|
||
In order to update this file, it is therefore those files which need to be updated, as well as potentially the generator script: | ||
- ../../../../tools/scripts/generate-rule-docs.ts | ||
|
||
--> | ||
|
||
<br> | ||
|
||
# `@angular-eslint/template/no-restricted-syntax` | ||
|
||
Disallows specified syntax. | ||
|
||
- Type: suggestion | ||
- Category: Stylistic Issues | ||
|
||
<br> | ||
|
||
## Rule Options | ||
|
||
The rule does not have any configuration options. | ||
|
||
<br> | ||
|
||
## Usage Examples | ||
|
||
> The following examples are generated automatically from the actual unit tests within the plugin, so you can be assured that their behavior is accurate based on the current commit. | ||
|
||
<br> | ||
|
||
<details> | ||
<summary>❌ - Toggle examples of <strong>incorrect</strong> code for this rule</summary> | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
"Interpolation" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ❌ Invalid Code | ||
|
||
```html | ||
<article>{{readSomethingPlease}}</article> | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
``` | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
{ | ||
"selector": "Element[name='button']:not(:has(:matches(BoundAttribute, TextAttribute)[name='type']))", | ||
"message": "Missing an explicit type attribute for button" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ❌ Invalid Code | ||
|
||
```html | ||
<button>Click me!</button> | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
``` | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
{ | ||
"selector": "Element[name='button'] :matches(BoundAttribute, TextAttribute)[name='type'][value!=/^(button|reset|submit)$/]" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ❌ Invalid Code | ||
|
||
```html | ||
<button type="invalidType">Click me!</button> | ||
~~~~~~~~~~~~~~~~~~ | ||
``` | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
"BoundAttribute[name=\"ngClass\"]" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ❌ Invalid Code | ||
|
||
```html | ||
<button [ngClass]="classes?.class1">Click me!</button> | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
``` | ||
|
||
</details> | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
<details> | ||
<summary>✅ - Toggle examples of <strong>correct</strong> code for this rule</summary> | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
"Binary[operation=/^(==|!=)$/]" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ✅ Valid Code | ||
|
||
```html | ||
{{ amIUsingStrictEquality === true ? 'Yes' : 'No' }} | ||
``` | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
"Template[children.length=0]" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ✅ Valid Code | ||
|
||
```html | ||
<input [formControl]="formControl"> | ||
<textarea [ngModel]="formControl"></textarea> | ||
<ng-template>Child here!</ng-template> | ||
``` | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
{ | ||
"selector": ":matches(BoundAttribute, TextAttribute)[name='ngClass']" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ✅ Valid Code | ||
|
||
```html | ||
<div [class]="classes"></div> | ||
``` | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
#### Custom Config | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"@angular-eslint/template/no-restricted-syntax": [ | ||
"error", | ||
{ | ||
"message": "Do not use `| json`.", | ||
"selector": "BindingPipe[name='json']" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
<br> | ||
|
||
#### ✅ Valid Code | ||
|
||
```html | ||
<ng-container *translator="let translator"> | ||
{{ translator | async }} | ||
</ng-container> | ||
{{ one ?? other }} | ||
``` | ||
|
||
</details> | ||
|
||
<br> |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Retry
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, there's a bug on
json-schema-to-typescript
so it doesn't compile schema well if it containsoneOf
.