From 2b23aafaa36767c95190d1b2c1f1fd9d612e3c56 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 19 Jul 2019 18:15:23 +1200 Subject: [PATCH 1/3] chore(no-duplicate-hooks): convert to TypeScript --- ...e-hooks.test.js => no-duplicate-hooks.test.ts} | 4 ++-- ...o-duplicate-hooks.js => no-duplicate-hooks.ts} | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) rename src/rules/__tests__/{no-duplicate-hooks.test.js => no-duplicate-hooks.test.ts} (98%) rename src/rules/{no-duplicate-hooks.js => no-duplicate-hooks.ts} (74%) diff --git a/src/rules/__tests__/no-duplicate-hooks.test.js b/src/rules/__tests__/no-duplicate-hooks.test.ts similarity index 98% rename from src/rules/__tests__/no-duplicate-hooks.test.js rename to src/rules/__tests__/no-duplicate-hooks.test.ts index 402ecff7b..ceac3d8b7 100644 --- a/src/rules/__tests__/no-duplicate-hooks.test.js +++ b/src/rules/__tests__/no-duplicate-hooks.test.ts @@ -1,7 +1,7 @@ -import { RuleTester } from 'eslint'; +import { TSESLint } from '@typescript-eslint/experimental-utils'; import rule from '../no-duplicate-hooks'; -const ruleTester = new RuleTester({ +const ruleTester = new TSESLint.RuleTester({ parserOptions: { ecmaVersion: 6, }, diff --git a/src/rules/no-duplicate-hooks.js b/src/rules/no-duplicate-hooks.ts similarity index 74% rename from src/rules/no-duplicate-hooks.js rename to src/rules/no-duplicate-hooks.ts index 9ec7b7383..c02f33c78 100644 --- a/src/rules/no-duplicate-hooks.js +++ b/src/rules/no-duplicate-hooks.ts @@ -1,4 +1,4 @@ -import { getDocsUrl, isDescribe, isHook } from './util'; +import { createRule, isDescribe, isHook } from './tsUtils'; const newHookContext = () => ({ beforeAll: 0, @@ -7,15 +7,22 @@ const newHookContext = () => ({ afterEach: 0, }); -export default { +export default createRule({ + name: __filename, meta: { docs: { - url: getDocsUrl(__filename), + category: 'Best Practices', + description: 'Disallow duplicate setup and teardown hooks', + recommended: false, }, messages: { noDuplicateHook: 'Duplicate {{hook}} in describe block', }, + fixable: 'code', + schema: [], + type: 'suggestion', }, + defaultOptions: [], create(context) { const hookContexts = [newHookContext()]; return { @@ -43,4 +50,4 @@ export default { }, }; }, -}; +}); From 9a13d914a6d82af7fb3d9d87b942c1f4a8d239e1 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 20 Jul 2019 10:05:27 +0200 Subject: [PATCH 2/3] chore: correct meta fixable --- src/rules/no-duplicate-hooks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules/no-duplicate-hooks.ts b/src/rules/no-duplicate-hooks.ts index c02f33c78..b4aba9c61 100644 --- a/src/rules/no-duplicate-hooks.ts +++ b/src/rules/no-duplicate-hooks.ts @@ -18,7 +18,7 @@ export default createRule({ messages: { noDuplicateHook: 'Duplicate {{hook}} in describe block', }, - fixable: 'code', + fixable: false, schema: [], type: 'suggestion', }, From 765dac2a414e7ba798001240c171c9450be1170e Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 20 Jul 2019 10:07:04 +0200 Subject: [PATCH 3/3] chore: _actually_ fix fixable meta --- src/rules/no-duplicate-hooks.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rules/no-duplicate-hooks.ts b/src/rules/no-duplicate-hooks.ts index b4aba9c61..dbfe24afd 100644 --- a/src/rules/no-duplicate-hooks.ts +++ b/src/rules/no-duplicate-hooks.ts @@ -18,7 +18,6 @@ export default createRule({ messages: { noDuplicateHook: 'Duplicate {{hook}} in describe block', }, - fixable: false, schema: [], type: 'suggestion', },