Eslint-plugin-import: newline-after-import ignoring angular annotations.

Created on 29 May 2020  路  4Comments  路  Source: benmosher/eslint-plugin-import

With the following rule:

"import/newline-after-import": "error"

If I write:

import { DemoModel } from '../app/models/demo.model';
import { HomeComponent } from './views/home/home.component';
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})

No error is throw. But if I write:

import { DemoModel } from '../app/models/demo.model';
import { HomeComponent } from './views/home/home.component';
const x = 2;

it works as expected.
The way I see it, it should not care what the next line is (if not import, of course).

Here are the images:

Screen Shot 2020-05-29 at 11 50 42
Screen Shot 2020-05-29 at 11 50 26

bug help wanted

Most helpful comment

Are you saying you expect a newline above the decorator, below the imports, and it's not forcing one? If so, that is indeed a bug.

Exactly.

All 4 comments

What is an "anchor annotation"? That looks like decorators syntax, a stage 2 proposal that's on its 4th syntax/semantics iteration.

Are you saying you expect a newline above the decorator, below the imports, and it's not forcing one? If so, that is indeed a bug.

Are you saying you expect a newline above the decorator, below the imports, and it's not forcing one? If so, that is indeed a bug.

Exactly.

I can confirm that bug makes newline-after-imports pretty much useless in an Angular project, considering most of the typescript files in an angular project start with imports followed directly by the declaration of a decorated class.

Any updates about this?

Was this page helpful?
0 / 5 - 0 ratings