diff --git a/src/rules/newline-after-import.js b/src/rules/newline-after-import.js index f11ddeffd0..ccd564b2d1 100644 --- a/src/rules/newline-after-import.js +++ b/src/rules/newline-after-import.js @@ -76,20 +76,7 @@ module.exports = { create(context) { let level = 0; const requireCalls = []; - const options = setOptions(context); - - function setOptions(context) { - if (context.options[0]) { - if ('count' in context.options[0] && 'considerComments' in context.options[0] ) { - return context.options[0]; - } else if ( 'count' in context.options[0] ) { - return Object.assign({}, context.options[0], { considerComments: false }); - } else { - return Object.assign({}, context.options[0], { count: 1 }); - } - } - return { count: 1, considerComments: false }; - } + const options = Object.assign({ count: 1, considerComments: false }, context.options[0]); function checkForNewLine(node, nextNode, type) { if (isExportDefaultClass(nextNode) || isExportNameClass(nextNode)) { diff --git a/tests/src/rules/newline-after-import.js b/tests/src/rules/newline-after-import.js index 9eb5677bda..dc0d3d4059 100644 --- a/tests/src/rules/newline-after-import.js +++ b/tests/src/rules/newline-after-import.js @@ -321,6 +321,17 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), { `, parserOptions: { ecmaVersion: 2015, sourceType: 'module' } , }, + { + code: ` + import { A, B, C, D } from + '../path/to/my/module/in/very/far/directory' + + // some comment + var foo = 'bar'; + `, + parserOptions: { ecmaVersion: 2015, sourceType: 'module' }, + options: [{ 'considerComments': true }], + }, ), invalid: [].concat(