Skip to content

Commit

Permalink
Add schema and further testing for newlines option on `newline-afte…
Browse files Browse the repository at this point in the history
…r-import`
  • Loading branch information
ntdb committed Feb 13, 2017
1 parent 8c7ea26 commit 1d757dc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ function isClassWithDecorator(node) {
module.exports = {
meta: {
docs: {},
schema: [
{
'type': 'object',
'properties': {
'newlines': {
'type': 'integer',
'minimum': 1,
},
},
'additionalProperties': false,
},
],
},
create: function (context) {
let level = 0
Expand Down
20 changes: 20 additions & 0 deletions tests/src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parserOptions: { sourceType: 'module' },
options: [{ 'newlines': 2 }],
},
{
code: `import foo from 'foo';\n\n\n\n\nvar foo = 'bar';`,
parserOptions: { sourceType: 'module' },
options: [{ 'newlines': 4 }],
},
{
code: `var foo = require('foo-module');\n\nvar foo = 'bar';`,
parserOptions: { sourceType: 'module' },
Expand All @@ -94,6 +99,11 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parserOptions: { sourceType: 'module' },
options: [{ 'newlines': 2 }],
},
{
code: `var foo = require('foo-module');\n\n\n\n\nvar foo = 'bar';`,
parserOptions: { sourceType: 'module' },
options: [{ 'newlines': 4 }],
},
{
code: `require('foo-module');\n\nvar foo = 'bar';`,
parserOptions: { sourceType: 'module' },
Expand Down Expand Up @@ -173,6 +183,16 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
} ],
parserOptions: { sourceType: 'module' },
},
{
code: `import foo from 'foo';\nexport default function() {};`,
options: [{ 'newlines': 1 }],
errors: [ {
line: 1,
column: 1,
message: IMPORT_ERROR_MESSAGE,
} ],
parserOptions: { sourceType: 'module' },
},
{
code: `var foo = require('foo-module');\nvar something = 123;`,
errors: [ {
Expand Down

0 comments on commit 1d757dc

Please sign in to comment.