mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
2.2 KiB
2.2 KiB
DSpace ESLint plugins > TypeScript rules > dspace-angular-ts/alias-imports
Unclear imports should be aliased for clarity
Options
aliases
A list of all the imports that you want to alias for clarity. Every alias should be declared in the following format:
{
"package": "rxjs",
"imported": "of",
"local": "observableOf"
}
Examples
Valid code
correctly aliased imports
import { of as observableOf } from 'rxjs';
With options:
{
"aliases": [
{
"package": "rxjs",
"imported": "of",
"local": "observableOf"
}
]
}
enforce unaliased import
import { combineLatest } from 'rxjs';
With options:
{
"aliases": [
{
"package": "rxjs",
"imported": "combineLatest",
"local": "combineLatest"
}
]
}
Invalid code & automatic fixes
imports without alias
import { of } from 'rxjs';
Will produce the following error(s):
This import must be aliased
Result of yarn lint --fix
:
import { of as observableOf } from 'rxjs';
imports under the wrong alias
import { of as ofSomething } from 'rxjs';
Will produce the following error(s):
This import uses the wrong alias (should be {{ local }})
Result of yarn lint --fix
:
import { of as observableOf } from 'rxjs';
disallow aliasing import
import { combineLatest as observableCombineLatest } from 'rxjs';
With options:
```json
{
"aliases": [
{
"package": "rxjs",
"imported": "combineLatest",
"local": "combineLatest"
}
]
}
Will produce the following error(s):
This import should not use an alias
Result of `yarn lint --fix`:
```typescript
import { combineLatest } from 'rxjs';