Skip to content
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

[Fix] newline-after-import: recognize decorators #1139

Merged
merged 2 commits into from
Apr 24, 2020

Conversation

atos1990
Copy link

@atos1990 atos1990 commented Jul 17, 2018

Hi, this is my fix issue #1004

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, could you also provide a regression test?

@ljharb ljharb added the bug label Jul 17, 2018
@coveralls
Copy link

coveralls commented Jul 17, 2018

Coverage Status

Coverage increased (+0.005%) to 97.739% when pulling b307c7c on atos1990:issue#1004 into 95c12fc on benmosher:master.

@atos1990
Copy link
Author

@ljharb, done

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add "output" to each of these new test cases, so the autofixer can be covered too?

@atos1990
Copy link
Author

@ljharb, sorry for my mistake - it's my first test cases for ESLint :) done

{
code : `// issue 1004
import foo from 'foo';\n
@SomeDecorator(foo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, if a newline is required after import, this should be invalid - there needs to be a blank line between the import line and the decorator.

{
code : `// issue 1004
const foo = require('foo');\n
@SomeDecorator(foo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

`,
output: `// issue 10042
import foo from 'foo';\n
@SomeDecorator(foo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should autofix to add a blank line above the decorator

`,
output: `// issue 1004
const foo = require('foo');\n
@SomeDecorator(foo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should autofix to add a blank line above the decorator

@@ -349,5 +359,27 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parserOptions: { sourceType: 'module' },
parser: 'babel-eslint',
},
{
code: `// issue 10042\nimport foo from 'foo';\n@SomeDecorator(foo)\nexport default class Test {}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these be reverted to use actual newlines instead of \n? it's much more readable.

@ljharb
Copy link
Member

ljharb commented Nov 3, 2019

ping @atos1990, this also needs a rebase

@TrejGun
Copy link

TrejGun commented Dec 11, 2019

@atos1990, please rebase

@shastaxc
Copy link

shastaxc commented Apr 8, 2020

Came here looking for this fix. ETA on merge? With this rule not working with decorators, it pretty much means it won't work with any of my ts files in Angular, which is the only thing I'm using ESLint for.

@ljharb ljharb changed the title Fix #1004 newline-after-import not recognizing decorator [Fix] newline-after-import: recognize decorators Apr 24, 2020
@ljharb ljharb merged commit b307c7c into import-js:master Apr 24, 2020
@TrejGun
Copy link

TrejGun commented Apr 26, 2020

thanks @ljharb

@elbertcastaneda
Copy link

We continue with this error in the latest version, I am thinking that the next version could contain this fix, is it right?

@ljharb
Copy link
Member

ljharb commented May 9, 2020

Yes.

@skoblenick
Copy link

still don't see this fix in main and releases have been done after this was confirmed to be in the "next" release

@ljharb
Copy link
Member

ljharb commented Jan 13, 2022

@skoblenick as you can see if you click on the commit that closed the PR, it is in both main, and every version v2.21.0 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

7 participants