Skip to content

Commit

Permalink
Update error message in case expected number of empty lines is more t…
Browse files Browse the repository at this point in the history
…han 1
  • Loading branch information
AdamSelene committed Oct 25, 2017
1 parent 98acd6a commit a42246a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ module.exports = {
line: node.loc.end.line,
column,
},
message: `Expected empty line after ${type} statement not followed by another ${type}.`,
message: `Expected ${options.count} empty line${options.count > 1 ? 's' : ''} \
after ${type} statement not followed by another ${type}.`,
fix: fixer => fixer.insertTextAfter(
node,
'\n'.repeat(EXPECTED_LINE_DIFFERENCE - lineDifference)
Expand Down
11 changes: 7 additions & 4 deletions tests/src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { RuleTester } from 'eslint'

const IMPORT_ERROR_MESSAGE = 'Expected empty line after import statement not followed by another import.'
const REQUIRE_ERROR_MESSAGE = 'Expected empty line after require statement not followed by another require.'
const IMPORT_ERROR_MESSAGE = 'Expected 1 empty line after import statement not followed by another import.'
const IMPORT_ERROR_MESSAGE_MULTIPLE = function(count) {
return `Expected ${count} empty lines after import statement not followed by another import.`
}
const REQUIRE_ERROR_MESSAGE = 'Expected 1 empty line after require statement not followed by another require.'

const ruleTester = new RuleTester()

Expand Down Expand Up @@ -181,7 +184,7 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
errors: [ {
line: 1,
column: 1,
message: IMPORT_ERROR_MESSAGE,
message: IMPORT_ERROR_MESSAGE_MULTIPLE(2),
} ],
parserOptions: { sourceType: 'module' },
},
Expand Down Expand Up @@ -347,4 +350,4 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parser: 'babel-eslint',
},
],
});
})

0 comments on commit a42246a

Please sign in to comment.