Skip to content

Commit

Permalink
feat/update-tests (#488)
Browse files Browse the repository at this point in the history
* feat: init

* chore: updated recommended

* chore: update

* chore(update): improve parser options

* update

* update

* update

* update

* feat(tests): improve tests
  • Loading branch information
veritem authored Aug 5, 2024
1 parent d4f2ff5 commit 268df79
Show file tree
Hide file tree
Showing 89 changed files with 292 additions and 250 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion src/rules/consistent-test-filename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default createEslintRule<
meta: {
type: 'problem',
docs: {
recommended: 'strict',
recommended: false,
requiresTypeChecking: false,
description: 'require .spec test file pattern'
},
Expand Down
2 changes: 1 addition & 1 deletion src/rules/consistent-test-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default createEslintRule<
fixable: 'code',
docs: {
description: 'enforce using test or it but not both',
recommended: 'strict'
recommended: false
},
messages: {
consistentMethod:
Expand Down
2 changes: 1 addition & 1 deletion src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
type: 'suggestion',
docs: {
description: 'enforce having expectation in test body',
recommended: 'strict'
recommended: false
},
schema: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/rules/max-expects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
meta: {
docs: {
requiresTypeChecking: false,
recommended: 'strict',
recommended: false,
description: 'enforce a maximum number of expect per test'
},
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/max-nested-describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
docs: {
description:
'require describe block to be less than set max value or default value',
recommended: 'strict'
recommended: false
},
schema: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-alias-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
docs: {
description: 'disallow alias methods',
requiresTypeChecking: false,
recommended: 'strict'
recommended: false
},
messages: {
noAliasMethods: 'Replace {{ alias }}() with its canonical name {{ canonical }}()'
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-commented-out-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
docs: {
description: 'disallow commented out tests',
requiresTypeChecking: false,
recommended: 'strict'
recommended: false
},
messages: {
noCommentedOutTests: 'Remove commented out tests. You may want to use `skip` or `only` instead.'
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-conditional-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
docs: {
description: 'disallow conditional expects',
requiresTypeChecking: false,
recommended: 'strict'
recommended: false
},
messages: {
noConditionalExpect: 'Avoid calling `expect` inside conditional statements'
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-conditional-in-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
docs: {
description: 'disallow conditional tests',
requiresTypeChecking: false,
recommended: 'strict'
recommended: false
},
messages: {
noConditionalInTest: 'Remove conditional tests'
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-conditional-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default createEslintRule<[], MESSAGE_ID>({
type: 'problem',
docs: {
description: 'disallow conditional tests',
recommended: 'strict'
recommended: false
},
schema: [],
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-disabled-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
type: 'suggestion',
docs: {
description: 'disallow disabled tests',
recommended: 'strict'
recommended: false
},
messages: {
missingFunction: 'Test is missing function argument',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-done-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default createEslintRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'disallow using a callback in asynchronous tests and hooks',
recommended: 'strict'
recommended: false
},
deprecated: true,
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-duplicate-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
name: RULE_NAME,
meta: {
docs: {
recommended: 'strict',
recommended: false,
description: 'disallow duplicate hooks and teardown hooks',
requiresTypeChecking: false
},
Expand Down
7 changes: 2 additions & 5 deletions src/rules/no-focused-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default createEslintRule<Options, MessageIds>({
type: 'problem',
docs: {
description: 'disallow focused tests',
recommended: 'strict'
recommended: false
},
fixable: 'code',
schema: [
Expand All @@ -44,10 +44,7 @@ export default createEslintRule<Options, MessageIds>({
},
defaultOptions: [{ fixable: true }],
create: (context) => {
const config = context.options[0] ?? {
fixable: true
}
const fixable = config.fixable
const fixable = context.options[0]?.fixable

return {
ExpressionStatement(node) {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default createEslintRule<
type: 'suggestion',
docs: {
description: 'disallow setup and teardown hooks',
recommended: 'strict'
recommended: false
},
schema: [{
type: 'object',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-identical-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
type: 'problem',
docs: {
description: 'disallow identical titles',
recommended: 'strict'
recommended: false
},
fixable: 'code',
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-import-node-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
meta: {
docs: {
description: 'disallow importing `node:test`',
recommended: 'strict'
recommended: false
},
type: 'suggestion',
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-interpolation-in-snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
type: 'problem',
docs: {
description: 'disallow string interpolation in snapshots',
recommended: 'strict'
recommended: false
},
fixable: 'code',
schema: [],
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-large-snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default createEslintRule<[RuleOptions], MESSAGE_IDS>({
meta: {
docs: {
description: 'disallow large snapshots',
recommended: 'strict'
recommended: false
},
messages: {
noSnapShot: '`{{ lineCount }}`s should begin with lowercase',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-mocks-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
type: 'problem',
docs: {
description: 'disallow importing from __mocks__ directory',
recommended: 'strict'
recommended: false
},
messages: {
noMocksImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`jest.mock\` and import from the original module path.`
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-restricted-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
meta: {
docs: {
description: 'disallow the use of certain matchers',
recommended: 'strict'
recommended: false
},
type: 'suggestion',
schema: [
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-restricted-vi-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
type: 'suggestion',
docs: {
description: 'disallow specific `vi.` methods',
recommended: 'strict'
recommended: false
},
schema: [{
type: 'object',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-standalone-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
meta: {
docs: {
description: 'disallow using `expect` outside of `it` or `test` blocks',
recommended: 'strict'
recommended: false
},
type: 'suggestion',
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-test-prefixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
meta: {
docs: {
description: 'disallow using `test` as a prefix',
recommended: 'strict'
recommended: false
},
type: 'suggestion',
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-test-return-statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default createEslintRule<Options, MessageIds>({
type: 'problem',
docs: {
description: 'disallow return statements in tests',
recommended: 'strict'
recommended: false
},
schema: [],
messages: {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/padding-around-after-all-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFilename } from "src/utils/msc"
import { Config, PaddingType, StatementType, createPaddingRule } from "../utils/padding"
import { URL } from "node:url"

export const RULE_NAME = new URL('', import.meta.url).pathname
export const RULE_NAME = getFilename(import.meta.url)

export const config: Config[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/rules/padding-around-after-each-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Config, PaddingType, StatementType, createPaddingRule } from "../utils/padding";
import { get_filename } from "../utils/msc";
import { getFilename } from "../utils/msc";

export const RULE_NAME = get_filename(import.meta.url)
export const RULE_NAME = getFilename(import.meta.url)

export const config: Config[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/rules/padding-around-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { config as paddingAroundDescribeBlocksConfig } from './padding-around-de
import { config as paddingAroundExpectGroupsConfig } from './padding-around-expect-groups';
import { config as paddingAroundTestBlocksConfig } from './padding-around-test-blocks';
import { createPaddingRule } from '../utils/padding';
import { get_filename } from '../utils/msc';
import { getFilename } from '../utils/msc';

export const RULE_NAME = get_filename(import.meta.url)
export const RULE_NAME = getFilename(import.meta.url)

export default createPaddingRule(
RULE_NAME,
Expand Down
4 changes: 2 additions & 2 deletions src/rules/padding-around-before-all-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get_filename } from "../utils/msc";
import { getFilename } from "../utils/msc";
import { Config, PaddingType, StatementType, createPaddingRule } from "../utils/padding";

export const RULE_NAME = get_filename(import.meta.url)
export const RULE_NAME = getFilename(import.meta.url)

export const config: Config[] = [
{
Expand Down
5 changes: 2 additions & 3 deletions src/rules/padding-around-before-each-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import { get_filename } from '../utils/msc';
import { getFilename } from '../utils/msc';
import { PaddingType, StatementType, createPaddingRule } from '../utils/padding';

export const RULE_NAME = get_filename(import.meta.url)
export const RULE_NAME = getFilename(import.meta.url)

export const config = [
{
Expand Down
5 changes: 2 additions & 3 deletions src/rules/padding-around-describe-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import { get_filename } from '../utils/msc';
import { getFilename } from '../utils/msc';
import { Config, PaddingType, StatementType, createPaddingRule } from '../utils/padding';

export const RULE_NAME = get_filename(import.meta.url)
export const RULE_NAME = getFilename(import.meta.url)

export const config: Config[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/rules/padding-around-expect-groups.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get_filename } from "../utils/msc";
import { getFilename } from "../utils/msc";
import { Config, PaddingType, StatementType, createPaddingRule } from "../utils/padding";

export const RULE_NAME = get_filename(import.meta.url)
export const RULE_NAME = getFilename(import.meta.url)

export const config: Config[] = [
{
Expand Down
5 changes: 2 additions & 3 deletions src/rules/padding-around-test-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import { get_filename } from '../utils/msc';
import { getFilename } from '../utils/msc';
import { PaddingType, StatementType, createPaddingRule } from '../utils/padding';

export const RULE_NAME = get_filename(import.meta.url)
export const RULE_NAME = getFilename(import.meta.url)

export const config = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-called-with.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
docs: {
description:
'enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()`',
recommended: 'strict'
recommended: false
},
messages: {
preferCalledWith: 'Prefer {{ matcherName }}With(/* expected args */)'
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-comparison-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
type: 'suggestion',
docs: {
description: 'enforce using the built-in comparison matchers',
recommended: 'strict'
recommended: false
},
schema: [],
fixable: 'code',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createEslintRule({
type: 'suggestion',
docs: {
description: 'enforce using `each` rather than manual loops',
recommended: 'strict'
recommended: false
},
schema: [],
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-equality-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
type: 'suggestion',
docs: {
description: 'enforce using the built-in quality matchers',
recommended: 'strict'
recommended: false
},
messages: {
useEqualityMatcher: 'Prefer using one of the equality matchers instead',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-expect-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default createEslintRule<Options[], MessageIds>({
meta: {
docs: {
description: 'enforce using expect assertions instead of callbacks',
recommended: 'strict'
recommended: false
},
messages: {
hasAssertionsTakesNoArguments:
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-expect-resolves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
type: 'suggestion',
docs: {
description: 'enforce using `expect().resolves` over `expect(await ...)` syntax',
recommended: 'strict'
recommended: false
},
fixable: 'code',
messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-hooks-in-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
type: 'suggestion',
docs: {
description: 'enforce having hooks in consistent order',
recommended: 'strict'
recommended: false
},
messages: {
reorderHooks: '`{{ currentHook }}` hooks should be before any `{{ previousHook }}` hooks'
Expand Down
Loading

0 comments on commit 268df79

Please sign in to comment.