Repository: lo1tuma/eslint-plugin-mocha (ts)

Issue:
Support `specify` alias to `it`
We use that pretty extensively in jsdom, but it looks like the no-exclusive-tests rule only supports `it`

Pull request:
Support specify alias
Fixes #57 

Patch:
diff --git a/docs/rules/handle-done-callback.md b/docs/rules/handle-done-callback.md
index 6a95a2a..07dd174 100644
--- a/docs/rules/handle-done-callback.md
+++ b/docs/rules/handle-done-callback.md
@@ -20,7 +20,7 @@ In this example the `done` callback was never called and test will time out.
 
 ## Rule Details
 
-This rule checks each `FunctionExpression` or `ArrowFunctionExpression` inside of `it`, `it.only`, `test`, `test.only`, `before`, `after`, `beforeEach` and `afterEach`.
+This rule checks each `FunctionExpression` or `ArrowFunctionExpression` inside of `it`, `it.only`, `test`, `test.only`, `specify`, `specify.only`, `before`, `after`, `beforeEach` and `afterEach`.
 
 The following patterns are considered warnings:
 
diff --git a/lib/rules/handle-done-callback.js b/lib/rules/handle-done-callback.js
index 0c26875..5f49d02 100644
--- a/lib/rules/handle-done-callback.js
+++ b/lib/rules/handle-done-callback.js
@@ -8,6 +8,8 @@ module.exports = function (context) {
         'it.only',
         'test',
         'test.only',
+        'specify',
+        'specify.only',
         'before',
         'after',
         'beforeEach',


Test patch:
diff --git a/docs/rules/no-exclusive-tests.md b/docs/rules/no-exclusive-tests.md
index 45c8886..eeb3c0a 100644
--- a/docs/rules/no-exclusive-tests.md
+++ b/docs/rules/no-exclusive-tests.md
@@ -10,7 +10,7 @@ This rule reminds you to remove `.only` from your tests by raising a warning whe
 
 ## Rule Details
 
-This rule looks for every `describe.only`, `it.only`, `suite.only`, `test.only` and `context.only` occurrences within the source code.
+This rule looks for every `describe.only`, `it.only`, `suite.only`, `test.only`, `context.only` and `specify.only`occurrences within the source code.
 Of course there are some edge-cases which can’t be detected by this rule e.g.:
 
 ```js
diff --git a/docs/rules/no-skipped-tests.md b/docs/rules/no-skipped-tests.md
index 2f93aba..11f7374 100644
--- a/docs/rules/no-skipped-tests.md
+++ b/docs/rules/no-skipped-tests.md
@@ -7,7 +7,7 @@ Sometimes tests are skipped as part of a debugging process, and aren't intended
 
 ## Rule Details
 
-This rule looks for `describe.skip`, `it.skip`, `suite.skip`, `test.skip`, `context.skip`, `xdescribe`, `xit`, and `xcontext` occurrences within the source code.
+This rule looks for `describe.skip`, `it.skip`, `suite.skip`, `test.skip`, `context.skip`, `specify.skip`, `xdescribe`, `xit`, `xcontext` and `xspecify` occurrences within the source code.
 
 The following patterns are considered warnings:
 
diff --git a/lib/rules/no-exclusive-tests.js b/lib/rules/no-exclusive-tests.js
index 5607de6..3e41a11 100644
--- a/lib/rules/no-exclusive-tests.js
+++ b/lib/rules/no-exclusive-tests.js
@@ -6,7 +6,8 @@ module.exports = function (context) {
         'describe',
         'suite',
         'test',
-        'context'
+        'context',
+        'specify'
     ];
 
     function matchesMochaTestFunction(object) {
diff --git a/lib/rules/no-global-tests.js b/lib/rules/no-global-tests.js
index 1291d3a..cd7ab33 100644
--- a/lib/rules/no-global-tests.js
+++ b/lib/rules/no-global-tests.js
@@ -7,7 +7,10 @@ module.exports = function (context) {
             'it.skip',
             'test',
             'test.only',
-            'test.skip'
+            'test.skip',
+            'specify',
+            'specify.only',
+            'specify.skip'
         ];
 
     function getFnName(callee) {
diff --git a/lib/rules/no-skipped-tests.js b/lib/rules/no-skipped-tests.js
index 0602ceb..30c5b40 100644
--- a/lib/rules/no-skipped-tests.js
+++ b/lib/rules/no-skipped-tests.js
@@ -6,12 +6,14 @@ module.exports = function (context) {
             'describe',
             'suite',
             'test',
-            'context'
+            'context',
+            'specify'
         ],
         mochaXFunctions = [
             'xit',
             'xdescribe',
-            'xcontext'
+            'xcontext',
+            'xspecify'
         ];
 
     function matchesMochaTestFunction(object) {
diff --git a/lib/rules/no-synchronous-tests.js b/lib/rules/no-synchronous-tests.js
index 9af767a..daf6533 100644
--- a/lib/rules/no-synchronous-tests.js
+++ b/lib/rules/no-synchronous-tests.js
@@ -8,6 +8,8 @@ module.exports = function (context) {
         'it.only',
         'test',
         'test.only',
+        'specify',
+        'specify.only',
         'before',
         'after',
         'beforeEach',
diff --git a/test/rules/handle-done-callback.js b/test/rules/handle-done-callback.js
index 6401dc0..2a3163f 100644
--- a/test/rules/handle-done-callback.js
+++ b/test/rules/handle-done-callback.js
@@ -63,6 +63,14 @@ ruleTester.run('handle-done-callback', rules['handle-done-callback'], {
             code: 'test.only("", function (done) { });',
             errors: [ { message: 'Expected "done" callback to be handled.', column: 25, line: 1 } ]
         },
+        {
+            code: 'specify("", function (done) { });',
+            errors: [ { message: 'Expected "done" callback to be handled.', column: 23, line: 1 } ]
+        },
+        {
+            code: 'specify.only("", function (done) { });',
+            errors: [ { message: 'Expected "done" callback to be handled.', column: 28, line: 1 } ]
+        },
         {
             code: 'before(function (done) { });',
             errors: [ { message: 'Expected "done" callback to be handled.', column: 18, line: 1 } ]
diff --git a/test/rules/no-exclusive-tests.js b/test/rules/no-exclusive-tests.js
index f69684f..e3c0f5b 100644
--- a/test/rules/no-exclusive-tests.js
+++ b/test/rules/no-exclusive-tests.js
@@ -20,7 +20,9 @@ ruleTester.run('no-exclusive-tests', rules['no-exclusive-tests'], {
         'context.skip()',
         'var appliedOnly = describe.only; appliedOnly.apply(describe)',
         'var calledOnly = it.only; calledOnly.call(it)',
-        'var dynamicOnly = "only"; suite[dynamicOnly]()'
+        'var dynamicOnly = "only"; suite[dynamicOnly]()',
+        'specify()',
+        'specify.skip()'
     ],
 
     invalid: [
@@ -73,6 +75,16 @@ ruleTester.run('no-exclusive-tests', rules['no-exclusive-tests'], {
             code: 'context["only"]()',
             errors: [ { message: expectedErrorMessage, column: 9, line: 1 } ],
             output: 'context()'
+        },
+        {
+            code: 'specify.only()',
+            errors: [ { message: expectedErrorMessage, column: 9, line: 1 } ],
+            output: 'specify()'
+        },
+        {
+            code: 'specify["only"]()',
+            errors: [ { message: expectedErrorMessage, column: 9, line: 1 } ],
+            output: 'specify()'
         }
     ]
 
diff --git a/test/rules/no-global-tests.js b/test/rules/no-global-tests.js
index 2f72a03..58a3d43 100644
--- a/test/rules/no-global-tests.js
+++ b/test/rules/no-global-tests.js
@@ -81,6 +81,26 @@ ruleTester.run('no-global-tests', rule, {
             code: 'test["skip"]();',
             errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ]
         },
+        {
+            code: 'specify();',
+            errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ]
+        },
+        {
+            code: 'specify.only();',
+            errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ]
+        },
+        {
+            code: 'specify["only"]();',
+            errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ]
+        },
+        {
+            code: 'specify.skip();',
+            errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ]
+        },
+        {
+            code: 'specify["skip"]();',
+            errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ]
+        },
         {
             code: 'import foo from "bar"; it("");',
             parserOptions: {
diff --git a/test/rules/no-skipped-tests.js b/test/rules/no-skipped-tests.js
index d9ed58e..8232d20 100644
--- a/test/rules/no-skipped-tests.js
+++ b/test/rules/no-skipped-tests.js
@@ -88,7 +88,18 @@ ruleTester.run('no-skipped-tests', rules['no-skipped-tests'], {
             code: 'xcontext()',
             errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ],
             output: 'context()'
+        },
+        {
+            code: 'specify.skip()',
+            errors: [ { message: expectedErrorMessage, column: 9, line: 1 } ],
+            output: 'specify()'
+        },
+        {
+            code: 'xspecify()',
+            errors: [ { message: expectedErrorMessage, column: 1, line: 1 } ],
+            output: 'specify()'
         }
+
     ]
 
 });
diff --git a/test/rules/no-synchronous-tests.js b/test/rules/no-synchronous-tests.js
index a09b001..b7416d7 100644
--- a/test/rules/no-synchronous-tests.js
+++ b/test/rules/no-synchronous-tests.js
@@ -68,6 +68,15 @@ ruleTester.run('no-synchronous-tests', rules['no-synchronous-tests'], {
             code: 'it("", () => "not-a-promise" );',
             parserOptions: { ecmaVersion: 6 },
             errors: [ { message: 'Unexpected synchronous test.', column: 8, line: 1 } ]
+        },
+        {
+            code: 'specify("", function () {});',
+            errors: [ { message: 'Unexpected synchronous test.', column: 13, line: 1 } ]
+        },
+        {
+            code: 'specify.only("", function () {});',
+            errors: [ { message: 'Unexpected synchronous test.', column: 18, line: 1 } ]
         }
+
     ]
 });