Please use @angular-eslint/prefer-standalone
instead.
Ensures component standalone
property is set to true
in the component decorator
- Type: suggestion
- 🔧 Supports autofix (
--fix
)
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/prefer-standalone-component": [
"error"
]
}
}
@Component({})
~~~~~~~~~~~~~~
class Test {}
{
"rules": {
"@angular-eslint/prefer-standalone-component": [
"error"
]
}
}
@Component({ standalone: false })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Test {}
{
"rules": {
"@angular-eslint/prefer-standalone-component": [
"error"
]
}
}
@Component({
~~~~~~~~~~~~
standalone: false,
~~~~~~~~~~~~~~~~~~
template: '<div></div>'
~~~~~~~~~~~~~~~~~~~~~~~
})
~~
class Test {}
{
"rules": {
"@angular-eslint/prefer-standalone-component": [
"error"
]
}
}
@Component({
~~~~~~~~~~~~
template: '<div></div>'
~~~~~~~~~~~~~~~~~~~~~~~
})
~~
class Test {}
{
"rules": {
"@angular-eslint/prefer-standalone-component": [
"error"
]
}
}
@Component({
~~~~~~~~~~~~
selector: 'my-selector',
~~~~~~~~~~~~~~~~~~~~~~~
template: '<div></div>'
~~~~~~~~~~~~~~~~~~~~~~~
})
~~
class Test {}
✅ - Toggle examples of correct code for this rule
{
"rules": {
"@angular-eslint/prefer-standalone-component": [
"error"
]
}
}
@Component({
standalone: true,
})
class Test {}
{
"rules": {
"@angular-eslint/prefer-standalone-component": [
"error"
]
}
}
@Component({
standalone: true,
selector: 'test-selector'
})
class Test {}
{
"rules": {
"@angular-eslint/prefer-standalone-component": [
"error"
]
}
}
@Component({
selector: 'test-selector',
standalone: true,
template: '<div></div>',
styleUrls: ['./test.css']
})
class Test {}