-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
There was a problem hiding this 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, done |
There was a problem hiding this 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?
@ljharb, sorry for my mistake - it's my first test cases for ESLint :) done |
{ | ||
code : `// issue 1004 | ||
import foo from 'foo';\n | ||
@SomeDecorator(foo) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 {}`, |
There was a problem hiding this comment.
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.
ping @atos1990, this also needs a rebase |
@atos1990, please rebase |
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. |
newline-after-import
: recognize decorators
thanks @ljharb |
We continue with this error in the latest version, I am thinking that the next version could contain this fix, is it right? |
Yes. |
still don't see this fix in |
@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. |
Hi, this is my fix issue #1004