From 31cae3bde0c4ac2a59bf43e0f74c79e3f0129ded Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Wed, 1 Jan 2025 09:51:07 +1300 Subject: [PATCH] fix: make rule message punctuation more consistent and address some typos (#628) --- src/rules/consistent-test-filename.ts | 2 +- src/rules/max-expects.ts | 2 +- src/rules/max-nested-describe.ts | 2 +- src/rules/no-commented-out-tests.ts | 2 +- src/rules/no-conditional-tests.ts | 2 +- src/rules/no-disabled-tests.ts | 4 ++-- src/rules/no-duplicate-hooks.ts | 2 +- src/rules/no-focused-tests.ts | 2 +- src/rules/no-mocks-import.ts | 2 +- src/rules/no-test-prefixes.ts | 2 +- src/rules/prefer-to-be-object.ts | 2 +- src/rules/require-top-level-describe.ts | 4 ++-- src/rules/valid-expect.ts | 14 +++++++------- src/rules/valid-title.ts | 12 ++++++------ 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/rules/consistent-test-filename.ts b/src/rules/consistent-test-filename.ts index 07e30e1..ef83855 100644 --- a/src/rules/consistent-test-filename.ts +++ b/src/rules/consistent-test-filename.ts @@ -24,7 +24,7 @@ export default createEslintRule< description: 'require .spec test file pattern' }, messages: { - consistentTestFilename: 'use test file name pattern {{pattern}}' + consistentTestFilename: 'Use test file name pattern {{ pattern }}' }, schema: [ { diff --git a/src/rules/max-expects.ts b/src/rules/max-expects.ts index d088556..b4ce42f 100644 --- a/src/rules/max-expects.ts +++ b/src/rules/max-expects.ts @@ -19,7 +19,7 @@ export default createEslintRule({ description: 'enforce a maximum number of expect per test' }, messages: { - maxExpect: 'Too many assertion calls ({{count}}). Maximum is {{max}}.' + maxExpect: 'Too many assertion calls ({{ count }}) - maximum allowed is {{ max }}' }, type: 'suggestion', schema: [ diff --git a/src/rules/max-nested-describe.ts b/src/rules/max-nested-describe.ts index e5432de..b77d953 100644 --- a/src/rules/max-nested-describe.ts +++ b/src/rules/max-nested-describe.ts @@ -31,7 +31,7 @@ export default createEslintRule({ ], messages: { maxNestedDescribe: - 'Nested describe block should be less than set max value.' + 'Nested describe block should be less than set max value' } }, defaultOptions: [ diff --git a/src/rules/no-commented-out-tests.ts b/src/rules/no-commented-out-tests.ts index 0e644c8..15bf958 100644 --- a/src/rules/no-commented-out-tests.ts +++ b/src/rules/no-commented-out-tests.ts @@ -18,7 +18,7 @@ export default createEslintRule({ recommended: false }, messages: { - noCommentedOutTests: 'Remove commented out tests. You may want to use `skip` or `only` instead.' + noCommentedOutTests: 'Remove commented out tests - you may want to use `skip` or `only` instead' }, schema: [], type: 'suggestion' diff --git a/src/rules/no-conditional-tests.ts b/src/rules/no-conditional-tests.ts index e4f06f2..27bda68 100644 --- a/src/rules/no-conditional-tests.ts +++ b/src/rules/no-conditional-tests.ts @@ -14,7 +14,7 @@ export default createEslintRule<[], MESSAGE_ID>({ }, schema: [], messages: { - noConditionalTests: 'Avoid using if conditions in a test.' + noConditionalTests: 'Avoid using if conditions in a test' } }, defaultOptions: [], diff --git a/src/rules/no-disabled-tests.ts b/src/rules/no-disabled-tests.ts index b5b8016..717bb49 100644 --- a/src/rules/no-disabled-tests.ts +++ b/src/rules/no-disabled-tests.ts @@ -18,8 +18,8 @@ export default createEslintRule({ pending: 'Call to pending()', pendingSuite: 'Call to pending() within test suite', pendingTest: 'Call to pending() within test', - disabledSuite: 'Disabled test suite. If you want to skip a test suite temporarily, use .todo() instead.', - disabledTest: 'Disabled test. If you want to skip a test temporarily, use .todo() instead.' + disabledSuite: 'Disabled test suite - if you want to skip a test suite temporarily, use .todo() instead', + disabledTest: 'Disabled test - if you want to skip a test temporarily, use .todo() instead' }, schema: [] }, diff --git a/src/rules/no-duplicate-hooks.ts b/src/rules/no-duplicate-hooks.ts index a10c64b..91f5a1c 100644 --- a/src/rules/no-duplicate-hooks.ts +++ b/src/rules/no-duplicate-hooks.ts @@ -14,7 +14,7 @@ export default createEslintRule({ requiresTypeChecking: false }, messages: { - noDuplicateHooks: 'Duplicate {{hook}} in describe block.' + noDuplicateHooks: 'Duplicate {{ hook }} in describe block' }, schema: [], type: 'suggestion' diff --git a/src/rules/no-focused-tests.ts b/src/rules/no-focused-tests.ts index c5e5e4a..f4abc48 100644 --- a/src/rules/no-focused-tests.ts +++ b/src/rules/no-focused-tests.ts @@ -39,7 +39,7 @@ export default createEslintRule({ } ], messages: { - noFocusedTests: 'Focused tests are not allowed.' + noFocusedTests: 'Focused tests are not allowed' } }, defaultOptions: [{ fixable: true }], diff --git a/src/rules/no-mocks-import.ts b/src/rules/no-mocks-import.ts index d7793cc..5740bd3 100644 --- a/src/rules/no-mocks-import.ts +++ b/src/rules/no-mocks-import.ts @@ -21,7 +21,7 @@ export default createEslintRule({ recommended: false }, messages: { - noMocksImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`vi.mock\` and import from the original module path.` + noMocksImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`vi.mock\` and import from the original module path` }, schema: [] }, diff --git a/src/rules/no-test-prefixes.ts b/src/rules/no-test-prefixes.ts index 7dcf121..1f2a22e 100644 --- a/src/rules/no-test-prefixes.ts +++ b/src/rules/no-test-prefixes.ts @@ -15,7 +15,7 @@ export default createEslintRule({ }, type: 'suggestion', messages: { - usePreferredName: 'Use "{{preferredNodeName}}" instead' + usePreferredName: 'Use "{{ preferredNodeName }}" instead' }, fixable: 'code', schema: [] diff --git a/src/rules/prefer-to-be-object.ts b/src/rules/prefer-to-be-object.ts index 3e69947..98ec0be 100644 --- a/src/rules/prefer-to-be-object.ts +++ b/src/rules/prefer-to-be-object.ts @@ -17,7 +17,7 @@ export default createEslintRule({ }, fixable: 'code', messages: { - preferToBeObject: 'Prefer toBeObject() to test if a value is an object.' + preferToBeObject: 'Prefer toBeObject() to test if a value is an object' }, schema: [] }, diff --git a/src/rules/require-top-level-describe.ts b/src/rules/require-top-level-describe.ts index 04bfb6e..4236143 100644 --- a/src/rules/require-top-level-describe.ts +++ b/src/rules/require-top-level-describe.ts @@ -20,8 +20,8 @@ export default createEslintRule({ messages: { tooManyDescribes: 'There should not be more than {{ max }} describe{{ s }} at the top level', - unexpectedTestCase: 'All test cases must be wrapped in a describe block.', - unexpectedHook: 'All hooks must be wrapped in a describe block.' + unexpectedTestCase: 'All test cases must be wrapped in a describe block', + unexpectedHook: 'All hooks must be wrapped in a describe block' }, type: 'suggestion', schema: [ diff --git a/src/rules/valid-expect.ts b/src/rules/valid-expect.ts index 4f52065..8e6b907 100644 --- a/src/rules/valid-expect.ts +++ b/src/rules/valid-expect.ts @@ -125,14 +125,14 @@ export default createEslintRule<[ recommended: false }, messages: { - tooManyArgs: 'Expect takes most {{ amount}} argument{{s}}', - notEnoughArgs: 'Expect requires atleast {{ amount }} argument{{s}}', - modifierUnknown: 'Expect has unknown modifier', - matcherNotFound: 'Expect must have a corresponding matcher call.', - matcherNotCalled: 'Matchers must be called to assert.', - asyncMustBeAwaited: 'Async assertions must be awaited{{orReturned}}', + tooManyArgs: 'Expect takes at most {{ amount}} argument{{ s }}', + notEnoughArgs: 'Expect requires at least {{ amount }} argument{{ s }}', + modifierUnknown: 'Expect has an unknown modifier', + matcherNotFound: 'Expect must have a corresponding matcher call', + matcherNotCalled: 'Matchers must be called to assert', + asyncMustBeAwaited: 'Async assertions must be awaited{{ orReturned }}', promisesWithAsyncAssertionsMustBeAwaited: - 'Promises which return async assertions must be awaited{{orReturned}}' + 'Promises which return async assertions must be awaited{{ orReturned }}' }, type: 'suggestion', fixable: 'code', diff --git a/src/rules/valid-title.ts b/src/rules/valid-title.ts index 2930ada..1de0f5b 100644 --- a/src/rules/valid-title.ts +++ b/src/rules/valid-title.ts @@ -128,14 +128,14 @@ export default createEslintRule({ }, messages: { titleMustBeString: 'Test title must be a string, a function or class name', - emptyTitle: '{{functionName}} should not have an empty title', + emptyTitle: '{{ functionName }} should not have an empty title', duplicatePrefix: 'should not have duplicate prefix', accidentalSpace: 'should not have leading or trailing spaces', - disallowedWord: '"{{word}}" is not allowed in test title', - mustNotMatch: '{{functionName}} should not match {{pattern}}', - mustMatch: '{{functionName}} should match {{pattern}}', - mustNotMatchCustom: '{{message}}', - mustMatchCustom: '{{message}}' + disallowedWord: '"{{ word }}" is not allowed in test title', + mustNotMatch: '{{ functionName }} should not match {{ pattern }}', + mustMatch: '{{ functionName }} should match {{ pattern }}', + mustNotMatchCustom: '{{ message }}', + mustMatchCustom: '{{ message }}' }, type: 'suggestion', schema: [