Skip to content

Commit

Permalink
Merge branch 'main' into prefer-combined-type-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
benkrejci authored Jul 25, 2023
2 parents 9c34583 + e2cf99c commit 4517190
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
- [`consistent-type-specifier-style`]: fix accidental removal of comma in certain cases ([#2754], thanks [@bradzacher])
- [Perf] `ExportMap`: Improve `ExportMap.for` performance on larger codebases ([#2756], thanks [@leipert])
- [`no-extraneous-dependencies`]/TypeScript: do not error when importing inline type from dev dependencies ([#1820], thanks [@andyogo])
- [`newline-after-import`]/TypeScript: do not error when re-exporting a namespaced import ([#2832], thanks [@laurens-dg])
* [`order`]: partial fix for [#2687] (thanks [@ljharb])

### Changed
Expand Down Expand Up @@ -1073,6 +1074,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#2832]: https://github.com/import-js/eslint-plugin-import/pull/2832
[#2756]: https://github.com/import-js/eslint-plugin-import/pull/2756
[#2754]: https://github.com/import-js/eslint-plugin-import/pull/2754
[#2748]: https://github.com/import-js/eslint-plugin-import/pull/2748
Expand Down Expand Up @@ -1747,6 +1749,7 @@ for info on changes for earlier releases.
[@KostyaZgara]: https://github.com/KostyaZgara
[@kylemh]: https://github.com/kylemh
[@laysent]: https://github.com/laysent
[@laurens-dg]: https://github.com/laurens-dg
[@le0nik]: https://github.com/le0nik
[@leipert]: https://github.com/leipert
[@lemonmade]: https://github.com/lemonmade
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"object.fromentries": "^2.0.6",
"object.values": "^1.1.6",
"resolve": "^1.22.3",
"semver": "^6.3.0",
"semver": "^6.3.1",
"tsconfig-paths": "^3.14.2"
}
}
5 changes: 5 additions & 0 deletions src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ module.exports = {

function checkImport(node) {
const { parent } = node;

if (!parent || !parent.body) {
return;
}

const nodePosition = parent.body.indexOf(node);
const nextNode = parent.body[nodePosition + 1];
const endLine = node.loc.end.line;
Expand Down
16 changes: 13 additions & 3 deletions tests/src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
code: `
const x = () => require('baz')
, y = () => require('bar')
// some comment here
`,
parserOptions: { ecmaVersion: 6 },
Expand Down Expand Up @@ -273,6 +273,16 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parser,
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
{
code: `
import { ns } from 'namespace';
import Bar = ns.baz.foo.Bar;
export import Foo = ns.baz.bar.Foo;
`,
parser,
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
)),
{
code: `
Expand All @@ -299,7 +309,7 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
{
code: `
import path from 'path';import foo from 'foo';
/**
* some multiline comment here
* another line of comment
Expand All @@ -313,7 +323,7 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
code: `
import path from 'path';
import foo from 'foo';
// Some random single line comment
var bar = 42;
`,
Expand Down

0 comments on commit 4517190

Please sign in to comment.