Ensures that output bindings, including aliases, are not named "on", nor prefixed with it. See more at https://angular.io/guide/styleguide#style-05-16
- Type: suggestion
The rule does not have any configuration options.
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.
❌ - Toggle examples of incorrect code for this rule
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component({
outputs: ['on']
~~~~
})
class Test {}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive({
inputs: [onCredit],
'outputs': [onLevel, `test: on`, onFunction()],
~~~~~~~~~~
})
class Test {}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component({
['outputs']: ['onTest: test', ...onArray],
~~~~~~~~~~~~~~
})
class Test {}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive({
[`outputs`]: ['onTest: test', ...onArray],
~~~~~~~~~~~~~~
})
class Test {}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component()
class Test {
@Output() on: EventEmitter<any> = new EventEmitter<{}>();
~~
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive()
class Test {
@Output() @Custom('on') 'onPrefix' = new EventEmitter<void>();
~~~~~~~~~~
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component()
class Test {
@Custom() @Output(`on`) _on = getOutput();
~~~~
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive()
class Test {
@Output('onPrefix') _on = (this.subject$ as Subject<{on: boolean}>).pipe();
~~~~~~~~~~
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component()
class Test {
@Output('getter') get 'on-getter'() {}
~~~~~~~~~~~
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Injectable()
class Test {
@Output('on') onPrefix = this.getOutput();
~~~~ ~~~~~~~~
}
✅ - Toggle examples of correct code for this rule
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
class Test {}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Page({
outputs: ['on', onChange, `onLine`, 'on: on2', 'offline: on', ...onCheck, onOutput()],
})
class Test {}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component()
class Test {
on = new EventEmitter();
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive()
class Test {
@Output() buttonChange = new EventEmitter<'on'>();
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component()
class Test {
@Output() On = new EventEmitter<{ on: onType }>();
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive()
class Test {
@Output(`one`) ontype = new EventEmitter<{ bar: string, on: boolean }>();
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Component()
class Test {
@Output('oneProp') common = new EventEmitter<ComplextOn>();
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive()
class Test<On> {
@Output() ON = new EventEmitter<On>();
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
const on = 'on';
@Component()
class Test {
@Output(on) touchMove: EventEmitter<{ action: 'on' | 'off' }> = new EventEmitter<{ action: 'on' | 'off' }>();
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
const test = 'on';
const on = 'on';
@Directive()
class Test {
@Output(test) [on]: EventEmitter<OnTest>;
}
{
"rules": {
"@angular-eslint/no-output-on-prefix": [
"error"
]
}
}
@Directive({
selector: 'foo',
})
class Test {
@Output() get 'getter'() {}
}