diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 04723ab29..37a00ee6e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,8 +6,8 @@ CONTRIBUTING.md Please fill the following form (leave what's relevant) --> -| Q | A | -| ---------------- | --- | +| Q | A | +| ---------------- | ----- | | Bug fix? | ✔/✖ | | New feature? | ✔/✖ | | Breaking change? | ✔/✖ | @@ -15,6 +15,6 @@ Please fill the following form (leave what's relevant) | Documentation? | ✔/✖ | | Tests added? | ✔/✖ | | Types added? | ✔/✖ | -| Related issues | | +| Related issues | | diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 724eb2d93..8ce9f4638 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -36,6 +36,8 @@ jobs: run: yarn build - name: Test run: yarn test + - name: Format + run: yarn format - name: Lint run: yarn lint - name: Release diff --git a/.prettierignore b/.prettierignore index 04c01ba7b..14b59e1d8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ node_modules/ -dist/ \ No newline at end of file +dist/ +.yarn/ diff --git a/.yarnrc.yml b/.yarnrc.yml index 223104e17..f7d4bcced 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -4,6 +4,6 @@ nodeLinker: node-modules plugins: - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs - spec: "@yarnpkg/plugin-interactive-tools" + spec: '@yarnpkg/plugin-interactive-tools' yarnPath: .yarn/releases/yarn-3.5.1.cjs diff --git a/package.json b/package.json index fc6f355b3..73f05e9b3 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "build": "vx build", "test": "vx test", "release": "vx release", + "format": "prettier -c .", "lint": "eslint . --ignore-path .gitignore", "prepare": "husky install", "dev": "vx dev", @@ -34,6 +35,7 @@ "eslint-plugin-jest": "^27.9.0", "husky": "^8.0.3", "lodash": "^4.17.21", + "prettier": "^3.3.1", "pretty-quick": "^3.3.1", "tsc": "^2.0.4", "tslib": "^2.6.3", diff --git a/packages/anyone/README.md b/packages/anyone/README.md index ea09fde2d..700455667 100644 --- a/packages/anyone/README.md +++ b/packages/anyone/README.md @@ -31,7 +31,7 @@ if (one(var1, var2, var3)) { all( validateInput1, // returns true validateInput2, // returns false - validateInput3 // no need to run this, we already know our validation failed + validateInput3, // no need to run this, we already know our validation failed ); ``` @@ -60,7 +60,7 @@ import all from 'anyone/all'; any( someFunction, // evaluates to false 1, - someVar // truthy + someVar, // truthy ); // true @@ -69,7 +69,7 @@ any( any( someFunction, // evaluates to false 0, - someVar // falsy + someVar, // falsy ); // false @@ -78,7 +78,7 @@ any( one( someFunction, // evaluates to false 0, - someVar // truthy + someVar, // truthy ); // true @@ -87,7 +87,7 @@ one( none( someFunction, // evaluates to false 1, - someVar // truthy + someVar, // truthy ); // false @@ -96,7 +96,7 @@ none( none( someFunction, // evaluates to false 0, - someVar // falsy + someVar, // falsy ); // true @@ -105,7 +105,7 @@ none( all( someFunction, // evaluates to false 0, - someVar // truthy + someVar, // truthy ); // false @@ -114,7 +114,7 @@ all( all( someFunction, // evaluates to true 1, - someVar // truthy + someVar, // truthy ); // true ``` diff --git a/packages/anyone/src/__tests__/all.test.ts b/packages/anyone/src/__tests__/all.test.ts index b8ff286fd..9ada00386 100644 --- a/packages/anyone/src/__tests__/all.test.ts +++ b/packages/anyone/src/__tests__/all.test.ts @@ -10,9 +10,9 @@ describe('methods/all', () => { expect( all( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(false); }); }); @@ -22,9 +22,9 @@ describe('methods/all', () => { expect( all( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(true); }); }); @@ -34,12 +34,12 @@ describe('methods/all', () => { expect( all.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), ), - ]) + ]), ).toBe(false); }); }); diff --git a/packages/anyone/src/__tests__/any.test.ts b/packages/anyone/src/__tests__/any.test.ts index 2a3de7fc2..517766104 100644 --- a/packages/anyone/src/__tests__/any.test.ts +++ b/packages/anyone/src/__tests__/any.test.ts @@ -10,9 +10,9 @@ describe('methods/any', () => { expect( any( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(false); }); }); @@ -22,9 +22,9 @@ describe('methods/any', () => { expect( any( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(true); }); }); @@ -34,10 +34,10 @@ describe('methods/any', () => { expect( any.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), sample(TRUTHY_VALUES), - ]) + ]), ).toBe(true); }); }); @@ -47,12 +47,12 @@ describe('methods/any', () => { expect( any.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), ), - ]) + ]), ).toBe(true); }); }); diff --git a/packages/anyone/src/__tests__/none.test.ts b/packages/anyone/src/__tests__/none.test.ts index 86aad6105..8140bbdb7 100644 --- a/packages/anyone/src/__tests__/none.test.ts +++ b/packages/anyone/src/__tests__/none.test.ts @@ -10,9 +10,9 @@ describe('methods/none', () => { expect( none( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(true); }); }); @@ -22,9 +22,9 @@ describe('methods/none', () => { expect( none( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(false); }); }); @@ -34,10 +34,10 @@ describe('methods/none', () => { expect( none.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), sample(TRUTHY_VALUES), - ]) + ]), ).toBe(false); }); }); @@ -47,12 +47,12 @@ describe('methods/none', () => { expect( none.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), ), - ]) + ]), ).toBe(false); }); }); diff --git a/packages/anyone/src/__tests__/one.test.ts b/packages/anyone/src/__tests__/one.test.ts index a8367619c..245701668 100644 --- a/packages/anyone/src/__tests__/one.test.ts +++ b/packages/anyone/src/__tests__/one.test.ts @@ -10,9 +10,9 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(false); }); }); @@ -22,9 +22,9 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(2, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(false); }); }); @@ -34,10 +34,10 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), - sample(TRUTHY_VALUES) - ) + sample(TRUTHY_VALUES), + ), ).toBe(true); }); }); @@ -47,8 +47,8 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(2, 10) }, () => sample(TRUTHY_VALUES)), - ...Array.from({ length: random(1, 10) }, () => sample(FALSY_VALUES)) - ) + ...Array.from({ length: random(1, 10) }, () => sample(FALSY_VALUES)), + ), ).toBe(false); }); }); diff --git a/packages/anyone/src/__tests__/runAnyoneMethods.test.ts b/packages/anyone/src/__tests__/runAnyoneMethods.test.ts index c255744b7..bd10b458d 100644 --- a/packages/anyone/src/__tests__/runAnyoneMethods.test.ts +++ b/packages/anyone/src/__tests__/runAnyoneMethods.test.ts @@ -5,26 +5,26 @@ import run from 'runAnyoneMethods'; describe('lib/run', () => { describe('When value is falsy', () => { it.each([FALSY_VALUES])('Should return `false` ("%s")', value => - expect(run(value)).toBe(false) + expect(run(value)).toBe(false), ); }); describe('When value is truthy', () => { it.each([TRUTHY_VALUES])('Should return `true` ("%s")', value => - expect(run(value)).toBe(true) + expect(run(value)).toBe(true), ); }); describe('When value is a function', () => { describe('When value is falsy', () => { it.each([FALSY_VALUES])('Should return `false` ("%s")', value => - expect(run(() => value)).toBe(false) + expect(run(() => value)).toBe(false), ); }); describe('When value is truthy', () => { it.each([TRUTHY_VALUES])('Should return `true` ("%s")', value => - expect(run(() => value)).toBe(true) + expect(run(() => value)).toBe(true), ); }); }); @@ -34,7 +34,7 @@ describe('lib/run', () => { expect( run(() => { throw new Error(); - }) + }), ).toBe(false); }); }); diff --git a/packages/context/README.md b/packages/context/README.md index 0c61f2ba4..b5b9f59f7 100644 --- a/packages/context/README.md +++ b/packages/context/README.md @@ -146,7 +146,7 @@ import ctx from './ctx'; function handleCart() { const context = ctx.useX( - 'handleCart was called outside of a running context' + 'handleCart was called outside of a running context', ); // { cart: { items: [ 'foo', 'bar' ] } } // This throws an error if we're not within a `run` call. // You should catch this error and handle it somewhere above this function. diff --git a/packages/context/src/__tests__/cascade.test.ts b/packages/context/src/__tests__/cascade.test.ts index bbf756e40..663f83253 100644 --- a/packages/context/src/__tests__/cascade.test.ts +++ b/packages/context/src/__tests__/cascade.test.ts @@ -40,7 +40,7 @@ describe('Cascading Context', () => { () => { expect(ctx.use().id).toBe(55); expect(ctx.use().user).toBe('boomsa'); - } + }, ); }); @@ -52,7 +52,7 @@ describe('Cascading Context', () => { () => { expect(ctx.use().id).toBe(55); expect(ctx.use().user).toBeUndefined(); - } + }, ); }); @@ -93,9 +93,9 @@ describe('Cascading Context', () => { expect(ctx.use().name).toBe('Emanuelle'); expect(ctx.use().color).toBe('blue'); }); - } + }, ); - } + }, ); }); @@ -123,7 +123,7 @@ describe('Cascading Context', () => { "name": "Emanuelle", } `); - } + }, ); expect(ctx.use().id).toBe(99); expect(ctx.use().name).toBe('watermelonbunny'); @@ -133,7 +133,7 @@ describe('Cascading Context', () => { "name": "watermelonbunny", } `); - } + }, ); }); }); @@ -244,7 +244,7 @@ describe('Cascading Context', () => { it('Should allow a custom context message', () => { expect(() => ctx.useX('Custom Failure Message')).toThrow( - 'Custom Failure Message' + 'Custom Failure Message', ); }); }); @@ -260,7 +260,7 @@ describe('Cascading Context', () => { it('Should allow a custom context message', () => { expect(() => ctx.useX('Custom Failure Message')).toThrow( - 'Custom Failure Message' + 'Custom Failure Message', ); }); }); diff --git a/packages/context/src/context.ts b/packages/context/src/context.ts index a51d841e2..973157258 100644 --- a/packages/context/src/context.ts +++ b/packages/context/src/context.ts @@ -29,7 +29,7 @@ export function createContext(defaultContextValue?: T): CtxApi { function useX(errorMessage?: string): T { invariant( isInsideContext(), - defaultTo(errorMessage, USEX_DEFAULT_ERROR_MESSAGE) + defaultTo(errorMessage, USEX_DEFAULT_ERROR_MESSAGE), ); return contextValue as T; } @@ -55,7 +55,7 @@ export function createContext(defaultContextValue?: T): CtxApi { * When nesting context runs, the the values of the current layer merges with the layers above it. */ export function createCascade>( - init?: (value: Partial, parentContext: Maybe) => Nullable + init?: (value: Partial, parentContext: Maybe) => Nullable, ): CtxCascadeApi { const ctx = createContext(); @@ -72,7 +72,7 @@ export function createCascade>( const out = assign( {}, parentContext ? parentContext : {}, - optionalFunctionValue(init, value, parentContext) ?? value + optionalFunctionValue(init, value, parentContext) ?? value, ) as T; return ctx.run(Object.freeze(out), fn) as R; diff --git a/packages/n4s/src/__tests__/enforce.test.ts b/packages/n4s/src/__tests__/enforce.test.ts index bf2877501..16aaefb0e 100644 --- a/packages/n4s/src/__tests__/enforce.test.ts +++ b/packages/n4s/src/__tests__/enforce.test.ts @@ -45,10 +45,10 @@ describe(`enforce`, () => { it('should throw message string when rule fails', () => { expect(() => enforce(':(').startsWithUnderscore()).toThrow( - ':( does not start with underscore' + ':( does not start with underscore', ); expect(() => - enforce(':(').isString().startsWithUnderscore().isNumber() + enforce(':(').isString().startsWithUnderscore().isNumber(), ).toThrow(':( does not start with underscore'); }); }); @@ -76,7 +76,7 @@ describe(`enforce`, () => { expect(enforce.isArray().run([])).toEqual(ruleReturn.passing()); expect(enforce.greaterThan(5).run(6)).toEqual(ruleReturn.passing()); expect(enforce.greaterThan(5).lessThan(7).run(6)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); }); @@ -85,7 +85,7 @@ describe(`enforce`, () => { expect(enforce.isArray().run({})).toEqual(ruleReturn.failing()); expect(enforce.greaterThan(6).run(5)).toEqual(ruleReturn.failing()); expect(enforce.greaterThan(7).lessThan(5).run(6)).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); }); }); @@ -105,14 +105,14 @@ describe(`enforce`, () => { it('Should return true when valid', () => { expect(enforce.isEmail().test('example@gmail.com')).toBe(true); expect(enforce.isEmail().isString().test('example@gmail.com')).toBe( - true + true, ); }); it('Should return false when invalid', () => { expect(enforce.isEmail().test('example!gmail.com')).toBe(false); expect(enforce.isEmail().isString().test('example!gmail.com')).toBe( - false + false, ); }); }); diff --git a/packages/n4s/src/exports/__tests__/compose.test.ts b/packages/n4s/src/exports/__tests__/compose.test.ts index 5abe6d821..c949b5973 100644 --- a/packages/n4s/src/exports/__tests__/compose.test.ts +++ b/packages/n4s/src/exports/__tests__/compose.test.ts @@ -19,17 +19,17 @@ describe('compose', () => { enforce.isNumeric(), enforce.isString(), enforce.greaterThan(3), - enforce.lessThan(5) + enforce.lessThan(5), ); expect(NumericStringBetweenThreeAndFive.run('4')).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect(NumericStringBetweenThreeAndFive.run('3')).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect(NumericStringBetweenThreeAndFive.run(5)).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect(NumericStringBetweenThreeAndFive.test('4')).toBe(true); expect(NumericStringBetweenThreeAndFive.test('3')).toBe(false); @@ -42,7 +42,7 @@ describe('compose', () => { first: enforce.isString().isNotEmpty(), last: enforce.isString().isNotEmpty(), middle: enforce.optional(enforce.isString().isNotEmpty()), - }) + }), ); expect( @@ -55,7 +55,7 @@ describe('compose', () => { first: 'John', last: 'Doe', }, - }) + }), ).toEqual(ruleReturn.passing()); expect( @@ -69,7 +69,7 @@ describe('compose', () => { last: 'Doe', middle: '', }, - }) + }), ).toEqual(ruleReturn.failing()); }); it('Should allow composing compositions', () => { @@ -80,13 +80,13 @@ describe('compose', () => { last: enforce.isString().isNotEmpty(), middle: enforce.optional(enforce.isString().isNotEmpty()), }), - }) + }), ); const Entity = compose( enforce.loose({ id: enforce.isNumeric(), - }) + }), ); const User = compose(Name, Entity); @@ -99,7 +99,7 @@ describe('compose', () => { middle: 'M', last: 'Doe', }, - }) + }), ).toEqual(ruleReturn.passing()); User({ id: '1', @@ -117,7 +117,7 @@ describe('compose', () => { name: { first: 'John', }, - }) + }), ).toEqual(ruleReturn.failing()); expect(() => @@ -126,7 +126,7 @@ describe('compose', () => { first: 'John', }, id: '__', - }) + }), ).toThrow(); }); }); diff --git a/packages/n4s/src/exports/__tests__/date.test.ts b/packages/n4s/src/exports/__tests__/date.test.ts index 4c36f3252..5e221a30a 100644 --- a/packages/n4s/src/exports/__tests__/date.test.ts +++ b/packages/n4s/src/exports/__tests__/date.test.ts @@ -42,34 +42,34 @@ describe('date', () => { */ it('Should pass for valid dates', () => { expect(() => - enforce('2002-07-15').isDate({ format: 'YYYY-MM-DD' }) + enforce('2002-07-15').isDate({ format: 'YYYY-MM-DD' }), ).not.toThrow(); expect(() => - enforce('2002/07/15').isDate({ format: 'YYYY/MM/DD' }) + enforce('2002/07/15').isDate({ format: 'YYYY/MM/DD' }), ).not.toThrow(); expect(() => - enforce('07/15/2002').isDate({ format: 'MM/DD/YYYY' }) + enforce('07/15/2002').isDate({ format: 'MM/DD/YYYY' }), ).not.toThrow(); expect(() => - enforce('07-15-2002').isDate({ format: 'MM-DD-YYYY' }) + enforce('07-15-2002').isDate({ format: 'MM-DD-YYYY' }), ).not.toThrow(); expect(() => - enforce('15/07/2002').isDate({ format: 'DD/MM/YYYY' }) + enforce('15/07/2002').isDate({ format: 'DD/MM/YYYY' }), ).not.toThrow(); expect(() => - enforce('15-07-2002').isDate({ format: 'DD-MM-YYYY' }) + enforce('15-07-2002').isDate({ format: 'DD-MM-YYYY' }), ).not.toThrow(); expect(() => - enforce('02-07-15').isDate({ format: 'YY-MM-DD' }) + enforce('02-07-15').isDate({ format: 'YY-MM-DD' }), ).not.toThrow(); expect(() => - enforce('02/07/15').isDate({ format: 'YY/MM/DD' }) + enforce('02/07/15').isDate({ format: 'YY/MM/DD' }), ).not.toThrow(); expect(() => - enforce('07/15/02').isDate({ format: 'MM/DD/YY' }) + enforce('07/15/02').isDate({ format: 'MM/DD/YY' }), ).not.toThrow(); expect(() => - enforce('07-15-02').isDate({ format: 'MM-DD-YY' }) + enforce('07-15-02').isDate({ format: 'MM-DD-YY' }), ).not.toThrow(); }); @@ -77,7 +77,7 @@ describe('date', () => { expect(() => enforce('2002-07-15').isDate({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZ', - }) + }), ).toThrow(); }); }); @@ -87,7 +87,7 @@ describe('date', () => { enforce('2002-07-15').isDate({ strictMode: true, format: 'YYYY-MM-DD', - }) + }), ).not.toThrow(); }); @@ -96,7 +96,7 @@ describe('date', () => { enforce('2002-07-15').isDate({ strictMode: true, format: 'YYYY/MM/DD', - }) + }), ).toThrow(); }); }); @@ -157,19 +157,19 @@ describe('date', () => { it('Should pass for valid ISO8601 dates', () => { expect(() => - enforce('2020-07-10 15:00:00.000').isISO8601() + enforce('2020-07-10 15:00:00.000').isISO8601(), ).not.toThrow(); expect(() => enforce('2020-07-10').isISO8601()).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00.000').isISO8601() + enforce('2020-07-10T15:00:00.000').isISO8601(), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00Z').isISO8601()).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00+05:00').isISO8601() + enforce('2020-07-10T15:00:00+05:00').isISO8601(), ).not.toThrow(); }); @@ -182,23 +182,23 @@ describe('date', () => { describe('strict', () => { it('Should pass for valid ISO8601 dates', () => { expect(() => - enforce('2020-07-10 15:00:00.000').isISO8601({ strict: true }) + enforce('2020-07-10 15:00:00.000').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10').isISO8601({ strict: true }) + enforce('2020-07-10').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00.000').isISO8601({ strict: true }) + enforce('2020-07-10T15:00:00.000').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00Z').isISO8601({ strict: true }) + enforce('2020-07-10T15:00:00Z').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00+05:00').isISO8601({ strict: true }) + enforce('2020-07-10T15:00:00+05:00').isISO8601({ strict: true }), ).not.toThrow(); }); @@ -206,7 +206,7 @@ describe('date', () => { expect(() => enforce(0).isISO8601({ strict: true })).toThrow(); expect(() => enforce(new Date()).isISO8601({ strict: true })).toThrow(); expect(() => - enforce('2020/07/10T15:00:00.000Z').isISO8601({ strict: true }) + enforce('2020/07/10T15:00:00.000Z').isISO8601({ strict: true }), ).toThrow(); }); }); @@ -216,29 +216,29 @@ describe('date', () => { expect(() => enforce('2002-07-15T00:00:00.000Z').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); expect(() => - enforce('2020-07-10').isISO8601({ strictSeparator: true }) + enforce('2020-07-10').isISO8601({ strictSeparator: true }), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00.000').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00Z').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00+05:00').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); }); @@ -246,7 +246,7 @@ describe('date', () => { expect(() => enforce('2020/07/10T15:00:00.000Z').isISO8601({ strictSeparator: true, - }) + }), ).toThrow(); }); }); diff --git a/packages/n4s/src/exports/__tests__/email.test.ts b/packages/n4s/src/exports/__tests__/email.test.ts index 3c4ff19dc..370e7fbec 100644 --- a/packages/n4s/src/exports/__tests__/email.test.ts +++ b/packages/n4s/src/exports/__tests__/email.test.ts @@ -8,7 +8,7 @@ describe('isEmail', () => { expect(() => enforce('user@mail.example.com').isEmail()).not.toThrow(); expect(() => enforce('user+tag@mail.example.com').isEmail()).not.toThrow(); expect(() => - enforce('verylongemailaddress1234567890@mail.example.com').isEmail() + enforce('verylongemailaddress1234567890@mail.example.com').isEmail(), ).not.toThrow(); expect(() => enforce('user@example.co').isEmail()).not.toThrow(); expect(() => enforce('user@example.io').isEmail()).not.toThrow(); @@ -30,19 +30,19 @@ describe('isEmail', () => { expect(() => enforce('Display Name ').isEmail({ allow_display_name: true, - }) + }), ).not.toThrow(); expect(() => enforce('Display Name ').isEmail({ allow_display_name: true, require_display_name: true, - }) + }), ).not.toThrow(); expect(() => - enforce('user@192.168.0.1').isEmail({ allow_ip_domain: true }) + enforce('user@192.168.0.1').isEmail({ allow_ip_domain: true }), ).not.toThrow(); expect(() => - enforce('user@example').isEmail({ require_tld: false }) + enforce('user@example').isEmail({ require_tld: false }), ).not.toThrow(); }); @@ -51,10 +51,10 @@ describe('isEmail', () => { enforce('Display Name user@example.com').isEmail({ allow_display_name: true, require_display_name: true, - }) + }), ).toThrow(); expect(() => - enforce('user@192.168.0.1').isEmail({ allow_ip_domain: false }) + enforce('user@192.168.0.1').isEmail({ allow_ip_domain: false }), ).toThrow(); }); }); diff --git a/packages/n4s/src/exports/__tests__/isUrl.test.ts b/packages/n4s/src/exports/__tests__/isUrl.test.ts index 639f0af44..837d14269 100644 --- a/packages/n4s/src/exports/__tests__/isUrl.test.ts +++ b/packages/n4s/src/exports/__tests__/isUrl.test.ts @@ -6,13 +6,23 @@ describe('isURL', () => { expect(() => enforce('http://www.google.com').isURL()).not.toThrow(); expect(() => enforce('https://google.com').isURL()).not.toThrow(); expect(() => enforce('google.com').isURL()).not.toThrow(); - expect(() => enforce('https://www.wikipedia.org/wiki/Main_Page').isURL()).not.toThrow(); + expect(() => + enforce('https://www.wikipedia.org/wiki/Main_Page').isURL(), + ).not.toThrow(); expect(() => enforce('ftp://myserver.net').isURL()).not.toThrow(); - expect(() => enforce('https://www.example.com/query?search=AI').isURL()).not.toThrow(); - expect(() => enforce('https://username:password@hostname.com:8080').isURL()).not.toThrow(); + expect(() => + enforce('https://www.example.com/query?search=AI').isURL(), + ).not.toThrow(); + expect(() => + enforce('https://username:password@hostname.com:8080').isURL(), + ).not.toThrow(); expect(() => enforce('http://233.233.233.233').isURL()).not.toThrow(); - expect(() => enforce('https://www.example.com/foo/?bar=baz&inga=42&quux').isURL()).not.toThrow(); - expect(() => enforce('http://www.example.com/index.html#section1').isURL()).not.toThrow(); + expect(() => + enforce('https://www.example.com/foo/?bar=baz&inga=42&quux').isURL(), + ).not.toThrow(); + expect(() => + enforce('http://www.example.com/index.html#section1').isURL(), + ).not.toThrow(); }); it('Should fail for invalid URLs', () => { @@ -28,24 +38,51 @@ describe('isURL', () => { expect(() => enforce('http://www.goo gle.com').isURL()).toThrow(); expect(() => enforce('://www.google.com').isURL()).toThrow(); expect(() => enforce('http://localhost').isURL()).toThrow(); - expect(() => enforce('www.com').isURL({ require_host: false })).not.toThrow(); - }) + expect(() => + enforce('www.com').isURL({ require_host: false }), + ).not.toThrow(); + }); describe('With options', () => { it('should pass for valid URLs', () => { - expect(() => enforce('myprotocol://customdomain.com').isURL({ protocols: ['myprotocol'] })).not.toThrow(); - expect(() => enforce('http://localhost:8080').isURL({ require_tld: false })).not.toThrow(); - expect(() => enforce('invalid://www.google.com').isURL({ require_valid_protocol: false })).not.toThrow(); - expect(() => enforce('http://my_server.com').isURL({ allow_underscores: true })).not.toThrow(); + expect(() => + enforce('myprotocol://customdomain.com').isURL({ + protocols: ['myprotocol'], + }), + ).not.toThrow(); + expect(() => + enforce('http://localhost:8080').isURL({ require_tld: false }), + ).not.toThrow(); + expect(() => + enforce('invalid://www.google.com').isURL({ + require_valid_protocol: false, + }), + ).not.toThrow(); + expect(() => + enforce('http://my_server.com').isURL({ allow_underscores: true }), + ).not.toThrow(); }); it('should fail for invalid URLs', () => { - expect(() => enforce('myprotocol://customdomain.com').isURL({ protocols: ['http'] })).toThrow(); - expect(() => enforce('http://localhost:8080').isURL({ require_tld: true })).toThrow(); - expect(() => enforce('invalid://www.google.com').isURL({ require_valid_protocol: true })).toThrow(); - expect(() => enforce('http://my_server.com').isURL({ allow_underscores: false })).toThrow(); - expect(() => enforce('http://www.example.com/index.html#section1').isURL({ allow_fragments: false })).toThrow(); + expect(() => + enforce('myprotocol://customdomain.com').isURL({ protocols: ['http'] }), + ).toThrow(); + expect(() => + enforce('http://localhost:8080').isURL({ require_tld: true }), + ).toThrow(); + expect(() => + enforce('invalid://www.google.com').isURL({ + require_valid_protocol: true, + }), + ).toThrow(); + expect(() => + enforce('http://my_server.com').isURL({ allow_underscores: false }), + ).toThrow(); + expect(() => + enforce('http://www.example.com/index.html#section1').isURL({ + allow_fragments: false, + }), + ).toThrow(); }); }); - -}); \ No newline at end of file +}); diff --git a/packages/n4s/src/exports/compose.ts b/packages/n4s/src/exports/compose.ts index b608080f5..44762f04a 100644 --- a/packages/n4s/src/exports/compose.ts +++ b/packages/n4s/src/exports/compose.ts @@ -19,7 +19,7 @@ export default function compose( { run, test: (value: any) => run(value).pass, - } + }, ); function run(value: any): RuleDetailedResult { @@ -29,7 +29,7 @@ export default function compose( composites, ( composite: LazyRuleRunners, - breakout: (conditional: boolean, res: RuleDetailedResult) => void + breakout: (conditional: boolean, res: RuleDetailedResult) => void, ) => { /* HACK: Just a small white lie. ~~HELP WANTED~~. The ideal is that instead of `LazyRuleRunners` We would simply use `Lazy` to begin with. @@ -40,8 +40,8 @@ export default function compose( const res = runLazyRule(composite, value); breakout(!res.pass, res); - } - ) + }, + ), ); }); } diff --git a/packages/n4s/src/exports/schema.ts b/packages/n4s/src/exports/schema.ts index 2a026d8a7..1f6d315c8 100644 --- a/packages/n4s/src/exports/schema.ts +++ b/packages/n4s/src/exports/schema.ts @@ -1,6 +1,5 @@ import { enforce } from 'n4s'; - import { EnforceCustomMatcher } from 'enforceUtilityTypes'; import { isArrayOf } from 'isArrayOf'; import { loose } from 'loose'; diff --git a/packages/n4s/src/lib/ruleReturn.ts b/packages/n4s/src/lib/ruleReturn.ts index fef7075ce..5b30d61bc 100644 --- a/packages/n4s/src/lib/ruleReturn.ts +++ b/packages/n4s/src/lib/ruleReturn.ts @@ -3,7 +3,7 @@ import { defaultTo } from 'vest-utils'; export default function ruleReturn( pass: boolean, - message?: string + message?: string, ): RuleDetailedResult { const output: RuleDetailedResult = { pass }; @@ -23,13 +23,13 @@ export function passing(): RuleDetailedResult { } export function defaultToFailing( - callback: (...args: any[]) => RuleDetailedResult + callback: (...args: any[]) => RuleDetailedResult, ): RuleDetailedResult { return defaultTo(callback, failing()); } export function defaultToPassing( - callback: (...args: any[]) => RuleDetailedResult + callback: (...args: any[]) => RuleDetailedResult, ): RuleDetailedResult { return defaultTo(callback, passing()); } diff --git a/packages/n4s/src/lib/runLazyRule.ts b/packages/n4s/src/lib/runLazyRule.ts index d53fde05b..2e9e49a7f 100644 --- a/packages/n4s/src/lib/runLazyRule.ts +++ b/packages/n4s/src/lib/runLazyRule.ts @@ -4,7 +4,7 @@ import * as ruleReturn from 'ruleReturn'; export default function runLazyRule( lazyRule: LazyRuleRunners, - currentValue: any + currentValue: any, ): RuleDetailedResult { try { return lazyRule.run(currentValue); diff --git a/packages/n4s/src/lib/transformResult.ts b/packages/n4s/src/lib/transformResult.ts index 1627f07b6..e8542a0a9 100644 --- a/packages/n4s/src/lib/transformResult.ts +++ b/packages/n4s/src/lib/transformResult.ts @@ -20,7 +20,7 @@ export function transformResult( } return ruleReturn( result.pass, - optionalFunctionValue(result.message, ruleName, value, ...args) + optionalFunctionValue(result.message, ruleName, value, ...args), ); } @@ -28,6 +28,6 @@ function validateResult(result: RuleReturn): void { // if result is boolean, or if result.pass is boolean invariant( isBoolean(result) || (result && isBoolean(result.pass)), - 'Incorrect return value for rule: ' + JSON.stringify(result) + 'Incorrect return value for rule: ' + JSON.stringify(result), ); } diff --git a/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts index 58edc636f..a7e29fc22 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts @@ -7,7 +7,9 @@ describe('allOf', () => { describe('When all rules are satisfied', () => { it('Should return a passing result', () => { expect( - enforce.allOf(enforce.isArray(), enforce.longerThan(2)).run([1, 2, 3]) + enforce + .allOf(enforce.isArray(), enforce.longerThan(2)) + .run([1, 2, 3]), ).toEqual(ruleReturn.passing()); }); }); diff --git a/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts index 1de8a0fb1..26774029f 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts @@ -7,7 +7,7 @@ describe('noneOf', () => { describe('When none of the rules are satisfied', () => { it('Should return a passing result', () => { expect( - enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run('x') + enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run('x'), ).toEqual(ruleReturn.passing()); }); }); @@ -15,7 +15,7 @@ describe('noneOf', () => { describe('When some of the rules are satisfied', () => { it('Should return a failing result', () => { expect( - enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2]) + enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2]), ).toEqual(ruleReturn.failing()); }); }); @@ -23,7 +23,7 @@ describe('noneOf', () => { describe('When all of the rules are satisfied', () => { it('Should return a failing result', () => { expect( - enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2, 3]) + enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2, 3]), ).toEqual(ruleReturn.failing()); }); }); diff --git a/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts index 980639937..084f1f3d3 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts @@ -7,7 +7,7 @@ import 'compounds'; describe('enforce.oneOf', () => { it('Should fail when multiple enforcements are met', () => { expect( - enforce.oneOf(enforce.isNumber(), enforce.greaterThan(2)).run(3) + enforce.oneOf(enforce.isNumber(), enforce.greaterThan(2)).run(3), ).toEqual(ruleReturn.failing()); }); @@ -18,7 +18,7 @@ describe('enforce.oneOf', () => { first: 'John', last: 'Doe', }, - }) + }), ).toEqual(ruleReturn.passing()); expect(User.run({ id: 11 })).toEqual(ruleReturn.passing()); }); diff --git a/packages/n4s/src/plugins/compounds/allOf.ts b/packages/n4s/src/plugins/compounds/allOf.ts index a56c006b4..2d03b49be 100644 --- a/packages/n4s/src/plugins/compounds/allOf.ts +++ b/packages/n4s/src/plugins/compounds/allOf.ts @@ -10,6 +10,6 @@ export function allOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { mapFirst(rules, (rule, breakout) => { const res = runLazyRule(rule, value); breakout(!res.pass, res); - }) + }), ); } diff --git a/packages/n4s/src/plugins/compounds/anyOf.ts b/packages/n4s/src/plugins/compounds/anyOf.ts index 24c8ea037..e29e72681 100644 --- a/packages/n4s/src/plugins/compounds/anyOf.ts +++ b/packages/n4s/src/plugins/compounds/anyOf.ts @@ -10,6 +10,6 @@ export function anyOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { mapFirst(rules, (rule, breakout) => { const res = runLazyRule(rule, value); breakout(res.pass, res); - }) + }), ); } diff --git a/packages/n4s/src/plugins/compounds/noneOf.ts b/packages/n4s/src/plugins/compounds/noneOf.ts index fc2fc05b2..0e59ef617 100644 --- a/packages/n4s/src/plugins/compounds/noneOf.ts +++ b/packages/n4s/src/plugins/compounds/noneOf.ts @@ -11,6 +11,6 @@ export function noneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { const res = runLazyRule(rule, value); breakout(res.pass, ruleReturn.failing()); - }) + }), ); } diff --git a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts index cbcb99061..bbcade4c1 100644 --- a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts @@ -7,19 +7,19 @@ describe('enforce.isArrayOf', () => { describe('lazy interface', () => { it('Should return a passing return for an empty array', () => { expect(enforce.isArrayOf(enforce.isString()).run([])).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); }); it('Should return a passing return for valid arrays', () => { expect( - enforce.isArrayOf(enforce.isString()).run(['a', 'b', 'c']) + enforce.isArrayOf(enforce.isString()).run(['a', 'b', 'c']), ).toEqual(ruleReturn.passing()); expect( enforce .isArrayOf(enforce.anyOf(enforce.isString(), enforce.isNumber())) - .run([1, 'b', 'c']) + .run([1, 'b', 'c']), ).toEqual(ruleReturn.passing()); expect( @@ -28,24 +28,24 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) + }), ) .run([ { id: 1, username: 'b' }, { id: 2, username: 'c' }, - ]) + ]), ).toEqual(ruleReturn.passing()); }); it('Should return a failing return for invalid arrays', () => { expect(enforce.isArrayOf(enforce.isString()).run([1, 2, 3])).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect( enforce .isArrayOf(enforce.allOf(enforce.isString(), enforce.isNumber())) - .run([1, 2, 3]) + .run([1, 2, 3]), ).toEqual(ruleReturn.failing()); expect( @@ -54,13 +54,13 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) + }), ) .run([ { id: '1', username: 'b' }, { id: '2', username: 'c' }, { id: '3', username: 'd' }, - ]) + ]), ).toEqual(ruleReturn.failing()); }); }); @@ -74,7 +74,7 @@ describe('enforce.isArrayOf', () => { enforce(['a', 'b', 'c']).isArrayOf(enforce.isString()); enforce([1, 'b', 'c']).isArrayOf( - enforce.anyOf(enforce.isString(), enforce.isNumber()) + enforce.anyOf(enforce.isString(), enforce.isNumber()), ); enforce([ @@ -84,7 +84,7 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) + }), ); }); @@ -93,8 +93,8 @@ describe('enforce.isArrayOf', () => { expect(() => enforce([1, 2, 3]).isArrayOf( - enforce.allOf(enforce.isString(), enforce.isNumber()) - ) + enforce.allOf(enforce.isString(), enforce.isNumber()), + ), ).toThrow(); expect(() => @@ -106,8 +106,8 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) - ) + }), + ), ).toThrow(); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/loose.test.ts b/packages/n4s/src/plugins/schema/__tests__/loose.test.ts index 2f1590c83..e94188e39 100644 --- a/packages/n4s/src/plugins/schema/__tests__/loose.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/loose.test.ts @@ -8,7 +8,7 @@ describe('enforce.loose for loose matching', () => { expect( enforce .loose({ username: enforce.isString(), age: enforce.isNumber() }) - .run({ username: 'ealush', age: 31, foo: 'bar' }) + .run({ username: 'ealush', age: 31, foo: 'bar' }), ).toEqual(ruleReturn.passing()); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/optional.test.ts b/packages/n4s/src/plugins/schema/__tests__/optional.test.ts index 674f68e13..fd6f22faf 100644 --- a/packages/n4s/src/plugins/schema/__tests__/optional.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/optional.test.ts @@ -7,10 +7,10 @@ describe('enforce.optional', () => { describe('lazy interface', () => { it('Should return a passing result for nullable values', () => { expect(enforce.optional(enforce.isNumber()).run(null)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect(enforce.optional(enforce.isArray()).run(undefined)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect( @@ -23,16 +23,16 @@ describe('enforce.optional', () => { .run({ firstName: 'John', lastName: 'Doe', - }) + }), ).toEqual(ruleReturn.passing()); }); it('Should return passing result for non-nullable values that satisfy the tests', () => { expect(enforce.optional(enforce.isNumber()).run(2)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect(enforce.optional(enforce.isArray()).run([1, 2])).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect( enforce @@ -45,16 +45,16 @@ describe('enforce.optional', () => { firstName: 'John', middleName: 'H.', lastName: 'Doe', - }) + }), ).toEqual(ruleReturn.passing()); }); it('Should return a failing result for non-nullable values that do not satisfy the tests', () => { expect(enforce.optional(enforce.isNumber()).run('2')).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect(enforce.optional(enforce.isArray()).run('2')).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect( enforce @@ -67,7 +67,7 @@ describe('enforce.optional', () => { firstName: 'John', middleName: 'H.', lastName: 'Doe', - }) + }), ).toEqual(ruleReturn.failing()); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts index d42d06e5e..ae261ff81 100644 --- a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts @@ -11,7 +11,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); partial({}); @@ -21,7 +21,7 @@ describe('partial', () => { rules.run({ username: null, id: null, - }) + }), ).toEqual(ruleReturn.passing()); }); @@ -30,11 +30,11 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); expect(rules.run({ username: 'foobar', id: 1 })).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); }); @@ -43,7 +43,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); expect(rules.run({ username: 'foobar' })).toEqual(ruleReturn.passing()); @@ -54,11 +54,11 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); expect(rules.run({ username: 'foo', id: '1' })).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); }); }); @@ -69,7 +69,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); enforce({ @@ -79,7 +79,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); }); @@ -88,7 +88,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); }); @@ -97,7 +97,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); }); @@ -107,8 +107,8 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) - ) + }), + ), ).toThrow(); }); }); @@ -120,9 +120,9 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ) - .run({ username: 'foobar', id: '1', foo: 'bar' }) + .run({ username: 'foobar', id: '1', foo: 'bar' }), ).toEqual(ruleReturn.failing()); expect( @@ -131,9 +131,9 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ) - .run({ username: 'foobar', id: '1', foo: 'bar' }) + .run({ username: 'foobar', id: '1', foo: 'bar' }), ).toEqual(ruleReturn.passing()); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts index b3dd49298..a81ad0292 100644 --- a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts @@ -9,7 +9,7 @@ describe('enforce.shape exact matching', () => { expect( enforce .shape({ username: enforce.isString(), age: enforce.isNumber() }) - .run({ username: 'ealush', age: 31, foo: 'bar' }) + .run({ username: 'ealush', age: 31, foo: 'bar' }), ).toEqual(ruleReturn.failing()); }); }); diff --git a/packages/n4s/src/plugins/schema/isArrayOf.ts b/packages/n4s/src/plugins/schema/isArrayOf.ts index 78e4bd7d7..9644d2ef5 100644 --- a/packages/n4s/src/plugins/schema/isArrayOf.ts +++ b/packages/n4s/src/plugins/schema/isArrayOf.ts @@ -8,16 +8,16 @@ import runLazyRule from 'runLazyRule'; export function isArrayOf( inputArray: any[], - currentRule: LazyRuleRunners + currentRule: LazyRuleRunners, ): RuleDetailedResult { return ruleReturn.defaultToPassing( mapFirst(inputArray, (currentValue, breakout, index) => { const res = ctx.run( { value: currentValue, set: true, meta: { index } }, - () => runLazyRule(currentRule, currentValue) + () => runLazyRule(currentRule, currentValue), ); breakout(!res.pass, res); - }) + }), ); } diff --git a/packages/n4s/src/plugins/schema/loose.ts b/packages/n4s/src/plugins/schema/loose.ts index b94e872a2..a88ab012b 100644 --- a/packages/n4s/src/plugins/schema/loose.ts +++ b/packages/n4s/src/plugins/schema/loose.ts @@ -7,14 +7,14 @@ import type { ShapeObject } from 'schemaTypes'; export function loose( inputObject: Record, - shapeObject: ShapeObject + shapeObject: ShapeObject, ): RuleDetailedResult { for (const key in shapeObject) { const currentValue = inputObject[key]; const currentRule = shapeObject[key]; const res = ctx.run({ value: currentValue, set: true, meta: { key } }, () => - runLazyRule(currentRule, currentValue) + runLazyRule(currentRule, currentValue), ); if (!res.pass) { diff --git a/packages/n4s/src/plugins/schema/shape.ts b/packages/n4s/src/plugins/schema/shape.ts index e7c64adc0..aa2dd4fdb 100644 --- a/packages/n4s/src/plugins/schema/shape.ts +++ b/packages/n4s/src/plugins/schema/shape.ts @@ -7,7 +7,7 @@ import type { ShapeObject } from 'schemaTypes'; export function shape( inputObject: Record, - shapeObject: ShapeObject + shapeObject: ShapeObject, ): RuleDetailedResult { const baseRes = loose(inputObject, shapeObject); if (!baseRes.pass) { diff --git a/packages/n4s/src/rules/__tests__/endsWith.test.ts b/packages/n4s/src/rules/__tests__/endsWith.test.ts index e341bbbd5..b23c1df25 100644 --- a/packages/n4s/src/rules/__tests__/endsWith.test.ts +++ b/packages/n4s/src/rules/__tests__/endsWith.test.ts @@ -9,7 +9,7 @@ describe('Tests isArray rule', () => { it('Should return true for a suffix', () => { expect(endsWith(word, word.substring(word.length / 2, word.length))).toBe( - true + true, ); }); diff --git a/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts b/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts index 60cab3a08..96a86c757 100644 --- a/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts +++ b/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts @@ -55,7 +55,7 @@ describe('Tests greaterThanOrEquals rule', () => { // @ts-expect-error - Testing invalid input expect(greaterThanOrEquals(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/inside.test.ts b/packages/n4s/src/rules/__tests__/inside.test.ts index e855cbbfd..d3d19ca22 100644 --- a/packages/n4s/src/rules/__tests__/inside.test.ts +++ b/packages/n4s/src/rules/__tests__/inside.test.ts @@ -9,7 +9,7 @@ describe('Inside rule', () => { it('Should fail to find a string inside an array in which it does not exist', () => { expect(inside('going to', ["I'm", 'gonna', 'pop', 'some', 'tags'])).toBe( - false + false, ); }); @@ -35,7 +35,7 @@ describe('Inside rule', () => { it('Should fail to find array elements in another array in which they do not exist', () => { expect(inside(['no', 'treble'], ['all', 'about', 'the', 'bass'])).toBe( - false + false, ); }); diff --git a/packages/n4s/src/rules/__tests__/isKeyOf.test.ts b/packages/n4s/src/rules/__tests__/isKeyOf.test.ts index 011a9b8f7..fd9b3a2fc 100644 --- a/packages/n4s/src/rules/__tests__/isKeyOf.test.ts +++ b/packages/n4s/src/rules/__tests__/isKeyOf.test.ts @@ -38,7 +38,7 @@ describe('Tests isKeyOf rule', () => { 'Should throw when %s is an object', v => { expect(() => enforce(DUMMY_KEY).isKeyOf({ v })).toThrow(); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/lessThan.test.ts b/packages/n4s/src/rules/__tests__/lessThan.test.ts index a79f53b7c..9360d3c49 100644 --- a/packages/n4s/src/rules/__tests__/lessThan.test.ts +++ b/packages/n4s/src/rules/__tests__/lessThan.test.ts @@ -59,7 +59,7 @@ describe('Tests lessThan rule', () => { // @ts-expect-error - Testing invalid input expect(lessThan(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts b/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts index 8cddf08e7..aaf16e883 100644 --- a/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts +++ b/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts @@ -59,7 +59,7 @@ describe('Tests lessThanOrEquals rule', () => { // @ts-expect-error - Testing invalid input expect(lessThanOrEquals(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/ruleCondition.test.ts b/packages/n4s/src/rules/__tests__/ruleCondition.test.ts index b34635cc3..1b7e0a91e 100644 --- a/packages/n4s/src/rules/__tests__/ruleCondition.test.ts +++ b/packages/n4s/src/rules/__tests__/ruleCondition.test.ts @@ -17,7 +17,7 @@ describe('enforce.condition', () => { expect(enforce.condition(() => false).run(1)).toEqual(failing()); expect(enforce.condition(() => failing()).run(1)).toEqual(failing()); expect( - enforce.condition(() => ruleReturn(false, 'failure message')).run(1) + enforce.condition(() => ruleReturn(false, 'failure message')).run(1), ).toEqual(ruleReturn(false, 'failure message')); }); @@ -25,7 +25,7 @@ describe('enforce.condition', () => { expect(enforce.condition(() => true).run(1)).toEqual(passing()); expect(enforce.condition(() => passing()).run(1)).toEqual(passing()); expect( - enforce.condition(() => ruleReturn(true, 'success message')).run(1) + enforce.condition(() => ruleReturn(true, 'success message')).run(1), ).toEqual(passing()); }); }); @@ -37,7 +37,7 @@ describe('enforce.condition', () => { expect(() => enforce(1).condition(() => failing())).toThrow(); expect(() => - enforce(1).condition(() => ruleReturn(false, 'failure message')) + enforce(1).condition(() => ruleReturn(false, 'failure message')), ).toThrow(); }); @@ -47,7 +47,7 @@ describe('enforce.condition', () => { expect(() => enforce(1).condition(() => passing())).not.toThrow(); expect(() => - enforce(1).condition(() => ruleReturn(true, 'success message')) + enforce(1).condition(() => ruleReturn(true, 'success message')), ).not.toThrow(); }); }); diff --git a/packages/n4s/src/rules/greaterThanOrEquals.ts b/packages/n4s/src/rules/greaterThanOrEquals.ts index c2ee07d7e..43b099cc8 100644 --- a/packages/n4s/src/rules/greaterThanOrEquals.ts +++ b/packages/n4s/src/rules/greaterThanOrEquals.ts @@ -2,7 +2,7 @@ import { greaterThan, numberEquals } from 'vest-utils'; export function greaterThanOrEquals( value: string | number, - gte: string | number + gte: string | number, ): boolean { return numberEquals(value, gte) || greaterThan(value, gte); } diff --git a/packages/n4s/src/rules/isBetween.ts b/packages/n4s/src/rules/isBetween.ts index d3b75bfb8..e3293a10b 100644 --- a/packages/n4s/src/rules/isBetween.ts +++ b/packages/n4s/src/rules/isBetween.ts @@ -6,7 +6,7 @@ import { lessThanOrEquals as lte } from 'lessThanOrEquals'; export function isBetween( value: number | string, min: number | string, - max: number | string + max: number | string, ): boolean { return gte(value, min) && lte(value, max); } diff --git a/packages/n4s/src/rules/lessThanOrEquals.ts b/packages/n4s/src/rules/lessThanOrEquals.ts index c48771105..c7aff9e94 100644 --- a/packages/n4s/src/rules/lessThanOrEquals.ts +++ b/packages/n4s/src/rules/lessThanOrEquals.ts @@ -4,7 +4,7 @@ import { lessThan } from 'lessThan'; export function lessThanOrEquals( value: string | number, - lte: string | number + lte: string | number, ): boolean { return numberEquals(value, lte) || lessThan(value, lte); } diff --git a/packages/n4s/src/rules/longerThanOrEquals.ts b/packages/n4s/src/rules/longerThanOrEquals.ts index 7a1e8dec3..4e4855dde 100644 --- a/packages/n4s/src/rules/longerThanOrEquals.ts +++ b/packages/n4s/src/rules/longerThanOrEquals.ts @@ -2,7 +2,7 @@ import { greaterThanOrEquals } from 'greaterThanOrEquals'; export function longerThanOrEquals( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return greaterThanOrEquals(value.length, arg1); } diff --git a/packages/n4s/src/rules/ruleCondition.ts b/packages/n4s/src/rules/ruleCondition.ts index 7cf682df4..690faf835 100644 --- a/packages/n4s/src/rules/ruleCondition.ts +++ b/packages/n4s/src/rules/ruleCondition.ts @@ -2,7 +2,7 @@ import type { RuleReturn } from 'ruleReturn'; export function condition( value: any, - callback: (value: any) => RuleReturn + callback: (value: any) => RuleReturn, ): RuleReturn { try { return callback(value); diff --git a/packages/n4s/src/rules/shorterThan.ts b/packages/n4s/src/rules/shorterThan.ts index 6e1169ca1..def0f72f6 100644 --- a/packages/n4s/src/rules/shorterThan.ts +++ b/packages/n4s/src/rules/shorterThan.ts @@ -2,7 +2,7 @@ import { lessThan } from 'lessThan'; export function shorterThan( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return lessThan(value.length, arg1); } diff --git a/packages/n4s/src/rules/shorterThanOrEquals.ts b/packages/n4s/src/rules/shorterThanOrEquals.ts index 93a89ad90..af317db43 100644 --- a/packages/n4s/src/rules/shorterThanOrEquals.ts +++ b/packages/n4s/src/rules/shorterThanOrEquals.ts @@ -2,7 +2,7 @@ import { lessThanOrEquals } from 'lessThanOrEquals'; export function shorterThanOrEquals( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return lessThanOrEquals(value.length, arg1); } diff --git a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts index 0eeb5a608..92e94f235 100644 --- a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts +++ b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts @@ -56,12 +56,12 @@ describe('enforce.context', () => { // first.parent() === name expect(keepContext.mock.calls[0][0].parent()).toEqual( - keepContext.mock.calls[1][0] + keepContext.mock.calls[1][0], ); // siblings[0].parent() === siblings expect(keepContext.mock.calls[2][0].parent()).toEqual( - keepContext.mock.calls[3][0] + keepContext.mock.calls[3][0], ); }); @@ -85,7 +85,7 @@ describe('enforce.context', () => { .someCustomRule(); expect( - keepContext.mock.calls[0][0].parent().parent().parent() + keepContext.mock.calls[0][0].parent().parent().parent(), ).toBeNull(); expect(keepContext.mock.calls[1][0].parent().parent()).toBeNull(); expect(keepContext.mock.calls[4][0].parent()).toBeNull(); @@ -152,7 +152,7 @@ describe('enforce.context', () => { describe('enforce.isArrayOf', () => { it('passes the current value into the context', () => { enforce(['Elle', 'Tester', 'Sophie']).isArrayOf( - enforce.isString().someCustomRule() + enforce.isString().someCustomRule(), ); expect(keepContext.mock.calls[0][0].value).toBe('Elle'); @@ -162,7 +162,7 @@ describe('enforce.context', () => { it('passes the current index into the context meta field', () => { enforce(['Elle', 'Tester', 'Sophie']).isArrayOf( - enforce.isString().someCustomRule() + enforce.isString().someCustomRule(), ); expect(keepContext.mock.calls[0][0].meta).toEqual({ index: 0 }); expect(keepContext.mock.calls[1][0].meta).toEqual({ index: 1 }); @@ -180,9 +180,9 @@ describe('enforce.context', () => { }).shape({ username: enforce.isString(), friends: enforce.isArrayOf( - enforce.isString().isFriendTheSameAsUser() + enforce.isString().isFriendTheSameAsUser(), ), - }) + }), ).toThrow(); }); diff --git a/packages/n4s/src/runtime/__tests__/message.test.ts b/packages/n4s/src/runtime/__tests__/message.test.ts index 8c9ca70b0..ed51d89bc 100644 --- a/packages/n4s/src/runtime/__tests__/message.test.ts +++ b/packages/n4s/src/runtime/__tests__/message.test.ts @@ -4,27 +4,27 @@ import ruleReturn from 'ruleReturn'; describe('enforce..message()', () => { it('Should set the failure message in builtin rules', () => { expect( - enforce.equals(false).message('oof. Expected true to be false').run(true) + enforce.equals(false).message('oof. Expected true to be false').run(true), ).toEqual(ruleReturn(false, 'oof. Expected true to be false')); expect( enforce .equals(false) .message(() => 'oof. Expected true to be false') - .run(true) + .run(true), ).toEqual(ruleReturn(false, 'oof. Expected true to be false')); }); it('Should set the failure message in custom rules', () => { expect( - enforce.ruleWithFailureMessage().message('oof. Failed again!').run(true) + enforce.ruleWithFailureMessage().message('oof. Failed again!').run(true), ).toEqual(ruleReturn(false, 'oof. Failed again!')); expect( enforce .ruleWithFailureMessage() .message(() => 'oof. Failed again!') - .run(true) + .run(true), ).toEqual(ruleReturn(false, 'oof. Failed again!')); }); @@ -33,7 +33,7 @@ describe('enforce..message()', () => { const msg = jest.fn(() => 'some message'); const arg = {}; expect(enforce.equals(false).message(msg).run(arg)).toEqual( - ruleReturn(false, 'some message') + ruleReturn(false, 'some message'), ); expect(msg).toHaveBeenCalledWith(arg, undefined); }); @@ -42,7 +42,7 @@ describe('enforce..message()', () => { const msg = jest.fn(() => 'some message'); const arg = {}; expect( - enforce.ruleWithFailureMessage(false).message(msg).run(arg) + enforce.ruleWithFailureMessage(false).message(msg).run(arg), ).toEqual(ruleReturn(false, 'some message')); expect(msg).toHaveBeenCalledWith(arg, 'This should not be seen!'); }); diff --git a/packages/n4s/src/runtime/genEnforceLazy.ts b/packages/n4s/src/runtime/genEnforceLazy.ts index c0aedc535..70e2c2a81 100644 --- a/packages/n4s/src/runtime/genEnforceLazy.ts +++ b/packages/n4s/src/runtime/genEnforceLazy.ts @@ -26,7 +26,7 @@ export default function genEnforceLazy(key: string) { const rule = getRule(ruleName); registeredRules.push((value: RuleValue) => - transformResult(rule(value, ...args), ruleName, value, ...args) + transformResult(rule(value, ...args), ruleName, value, ...args), ); let proxy = { @@ -40,10 +40,10 @@ export default function genEnforceLazy(key: string) { ruleReturn( !!res.pass, optionalFunctionValue(lazyMessage, value, res.message) ?? - res.message - ) + res.message, + ), ); - }) + }), ); }, test: (value: RuleValue): boolean => proxy.run(value).pass, diff --git a/packages/vast/README.md b/packages/vast/README.md index 0274aa523..45758925a 100644 --- a/packages/vast/README.md +++ b/packages/vast/README.md @@ -58,7 +58,7 @@ const useColor = state.registerStateKey( 'red', (currentState, previousState) => { console.log(`the color changed from ${previousState} to ${currentState}!`); - } + }, ); ``` diff --git a/packages/vast/src/__tests__/vast.test.ts b/packages/vast/src/__tests__/vast.test.ts index da3d21c3a..ff5c3bb2a 100644 --- a/packages/vast/src/__tests__/vast.test.ts +++ b/packages/vast/src/__tests__/vast.test.ts @@ -26,12 +26,12 @@ describe('vast state', () => { it('Should append another state key on each call', () => { const stateValues = Array.from({ length: 100 }, () => Math.random()); const stateGetters = stateValues.map(value => - state.registerStateKey(value) + state.registerStateKey(value), ); expect( stateGetters.every( - (stateGetter, i) => stateGetter()[0] === stateValues[i] - ) + (stateGetter, i) => stateGetter()[0] === stateValues[i], + ), ).toBe(true); expect(stateGetters).toHaveLength(100); }); @@ -165,7 +165,7 @@ describe('vast state', () => { state.registerStateKey('v1', onUpdate); expect(onUpdate.mock.invocationCallOrder[0]).toBeLessThan( - onChange.mock.invocationCallOrder[0] + onChange.mock.invocationCallOrder[0], ); }); }); diff --git a/packages/vast/src/vast.ts b/packages/vast/src/vast.ts index 6f663b432..f776ca766 100644 --- a/packages/vast/src/vast.ts +++ b/packages/vast/src/vast.ts @@ -8,7 +8,7 @@ import { // eslint-disable-next-line max-lines-per-function export function createState( - onStateChange?: (...args: unknown[]) => unknown + onStateChange?: (...args: unknown[]) => unknown, ): CreateStateReturn { const state: { references: unknown[]; @@ -18,7 +18,7 @@ export function createState( const registrations: [ unknown, - ((currentState: S, prevState: S) => void)? + ((currentState: S, prevState: S) => void)?, ][] = []; return { @@ -41,7 +41,7 @@ export function createState( */ function registerStateKey( initialState?: Maybe>, - onUpdate?: () => void + onUpdate?: () => void, ): CB> { const key = registrations.length; registrations.push([initialState, onUpdate]); @@ -52,14 +52,14 @@ export function createState( const prev = current(); state.references = []; registrations.forEach(([initialValue], index) => - initKey(index, initialValue, prev[index]) + initKey(index, initialValue, prev[index]), ); } function initKey( key: number, initialState?: Maybe>, - prevState?: Maybe + prevState?: Maybe, ) { current().push(); set(key, optionalFunctionValue(initialState, prevState)); @@ -104,6 +104,6 @@ type CreateStateReturn = { reset: () => void; registerStateKey: ( initialState?: Maybe>, - onUpdate?: () => void + onUpdate?: () => void, ) => CB>; }; diff --git a/packages/vest-utils/src/SimpleStateMachine.ts b/packages/vest-utils/src/SimpleStateMachine.ts index 9f07939d6..9d9ca8c61 100644 --- a/packages/vest-utils/src/SimpleStateMachine.ts +++ b/packages/vest-utils/src/SimpleStateMachine.ts @@ -20,7 +20,7 @@ export type TStateMachineApi = { }; export function StateMachine( - machine: TStateMachine + machine: TStateMachine, ): TStateMachineApi { let state = machine.initial; diff --git a/packages/vest-utils/src/__tests__/Predicates.test.ts b/packages/vest-utils/src/__tests__/Predicates.test.ts index 7b2b23d3f..d87a0d34d 100644 --- a/packages/vest-utils/src/__tests__/Predicates.test.ts +++ b/packages/vest-utils/src/__tests__/Predicates.test.ts @@ -9,7 +9,7 @@ describe('Predicates', () => { it('Should return true if all predicates return true', () => { const predicate = all( value => value > 0, - value => value < 10 + value => value < 10, ); expect(predicate(5)).toBe(true); @@ -18,7 +18,7 @@ describe('Predicates', () => { it('Should return false if any predicate returns false', () => { const predicate = all( value => value > 0, - value => value < 10 + value => value < 10, ); expect(predicate(15)).toBe(false); @@ -35,7 +35,7 @@ describe('Predicates', () => { value => value > 0, value => value < 10, // @ts-ignore - Testing invalid input - 'not a function' + 'not a function', ); expect(predicate(15)).toBe(false); @@ -71,21 +71,21 @@ describe('Predicates', () => { expect( any( value => value > 0, - value => value === 10 - )(5) + value => value === 10, + )(5), ).toBe(true); expect( any( value => value === 10, - value => value > 0 - )(5) + value => value > 0, + )(5), ).toBe(true); }); it('Should return true if all predicates return true', () => { const predicate = any( value => value > 0, - value => value === 10 + value => value === 10, ); expect(predicate(10)).toBe(true); @@ -94,7 +94,7 @@ describe('Predicates', () => { it('Should return false if all predicates return false', () => { const predicate = any( value => value > 0, - value => value === 10 + value => value === 10, ); expect(predicate(-5)).toBe(false); diff --git a/packages/vest-utils/src/__tests__/cache.test.ts b/packages/vest-utils/src/__tests__/cache.test.ts index d8eae24e1..7cfa4feb7 100644 --- a/packages/vest-utils/src/__tests__/cache.test.ts +++ b/packages/vest-utils/src/__tests__/cache.test.ts @@ -59,7 +59,7 @@ describe('lib: cache', () => { Array.from({ length: callCount }, (_, i) => { const c = cache(/*maxSize*/ cacheSize); const results = Array.from({ length: callCount }, (_, j) => - c([j], Math.random) + c([j], Math.random), ); if (i < diff) { @@ -74,7 +74,7 @@ describe('lib: cache', () => { }); it('Should take into account the deps array in its entirety', () => { const deps = Array.from({ length: 100 }, () => - _.sample([{}, false, Math.random(), true, () => null]) + _.sample([{}, false, Math.random(), true, () => null]), ); const c = cache(); const res = c([...deps], Math.random); diff --git a/packages/vest-utils/src/__tests__/defaultTo.test.ts b/packages/vest-utils/src/__tests__/defaultTo.test.ts index 8886e3d47..0dc823a40 100644 --- a/packages/vest-utils/src/__tests__/defaultTo.test.ts +++ b/packages/vest-utils/src/__tests__/defaultTo.test.ts @@ -34,7 +34,7 @@ describe('defaultTo', () => { 'Should return the same value', value => { expect(defaultTo(value, 'fallback value')).toBe(value); - } + }, ); }); }); diff --git a/packages/vest-utils/src/__tests__/greaterThan.test.ts b/packages/vest-utils/src/__tests__/greaterThan.test.ts index 8badeedb8..eed74321c 100644 --- a/packages/vest-utils/src/__tests__/greaterThan.test.ts +++ b/packages/vest-utils/src/__tests__/greaterThan.test.ts @@ -62,7 +62,7 @@ describe('Tests greaterThan rule', () => { // @ts-expect-error - testing invalid input expect(greaterThan(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/vest-utils/src/__tests__/numberEquals.test.ts b/packages/vest-utils/src/__tests__/numberEquals.test.ts index 9dda865d2..da7f04671 100644 --- a/packages/vest-utils/src/__tests__/numberEquals.test.ts +++ b/packages/vest-utils/src/__tests__/numberEquals.test.ts @@ -61,7 +61,7 @@ describe('Tests numberEquals rule', () => { // @ts-expect-error - testing invalid input expect(numberEquals(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts index ec973a01f..ede97ee76 100644 --- a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts +++ b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts @@ -6,7 +6,7 @@ describe('optionalFunctionValue', () => { 'Should return the same value', value => { expect(optionalFunctionValue(value)).toBe(value); - } + }, ); }); diff --git a/packages/vest-utils/src/__tests__/text.test.ts b/packages/vest-utils/src/__tests__/text.test.ts index 0da573924..b3cbc8425 100644 --- a/packages/vest-utils/src/__tests__/text.test.ts +++ b/packages/vest-utils/src/__tests__/text.test.ts @@ -5,10 +5,10 @@ describe('text', () => { describe('When all substitutions exist', () => { it('Should replace delimited placeholders', () => { expect(text('this {t} an example', { t: 'was' })).toBe( - 'this was an example' + 'this was an example', ); expect(text('this {t1} {t2} example', { t1: 'was', t2: 'one' })).toBe( - 'this was one example' + 'this was one example', ); }); }); diff --git a/packages/vest-utils/src/cache.ts b/packages/vest-utils/src/cache.ts index 0b750e1ea..4ac2cc2c9 100644 --- a/packages/vest-utils/src/cache.ts +++ b/packages/vest-utils/src/cache.ts @@ -10,7 +10,7 @@ export default function createCache(maxSize = 1): CacheApi { const cache = ( deps: unknown[], - cacheAction: (...args: unknown[]) => T + cacheAction: (...args: unknown[]) => T, ): T => { const cacheHit = cache.get(deps); // cache hit is not null @@ -40,7 +40,7 @@ export default function createCache(maxSize = 1): CacheApi { return cacheStorage.findIndex( ([cachedDeps]) => lengthEquals(deps, cachedDeps.length) && - deps.every((dep, i) => dep === cachedDeps[i]) + deps.every((dep, i) => dep === cachedDeps[i]), ); } } diff --git a/packages/vest-utils/src/defaultTo.ts b/packages/vest-utils/src/defaultTo.ts index 08c04def4..f4a9a417f 100644 --- a/packages/vest-utils/src/defaultTo.ts +++ b/packages/vest-utils/src/defaultTo.ts @@ -3,7 +3,7 @@ import { DynamicValue, Nullish } from 'utilityTypes'; export default function defaultTo( value: DynamicValue>, - defaultValue: DynamicValue + defaultValue: DynamicValue, ): T { return optionalFunctionValue(value) ?? optionalFunctionValue(defaultValue); } diff --git a/packages/vest-utils/src/greaterThan.ts b/packages/vest-utils/src/greaterThan.ts index 04dc56707..8201db164 100644 --- a/packages/vest-utils/src/greaterThan.ts +++ b/packages/vest-utils/src/greaterThan.ts @@ -2,7 +2,7 @@ import { isNumeric } from 'isNumeric'; export function greaterThan( value: number | string, - gt: number | string + gt: number | string, ): boolean { return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt); } diff --git a/packages/vest-utils/src/hasOwnProperty.ts b/packages/vest-utils/src/hasOwnProperty.ts index 7f6330e51..f2f9a12dc 100644 --- a/packages/vest-utils/src/hasOwnProperty.ts +++ b/packages/vest-utils/src/hasOwnProperty.ts @@ -3,7 +3,7 @@ */ export default function hasOwnProperty( obj: T, - key: string | number | symbol + key: string | number | symbol, ): key is keyof T { return Object.prototype.hasOwnProperty.call(obj, key); } diff --git a/packages/vest-utils/src/invariant.ts b/packages/vest-utils/src/invariant.ts index acbe2b792..556e3977d 100644 --- a/packages/vest-utils/src/invariant.ts +++ b/packages/vest-utils/src/invariant.ts @@ -4,7 +4,7 @@ import type { Stringable } from 'utilityTypes'; export default function invariant( condition: any, // eslint-disable-next-line @typescript-eslint/ban-types - message?: String | Stringable + message?: String | Stringable, ): asserts condition { if (condition) { return; diff --git a/packages/vest-utils/src/isFunction.ts b/packages/vest-utils/src/isFunction.ts index aafbf70c3..3378daea0 100644 --- a/packages/vest-utils/src/isFunction.ts +++ b/packages/vest-utils/src/isFunction.ts @@ -1,5 +1,5 @@ export default function isFunction( - value: unknown + value: unknown, ): value is (...args: unknown[]) => unknown { return typeof value === 'function'; } diff --git a/packages/vest-utils/src/lengthEquals.ts b/packages/vest-utils/src/lengthEquals.ts index b3a73dd76..031bccc68 100644 --- a/packages/vest-utils/src/lengthEquals.ts +++ b/packages/vest-utils/src/lengthEquals.ts @@ -3,7 +3,7 @@ import { numberEquals } from 'numberEquals'; export function lengthEquals( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return numberEquals(value.length, arg1); } diff --git a/packages/vest-utils/src/longerThan.ts b/packages/vest-utils/src/longerThan.ts index 1bbeef245..9bcb3fce7 100644 --- a/packages/vest-utils/src/longerThan.ts +++ b/packages/vest-utils/src/longerThan.ts @@ -2,7 +2,7 @@ import { greaterThan } from 'greaterThan'; export function longerThan( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return greaterThan(value.length, arg1); } diff --git a/packages/vest-utils/src/mapFirst.ts b/packages/vest-utils/src/mapFirst.ts index cd989f8c1..55f42e80f 100644 --- a/packages/vest-utils/src/mapFirst.ts +++ b/packages/vest-utils/src/mapFirst.ts @@ -3,8 +3,8 @@ export default function mapFirst( callback: ( item: T, breakout: (conditional: boolean, value: unknown) => void, - index: number - ) => unknown + index: number, + ) => unknown, ): any { let broke = false; let breakoutValue = null; diff --git a/packages/vest-utils/src/numberEquals.ts b/packages/vest-utils/src/numberEquals.ts index c2951b386..bc32b4e59 100644 --- a/packages/vest-utils/src/numberEquals.ts +++ b/packages/vest-utils/src/numberEquals.ts @@ -3,7 +3,7 @@ import { isNumeric } from 'isNumeric'; export function numberEquals( value: string | number, - eq: string | number + eq: string | number, ): boolean { return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq); } diff --git a/packages/vest-utils/src/tinyState.ts b/packages/vest-utils/src/tinyState.ts index 8a6f7ee9f..f1d898e95 100644 --- a/packages/vest-utils/src/tinyState.ts +++ b/packages/vest-utils/src/tinyState.ts @@ -2,7 +2,7 @@ import optionalFunctionValue from 'optionalFunctionValue'; import { DynamicValue } from 'utilityTypes'; export function createTinyState( - initialValue: SetValueInput + initialValue: SetValueInput, ): TinyState { let value: S; @@ -22,7 +22,7 @@ export function createTinyState( export type TinyState = () => [ value: S, setValue: (next: SetValueInput) => void, - resetValue: () => void + resetValue: () => void, ]; type SetValueInput = DynamicValue; diff --git a/packages/vest/src/__tests__/integration.stateful-async.test.ts b/packages/vest/src/__tests__/integration.stateful-async.test.ts index a30fa266d..096edbe93 100644 --- a/packages/vest/src/__tests__/integration.stateful-async.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-async.test.ts @@ -127,7 +127,7 @@ describe('Stateful async tests', () => { vest.test('field_1', tests.length.toString(), async () => { await wait(100); throw new Error(); - }) + }), ); }); suite().done(() => { diff --git a/packages/vest/src/__tests__/integration.stateful-tests.test.ts b/packages/vest/src/__tests__/integration.stateful-tests.test.ts index 9cf0463f9..3f953453a 100644 --- a/packages/vest/src/__tests__/integration.stateful-tests.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-tests.test.ts @@ -133,9 +133,9 @@ describe('more complex', () => { vest.test('confirm', 'passwords do not match', () => { enforce(data.confirm).equals(data.password); }); - } + }, ); - } + }, ); }); diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index a90ae4825..81521221b 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -259,8 +259,8 @@ describe('isolate', () => { expect(deferThrow).toHaveBeenCalledTimes(1); expect(deferThrow).toHaveBeenCalledWith( expect.stringContaining( - 'Vest Critical Error: Tests called in different order than previous run' - ) + 'Vest Critical Error: Tests called in different order than previous run', + ), ); }); }); diff --git a/packages/vest/src/core/context/SuiteContext.ts b/packages/vest/src/core/context/SuiteContext.ts index ef541e01a..1fd43c707 100644 --- a/packages/vest/src/core/context/SuiteContext.ts +++ b/packages/vest/src/core/context/SuiteContext.ts @@ -23,7 +23,7 @@ export const SuiteContext = createCascade((ctxRef, parentContext) => { suiteParams: [], testMemoCache, }, - ctxRef + ctxRef, ); }); diff --git a/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts b/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts index 2099bff6f..8d089051d 100644 --- a/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts +++ b/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts @@ -6,7 +6,7 @@ import { VestIsolateType } from 'VestIsolateType'; type TIsolateEach = TIsolate; export function IsolateEach( - callback: Callback + callback: Callback, ): TIsolateEach { return Isolate.create(VestIsolateType.Each, callback, { allowReorder: true, diff --git a/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts b/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts index f601819ce..988d95cac 100644 --- a/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts @@ -9,16 +9,16 @@ import { VestIsolateType } from 'VestIsolateType'; export type TIsolateTest< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, > = TIsolate & IsolateTestPayload>; export function IsolateTest< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, >( callback: CB, input: CommonTestFields, - key?: IsolateKey + key?: IsolateKey, ): TIsolateTest { const payload: IsolateTestPayload = { ...IsolateTestBase(), @@ -37,7 +37,7 @@ export function IsolateTest< VestIsolateType.Test, callback, payload, - key ?? null + key ?? null, ); return isolate as TIsolateTest; @@ -52,7 +52,7 @@ export function IsolateTestBase() { export type IsolateTestPayload< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, > = CommonTestFields & { severity: TestSeverity; status: TestStatus; @@ -61,7 +61,7 @@ export type IsolateTestPayload< type CommonTestFields< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, > = { message?: Maybe; groupName?: G; diff --git a/packages/vest/src/core/isolate/IsolateTest/VestTest.ts b/packages/vest/src/core/isolate/IsolateTest/VestTest.ts index 908894d83..2a01093f5 100644 --- a/packages/vest/src/core/isolate/IsolateTest/VestTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/VestTest.ts @@ -20,7 +20,7 @@ export class VestTest extends VestIsolate { static getData< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, >(test: TIsolateTest) { invariant(test.data); return test.data; @@ -29,7 +29,7 @@ export class VestTest extends VestIsolate { static is(isolate?: Maybe): isolate is TIsolateTest { return IsolateSelectors.isIsolateType( isolate, - VestIsolateType.Test + VestIsolateType.Test, ); } @@ -38,7 +38,7 @@ export class VestTest extends VestIsolate { } static cast( - isolate?: Maybe + isolate?: Maybe, ): TIsolateTest { VestTest.isX(isolate); return isolate as TIsolateTest; @@ -115,7 +115,7 @@ export class VestTest extends VestIsolate { static fail(test: TIsolateTest): void { VestTest.setStatus( test, - VestTest.warns(test) ? TestStatus.WARNING : TestStatus.FAILED + VestTest.warns(test) ? TestStatus.WARNING : TestStatus.FAILED, ); } @@ -134,7 +134,7 @@ export class VestTest extends VestIsolate { test: TIsolateTest, setter: | ((current: TIsolateTest['data']) => TIsolateTest['data']) - | TIsolateTest['data'] + | TIsolateTest['data'], ): void { test.data = optionalFunctionValue(setter, VestTest.getData(test)); } diff --git a/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts b/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts index 2ca3479a3..af2da2b56 100644 --- a/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts @@ -4,7 +4,7 @@ import { isSameProfileTest } from 'isSameProfileTest'; export default function cancelOverriddenPendingTest( prevRunTestObject: TIsolateTest, - currentRunTestObject: TIsolateTest + currentRunTestObject: TIsolateTest, ): void { if ( currentRunTestObject !== prevRunTestObject && diff --git a/packages/vest/src/core/test/__tests__/memo.test.ts b/packages/vest/src/core/test/__tests__/memo.test.ts index 7d8d1e761..daee15668 100644 --- a/packages/vest/src/core/test/__tests__/memo.test.ts +++ b/packages/vest/src/core/test/__tests__/memo.test.ts @@ -39,7 +39,7 @@ describe('test.memo', () => { vest.warn(); return false; }, - [{}] + [{}], ); })(); @@ -61,7 +61,7 @@ describe('test.memo', () => { vest.warn(); return false; }, - [4] + [4], ); }); @@ -90,7 +90,7 @@ describe('test.memo', () => { await wait(500); enforce(1).equals(2); }, - [1] + [1], ); vestTest.memo( 'field2', @@ -98,7 +98,7 @@ describe('test.memo', () => { await wait(500); enforce(1).equals(2); }, - [2] + [2], ); }); @@ -129,8 +129,8 @@ describe('test.memo', () => { async () => { await wait(10); }, - [true] - ) + [true], + ), ); if (count === 1) { @@ -152,7 +152,7 @@ describe('test.memo', () => { it('Should run test normally', () => { const cb1 = jest.fn(res => res); const cb2 = jest.fn( - res => new Promise((resolve, rej) => (res ? resolve() : rej())) + res => new Promise((resolve, rej) => (res ? resolve() : rej())), ); const suite = vest.create((key, res) => { vestTest.memo('f1', () => cb1(res), [1, key]); diff --git a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts index 6edde051c..1dddcfee5 100644 --- a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +++ b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts @@ -104,8 +104,8 @@ describe('Merging of previous test runs', () => { expect(deferThrow).toHaveBeenCalledWith( expect.stringContaining( - 'Vest Critical Error: Tests called in different order than previous run.' - ) + 'Vest Critical Error: Tests called in different order than previous run.', + ), ); }); @@ -337,7 +337,7 @@ describe('Merging of previous test runs', () => { () => { vest.test('f4', () => false); vest.test('f5', () => false); - } + }, ); counter++; }); diff --git a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts index 575ee890e..faf2851b5 100644 --- a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts +++ b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts @@ -99,7 +99,7 @@ describe('runAsyncTest', () => { testObject.push( vest.test('field_1', async () => { await wait(10); - }) + }), ); vest.test('field_2', () => {}); }); diff --git a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts index e34248f8a..f252ffe0a 100644 --- a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts +++ b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts @@ -77,7 +77,7 @@ describe('Test Function Payload', () => { function callPayload( fn: jest.Mock, call: number = 0, - arg: number = 0 + arg: number = 0, ) { return fn.mock.calls[call][arg]; } diff --git a/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts b/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts index 698da5f83..fc326bb9b 100644 --- a/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts +++ b/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts @@ -18,7 +18,7 @@ describe('nonMatchingSeverityProfile', () => { it('should return false', () => { VestTest.warn(testObject); expect(nonMatchingSeverityProfile(Severity.WARNINGS, testObject)).toBe( - false + false, ); }); }); @@ -26,7 +26,7 @@ describe('nonMatchingSeverityProfile', () => { describe('When both are not warning', () => { it('should return false', () => { expect(nonMatchingSeverityProfile(Severity.ERRORS, testObject)).toBe( - false + false, ); }); }); @@ -37,7 +37,7 @@ describe('nonMatchingSeverityProfile', () => { it('should return true', () => { VestTest.warn(testObject); expect(nonMatchingSeverityProfile(Severity.ERRORS, testObject)).toBe( - true + true, ); }); }); @@ -45,7 +45,7 @@ describe('nonMatchingSeverityProfile', () => { describe('When severity is warning', () => { it('should return true', () => { expect(nonMatchingSeverityProfile(Severity.WARNINGS, testObject)).toBe( - true + true, ); }); }); diff --git a/packages/vest/src/core/test/helpers/matchingGroupName.ts b/packages/vest/src/core/test/helpers/matchingGroupName.ts index d410b8fc7..75ba66d72 100644 --- a/packages/vest/src/core/test/helpers/matchingGroupName.ts +++ b/packages/vest/src/core/test/helpers/matchingGroupName.ts @@ -8,7 +8,7 @@ export const nonMatchingGroupName = bindNot(matchingGroupName); export function matchingGroupName( testObject: TIsolateTest, - groupName: Maybe + groupName: Maybe, ): boolean { return VestTest.getData(testObject).groupName === groupName; } diff --git a/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts b/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts index 7c7fbcf8f..67473fa37 100644 --- a/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts +++ b/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts @@ -9,7 +9,7 @@ import { VestTest } from 'VestTest'; */ export function nonMatchingSeverityProfile( severity: Severity, - testObject: TIsolateTest + testObject: TIsolateTest, ): boolean { return either(severity === Severity.WARNINGS, VestTest.warns(testObject)); } diff --git a/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts b/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts index c29724f63..aa381d004 100644 --- a/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts +++ b/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts @@ -2,7 +2,7 @@ import { Maybe, isStringValue, isUndefined } from 'vest-utils'; export function shouldUseErrorAsMessage( message: Maybe, - error: unknown + error: unknown, ): error is Maybe { // kind of cheating with this safe guard, but it does the job return isUndefined(message) && isStringValue(error); diff --git a/packages/vest/src/core/test/test.memo.ts b/packages/vest/src/core/test/test.memo.ts index 7d1d5c5df..2df21ef30 100644 --- a/packages/vest/src/core/test/test.memo.ts +++ b/packages/vest/src/core/test/test.memo.ts @@ -47,7 +47,7 @@ export function wrapTestMemo(test: VTest): TestMemo { function useGetTestFromCache( dependencies: any[], - cacheAction: CB + cacheAction: CB, ): TIsolateTest { const cache = useTestMemoCache(); @@ -80,7 +80,7 @@ type ParametersWithoutMessage = [test: TestFn, dependencies: unknown[]]; type ParametersWithMessage = [ message: string, test: TestFn, - dependencies: unknown[] + dependencies: unknown[], ]; type ParamsOverload = ParametersWithoutMessage | ParametersWithMessage; diff --git a/packages/vest/src/core/test/test.ts b/packages/vest/src/core/test/test.ts index 8e1e732e5..ec3e61a34 100644 --- a/packages/vest/src/core/test/test.ts +++ b/packages/vest/src/core/test/test.ts @@ -13,19 +13,19 @@ import { wrapTestMemo } from 'test.memo'; function vestTest( fieldName: F, message: string, - cb: TestFn + cb: TestFn, ): TIsolateTest; function vestTest(fieldName: F, cb: TestFn): TIsolateTest; function vestTest( fieldName: F, message: string, cb: TestFn, - key: IsolateKey + key: IsolateKey, ): TIsolateTest; function vestTest( fieldName: F, cb: TestFn, - key: IsolateKey + key: IsolateKey, ): TIsolateTest; // @vx-allow use-use function vestTest( @@ -66,7 +66,7 @@ function validateTestParams(fieldName: string, testFn: TestFn): void { fn_name: fnName, param: 'fieldName', expected: 'string', - }) + }), ); invariant( isFunction(testFn), @@ -74,6 +74,6 @@ function validateTestParams(fieldName: string, testFn: TestFn): void { fn_name: fnName, param: 'callback', expected: 'function', - }) + }), ); } diff --git a/packages/vest/src/exports/__tests__/classnames.test.ts b/packages/vest/src/exports/__tests__/classnames.test.ts index 5d547f84b..1c6dabea3 100644 --- a/packages/vest/src/exports/__tests__/classnames.test.ts +++ b/packages/vest/src/exports/__tests__/classnames.test.ts @@ -23,15 +23,15 @@ describe('Utility: classnames', () => { const validate = vest.create( jest.fn(() => { dummyTest.failing('field_0'); - }) + }), ); expect(typeof classnames(validate())).toBe('function'); const promisifed = await promisify( vest.create( jest.fn(() => { dummyTest.failing('field_0'); - }) - ) + }), + ), )(); expect(typeof classnames(promisifed)).toBe('function'); }); @@ -66,21 +66,21 @@ describe('Utility: classnames', () => { // splitting and sorting to not rely on object order which is unspecified in the language expect(genClass('field_2').split(' ').sort()).toEqual( - 'invalid_string tested_string warning_string'.split(' ').sort() + 'invalid_string tested_string warning_string'.split(' ').sort(), ); expect(genClass('field_3').split(' ').sort()).toEqual( - 'tested_string valid_string warning_string'.split(' ').sort() + 'tested_string valid_string warning_string'.split(' ').sort(), ); expect(genClass('field_4').split(' ').sort()).toEqual( - 'tested_string valid_string'.split(' ').sort() + 'tested_string valid_string'.split(' ').sort(), ); expect(genClass('field_5').split(' ').sort()).toEqual( - 'tested_string invalid_string'.split(' ').sort() + 'tested_string invalid_string'.split(' ').sort(), ); expect(genClass('field_6').split(' ').sort()).toEqual( - 'untested_string'.split(' ').sort() + 'untested_string'.split(' ').sort(), ); }); }); @@ -95,10 +95,10 @@ describe('Utility: classnames', () => { // splitting and sorting to not rely on object order which is unspecified in the language expect(genClass('field_2').split(' ').sort()).toEqual( - 'invalid_string'.split(' ').sort() + 'invalid_string'.split(' ').sort(), ); expect(genClass('field_3').split(' ').sort()).toEqual( - ''.split(' ').sort() + ''.split(' ').sort(), ); }); }); @@ -120,10 +120,10 @@ describe('Utility: classnames', () => { // splitting and sorting to not rely on object order which is unspecified in the language expect(genClass('field_2').split(' ').sort()).toEqual( - ''.split(' ').sort() + ''.split(' ').sort(), ); expect(genClass('field_3').split(' ').sort()).toEqual( - ''.split(' ').sort() + ''.split(' ').sort(), ); }); }); diff --git a/packages/vest/src/exports/__tests__/parser.test.ts b/packages/vest/src/exports/__tests__/parser.test.ts index ac456cc90..fbf5fa61a 100644 --- a/packages/vest/src/exports/__tests__/parser.test.ts +++ b/packages/vest/src/exports/__tests__/parser.test.ts @@ -16,13 +16,13 @@ describe('parser.parse', () => { it('Should return true when provided field is failing', () => { expect(parse(suiteDummy.failing('username')).invalid('username')).toBe( - true + true, ); }); it('Should return false when provided field is passing', () => { expect(parse(suiteDummy.passing('username')).invalid('username')).toBe( - false + false, ); }); @@ -37,13 +37,13 @@ describe('parser.parse', () => { it('Should return true when provided field is failing', () => { expect( - parse(ser(suiteDummy.failing('username'))).invalid('username') + parse(ser(suiteDummy.failing('username'))).invalid('username'), ).toBe(true); }); it('Should return false when provided field is passing', () => { expect( - parse(ser(suiteDummy.passing('username'))).invalid('username') + parse(ser(suiteDummy.passing('username'))).invalid('username'), ).toBe(false); }); }); @@ -59,10 +59,10 @@ describe('parser.parse', () => { }); it('Should return true if provided field is tested', () => { expect(parse(suiteDummy.passing('username')).tested('username')).toBe( - true + true, ); expect(parse(suiteDummy.failing('username')).tested('username')).toBe( - true + true, ); }); @@ -76,10 +76,10 @@ describe('parser.parse', () => { }); it('Should return true if provided field is tested', () => { expect( - parse(ser(suiteDummy.passing('username'))).tested('username') + parse(ser(suiteDummy.passing('username'))).tested('username'), ).toBe(true); expect( - parse(ser(suiteDummy.failing('username'))).tested('username') + parse(ser(suiteDummy.failing('username'))).tested('username'), ).toBe(true); }); }); @@ -99,8 +99,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ).untested('untested') + })(), + ).untested('untested'), ).toBe(true); }); @@ -110,7 +110,7 @@ describe('parser.parse', () => { it('Should return false if provided field is tested', () => { expect(parse(suiteDummy.passing('username')).untested('username')).toBe( - false + false, ); }); @@ -128,21 +128,21 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ) - ).untested('untested') + })(), + ), + ).untested('untested'), ).toBe(true); }); it('Should return false if any field is tested', () => { expect(parse(ser(suiteDummy.passing('username'))).untested()).toBe( - false + false, ); }); it('Should return false if provided field is tested', () => { expect( - parse(ser(suiteDummy.passing('username'))).untested('username') + parse(ser(suiteDummy.passing('username'))).untested('username'), ).toBe(false); }); }); @@ -152,19 +152,19 @@ describe('parser.parse', () => { it('Should return true if all fields are passing', () => { expect(parse(suiteDummy.passing(['f1', 'f2', 'f3'])).valid()).toBe(true); expect(parse(suiteDummy.passing(['f1', 'f2', 'f3'])).valid('f2')).toBe( - true + true, ); }); it('Should return true if all required fields have been tested and are passing', () => { expect( - parse(suiteDummy.passingWithUntestedOptional('optional')).valid() + parse(suiteDummy.passingWithUntestedOptional('optional')).valid(), ).toBe(true); }); it('Should return true if all fields, including optional, pass', () => { expect(parse(suiteDummy.passingWithOptional('optional')).valid()).toBe( - true + true, ); }); @@ -193,8 +193,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ).valid() + })(), + ).valid(), ).toBe(false); }); @@ -206,8 +206,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(false); }); @@ -219,8 +219,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(true); }); @@ -230,8 +230,8 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(true); }); @@ -241,8 +241,8 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ).valid('f2') + })(), + ).valid('f2'), ).toBe(false); expect( parse( @@ -250,8 +250,8 @@ describe('parser.parse', () => { vest.test('f1', () => {}); vest.test('f2', () => {}); vest.test('f2', () => false); - })() - ).valid('f2') + })(), + ).valid('f2'), ).toBe(false); }); @@ -263,8 +263,8 @@ describe('parser.parse', () => { vest.warn(); return false; }); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(true); }); }); @@ -272,22 +272,24 @@ describe('parser.parse', () => { describe('Serialized Result', () => { it('Should return true if all fields are passing', () => { expect(parse(ser(suiteDummy.passing(['f1', 'f2', 'f3']))).valid()).toBe( - true + true, ); expect( - parse(ser(suiteDummy.passing(['f1', 'f2', 'f3']))).valid('f2') + parse(ser(suiteDummy.passing(['f1', 'f2', 'f3']))).valid('f2'), ).toBe(true); }); it('Should return true if all required fields have been tested and are passing', () => { expect( - parse(ser(suiteDummy.passingWithUntestedOptional('optional'))).valid() + parse( + ser(suiteDummy.passingWithUntestedOptional('optional')), + ).valid(), ).toBe(true); }); it('Should return true if all fields, including optional, pass', () => { expect( - parse(ser(suiteDummy.passingWithOptional('optional'))).valid() + parse(ser(suiteDummy.passingWithOptional('optional'))).valid(), ).toBe(true); }); @@ -301,7 +303,7 @@ describe('parser.parse', () => { it('Should return true if suite only has warnings', () => { expect(parse(ser(suiteDummy.warning(['f1', 'f2', 'f3']))).valid()).toBe( - true + true, ); }); @@ -319,9 +321,9 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ) - ).valid() + })(), + ), + ).valid(), ).toBe(false); }); @@ -334,9 +336,9 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(false); }); @@ -349,9 +351,9 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(true); }); @@ -362,9 +364,9 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(true); }); @@ -375,9 +377,9 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ) - ).valid('f2') + })(), + ), + ).valid('f2'), ).toBe(false); expect( parse( @@ -386,9 +388,9 @@ describe('parser.parse', () => { vest.test('f1', () => {}); vest.test('f2', () => {}); vest.test('f2', () => false); - })() - ) - ).valid('f2') + })(), + ), + ).valid('f2'), ).toBe(false); }); @@ -401,9 +403,9 @@ describe('parser.parse', () => { vest.warn(); return false; }); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(true); }); }); diff --git a/packages/vest/src/exports/__tests__/promisify.test.ts b/packages/vest/src/exports/__tests__/promisify.test.ts index 7385e5d72..7651940b6 100644 --- a/packages/vest/src/exports/__tests__/promisify.test.ts +++ b/packages/vest/src/exports/__tests__/promisify.test.ts @@ -18,8 +18,8 @@ describe('Utility: promisify', () => { vest.create( jest.fn(() => { dummyTest.failing('field_0'); - }) - ) + }), + ), ); validateAsync = promisify(validatorFn); }); @@ -52,7 +52,7 @@ describe('Utility: promisify', () => { vest.create(() => { dummyTest.failing('field_0'); done(); - }) + }), ); validateAsync(); })); diff --git a/packages/vest/src/exports/classnames.ts b/packages/vest/src/exports/classnames.ts index 5cc24f1c6..e052b46d3 100644 --- a/packages/vest/src/exports/classnames.ts +++ b/packages/vest/src/exports/classnames.ts @@ -8,7 +8,7 @@ import { ParsedVestObject, parse } from 'parser'; */ export default function classnames( res: SuiteSummary, - classes: SupportedClasses = {} + classes: SupportedClasses = {}, ): (fieldName: F) => string { const selectors = parse(res); diff --git a/packages/vest/src/exports/promisify.ts b/packages/vest/src/exports/promisify.ts index 101a86f9b..0672d0bc0 100644 --- a/packages/vest/src/exports/promisify.ts +++ b/packages/vest/src/exports/promisify.ts @@ -9,7 +9,7 @@ import { } from 'SuiteResultTypes'; function promisify( - validatorFn: (...args: any[]) => SuiteRunResult + validatorFn: (...args: any[]) => SuiteRunResult, ) { return (...args: any[]): Promise> => { invariant(isFunction(validatorFn), ErrorStrings.PROMISIFY_REQUIRE_FUNCTION); diff --git a/packages/vest/src/hooks/focused/focused.ts b/packages/vest/src/hooks/focused/focused.ts index 08bc45a92..a8fd22009 100644 --- a/packages/vest/src/hooks/focused/focused.ts +++ b/packages/vest/src/hooks/focused/focused.ts @@ -27,7 +27,7 @@ export type IsolateFocusedPayload = { export function IsolateFocused( focusMode: FocusModes, - match?: true | FieldExclusion + match?: true | FieldExclusion, ): TIsolateFocused { return Isolate.create(VestIsolateType.Focused, noop, { focusMode, @@ -39,7 +39,7 @@ export function IsolateFocused( export class FocusSelectors { static isSkipFocused( focus: Nullable, - fieldName?: TFieldName + fieldName?: TFieldName, ): boolean { return ( focus?.data.focusMode === FocusModes.SKIP && @@ -48,7 +48,7 @@ export class FocusSelectors { } static isOnlyFocused( focus: Nullable, - fieldName?: TFieldName + fieldName?: TFieldName, ): boolean { return ( focus?.data.focusMode === FocusModes.ONLY && hasFocus(focus, fieldName) diff --git a/packages/vest/src/hooks/focused/useHasOnliedTests.ts b/packages/vest/src/hooks/focused/useHasOnliedTests.ts index 0cffdd841..e4e7896ee 100644 --- a/packages/vest/src/hooks/focused/useHasOnliedTests.ts +++ b/packages/vest/src/hooks/focused/useHasOnliedTests.ts @@ -10,13 +10,13 @@ import { FocusSelectors } from 'focused'; */ export function useHasOnliedTests( testObject: TIsolateTest, - fieldName?: TFieldName + fieldName?: TFieldName, ): boolean { return isNotNullish( Walker.findClosest(testObject, (child: TIsolate) => { if (!FocusSelectors.isIsolateFocused(child)) return false; return FocusSelectors.isOnlyFocused(child, fieldName); - }) + }), ); } diff --git a/packages/vest/src/hooks/include.ts b/packages/vest/src/hooks/include.ts index 157fa1353..c279cf5eb 100644 --- a/packages/vest/src/hooks/include.ts +++ b/packages/vest/src/hooks/include.ts @@ -28,7 +28,7 @@ import { useHasOnliedTests } from 'useHasOnliedTests'; */ // @vx-allow use-use export function include( - fieldName: F + fieldName: F, ): { when: (condition: F | TFieldName | TDraftCondition) => void; } { @@ -49,7 +49,7 @@ export function include( // This callback will run as part of the "isExcluded" series of checks inclusion[fieldName] = function isIncluded( - currentNode: TIsolateTest + currentNode: TIsolateTest, ): boolean { if (isStringValue(condition)) { return useHasOnliedTests(currentNode, condition); @@ -57,7 +57,7 @@ export function include( return optionalFunctionValue( condition, - optionalFunctionValue(useCreateSuiteResult) + optionalFunctionValue(useCreateSuiteResult), ); }; } diff --git a/packages/vest/src/hooks/optional/__tests__/optional.test.ts b/packages/vest/src/hooks/optional/__tests__/optional.test.ts index 6351d3985..f5b722733 100644 --- a/packages/vest/src/hooks/optional/__tests__/optional.test.ts +++ b/packages/vest/src/hooks/optional/__tests__/optional.test.ts @@ -250,7 +250,7 @@ describe('optional hook', () => { expect(res.hasErrors('field_1')).toBe(false); expect(res.isValid('field_1')).toBe(true); expect(res.isValid()).toBe(true); - } + }, ); }); diff --git a/packages/vest/src/hooks/optional/omitOptionalFields.ts b/packages/vest/src/hooks/optional/omitOptionalFields.ts index fb0580514..88df38474 100644 --- a/packages/vest/src/hooks/optional/omitOptionalFields.ts +++ b/packages/vest/src/hooks/optional/omitOptionalFields.ts @@ -63,7 +63,7 @@ export function useOmitOptionalFields(): void { // Ge the optional configuration for the given field const optionalConfig = SuiteOptionalFields.getOptionalField( root, - fieldName + fieldName, ); // If the optional was set to a function or a boolean, run it and verify/omit the test diff --git a/packages/vest/src/hooks/optional/optional.ts b/packages/vest/src/hooks/optional/optional.ts index ac9bc745e..4f9cd0e08 100644 --- a/packages/vest/src/hooks/optional/optional.ts +++ b/packages/vest/src/hooks/optional/optional.ts @@ -9,7 +9,7 @@ import { TFieldName } from 'SuiteResultTypes'; // @vx-allow use-use export function optional( - optionals: OptionalsInput + optionals: OptionalsInput, ): void { const suiteRoot = VestRuntime.useAvailableRoot(); diff --git a/packages/vest/src/isolates/each.ts b/packages/vest/src/isolates/each.ts index be41b3ca9..4ca8c3421 100644 --- a/packages/vest/src/isolates/each.ts +++ b/packages/vest/src/isolates/each.ts @@ -18,11 +18,11 @@ import { IsolateEach } from 'IsolateEach'; */ export function each( list: T[], - callback: (arg: T, index: number) => void + callback: (arg: T, index: number) => void, ): void { invariant( isFunction(callback), - ErrorStrings.EACH_CALLBACK_MUST_BE_A_FUNCTION + ErrorStrings.EACH_CALLBACK_MUST_BE_A_FUNCTION, ); IsolateEach(() => { diff --git a/packages/vest/src/isolates/group.ts b/packages/vest/src/isolates/group.ts index 556d21619..01e91544c 100644 --- a/packages/vest/src/isolates/group.ts +++ b/packages/vest/src/isolates/group.ts @@ -7,7 +7,7 @@ import { VestIsolateType } from 'VestIsolateType'; export function group( groupName: G, - callback: CB + callback: CB, ): TIsolate; export function group(callback: CB): TIsolate; export function group( @@ -15,10 +15,7 @@ export function group( ): TIsolate { const [callback, groupName] = args.reverse() as [CB, G]; - return Isolate.create( - VestIsolateType.Group, - () => { - return SuiteContext.run({ ...(groupName && { groupName }) }, callback); - }, - ); + return Isolate.create(VestIsolateType.Group, () => { + return SuiteContext.run({ ...(groupName && { groupName }) }, callback); + }); } diff --git a/packages/vest/src/isolates/omitWhen.ts b/packages/vest/src/isolates/omitWhen.ts index 3003d8ecf..f99cfa7b3 100644 --- a/packages/vest/src/isolates/omitWhen.ts +++ b/packages/vest/src/isolates/omitWhen.ts @@ -20,7 +20,7 @@ import { useCreateSuiteResult } from 'suiteResult'; // @vx-allow use-use export function omitWhen( conditional: TDraftCondition, - callback: CB + callback: CB, ): void { Isolate.create(VestIsolateType.OmitWhen, () => { SuiteContext.run( @@ -29,10 +29,10 @@ export function omitWhen( useWithinActiveOmitWhen() || optionalFunctionValue( conditional, - optionalFunctionValue(useCreateSuiteResult) + optionalFunctionValue(useCreateSuiteResult), ), }, - callback + callback, ); }); } diff --git a/packages/vest/src/isolates/skipWhen.ts b/packages/vest/src/isolates/skipWhen.ts index 45e75c19b..37ff4cd18 100644 --- a/packages/vest/src/isolates/skipWhen.ts +++ b/packages/vest/src/isolates/skipWhen.ts @@ -19,7 +19,7 @@ import { useCreateSuiteResult } from 'suiteResult'; // @vx-allow use-use export function skipWhen( condition: TDraftCondition, - callback: CB + callback: CB, ): void { Isolate.create(VestIsolateType.SkipWhen, () => { SuiteContext.run( @@ -31,10 +31,10 @@ export function skipWhen( // Otherwise, we should skip the test if the conditional is true. optionalFunctionValue( condition, - optionalFunctionValue(useCreateSuiteResult) + optionalFunctionValue(useCreateSuiteResult), ), }, - callback + callback, ); }); } diff --git a/packages/vest/src/suite/__tests__/create.test.ts b/packages/vest/src/suite/__tests__/create.test.ts index 75ddfc131..71e861a72 100644 --- a/packages/vest/src/suite/__tests__/create.test.ts +++ b/packages/vest/src/suite/__tests__/create.test.ts @@ -22,9 +22,9 @@ describe('Test createSuite module', () => { value => { // @ts-expect-error - testing invalid input expect(() => create(value)).toThrow( - ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION + ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION, ); - } + }, ); describe('When suite name is provided', () => { diff --git a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts index c3c9c31d7..7fa355a3c 100644 --- a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts +++ b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts @@ -79,29 +79,29 @@ describe('Suite Selectors on Suite', () => { expect(res.hasWarnings('f4')).toEqual(suite.hasWarnings('f4')); expect(res.hasErrorsByGroup('g1')).toEqual(suite.hasErrorsByGroup('g1')); expect(res.hasErrorsByGroup('g1', 'f1')).toEqual( - suite.hasErrorsByGroup('g1', 'f1') + suite.hasErrorsByGroup('g1', 'f1'), ); expect(res.hasErrorsByGroup('g1', 'f2')).toEqual( - suite.hasErrorsByGroup('g1', 'f2') + suite.hasErrorsByGroup('g1', 'f2'), ); expect(res.hasErrorsByGroup('g1', 'f3')).toEqual( - suite.hasErrorsByGroup('g1', 'f3') + suite.hasErrorsByGroup('g1', 'f3'), ); expect(res.hasErrorsByGroup('g1', 'f4')).toEqual( - suite.hasErrorsByGroup('g1', 'f4') + suite.hasErrorsByGroup('g1', 'f4'), ); expect(res.getErrorsByGroup('g1')).toEqual(suite.getErrorsByGroup('g1')); expect(res.getErrorsByGroup('g1, f1')).toEqual( - suite.getErrorsByGroup('g1, f1') + suite.getErrorsByGroup('g1, f1'), ); expect(res.getErrorsByGroup('g1, f2')).toEqual( - suite.getErrorsByGroup('g1, f2') + suite.getErrorsByGroup('g1, f2'), ); expect(res.getErrorsByGroup('g1, f3')).toEqual( - suite.getErrorsByGroup('g1, f3') + suite.getErrorsByGroup('g1, f3'), ); expect(res.getErrorsByGroup('g1, f4')).toEqual( - suite.getErrorsByGroup('g1, f4') + suite.getErrorsByGroup('g1, f4'), ); expect(res.isValid()).toEqual(suite.isValid()); expect(res.isValid('f1')).toEqual(suite.isValid('f1')); diff --git a/packages/vest/src/suite/getTypedMethods.ts b/packages/vest/src/suite/getTypedMethods.ts index 8d21d25c6..5536e307a 100644 --- a/packages/vest/src/suite/getTypedMethods.ts +++ b/packages/vest/src/suite/getTypedMethods.ts @@ -17,7 +17,7 @@ import { TestMemo } from 'test.memo'; export function getTypedMethods< F extends TFieldName, - G extends TGroupName + G extends TGroupName, >(): TTypedMethods { return { group, @@ -60,5 +60,5 @@ export type TTypedMethods = { export type TDraftCondition< F extends TFieldName, - G extends TGroupName + G extends TGroupName, > = DynamicValue]>; diff --git a/packages/vest/src/suite/validateParams/validateSuiteParams.ts b/packages/vest/src/suite/validateParams/validateSuiteParams.ts index 692ac0e17..55345cfbc 100644 --- a/packages/vest/src/suite/validateParams/validateSuiteParams.ts +++ b/packages/vest/src/suite/validateParams/validateSuiteParams.ts @@ -2,13 +2,11 @@ import { CB, invariant, isFunction } from 'vest-utils'; import { ErrorStrings } from 'ErrorStrings'; - - export function validateSuiteCallback( - suiteCallback: T + suiteCallback: T, ): asserts suiteCallback is T { invariant( isFunction(suiteCallback), - ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION + ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION, ); } diff --git a/packages/vest/src/suiteResult/SummaryFailure.ts b/packages/vest/src/suiteResult/SummaryFailure.ts index fbbcc2c0f..4ea4981fc 100644 --- a/packages/vest/src/suiteResult/SummaryFailure.ts +++ b/packages/vest/src/suiteResult/SummaryFailure.ts @@ -9,11 +9,11 @@ export class SummaryFailure constructor( public fieldName: F, public message: string | undefined, - public groupName: G | undefined + public groupName: G | undefined, ) {} static fromTestObject( - testObject: TIsolateTest + testObject: TIsolateTest, ) { const { fieldName, message, groupName } = VestTest.getData(testObject); diff --git a/packages/vest/src/suiteResult/done/deferDoneCallback.ts b/packages/vest/src/suiteResult/done/deferDoneCallback.ts index 2258694c6..857dce482 100644 --- a/packages/vest/src/suiteResult/done/deferDoneCallback.ts +++ b/packages/vest/src/suiteResult/done/deferDoneCallback.ts @@ -5,7 +5,7 @@ import { TFieldName } from 'SuiteResultTypes'; export function useDeferDoneCallback( doneCallback: DoneCallback, - fieldName?: TFieldName + fieldName?: TFieldName, ): void { const [, setFieldCallbacks] = useFieldCallbacks(); const [, setDoneCallbacks] = useDoneCallbacks(); @@ -14,7 +14,7 @@ export function useDeferDoneCallback( setFieldCallbacks(fieldCallbacks => assign(fieldCallbacks, { [fieldName]: (fieldCallbacks[fieldName] || []).concat(doneCallback), - }) + }), ); return; diff --git a/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts b/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts index d6a9931ae..f224dfad1 100644 --- a/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts +++ b/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts @@ -13,12 +13,12 @@ import { export function shouldSkipDoneRegistration< F extends TFieldName, - G extends TGroupName + G extends TGroupName, >( callback: (res: SuiteResult) => void, fieldName: Maybe, - output: SuiteRunResult + output: SuiteRunResult, ): boolean { // If we do not have any test runs for the current field return !!( diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts index af312a626..d540edf58 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts @@ -29,7 +29,7 @@ describe.each(modes)('produce method: %s', mode => { describe('When fieldName passed', () => { it('Should return an empty array', () => { expect(getRes().getErrorsByGroup('group_name', 'field_name')).toEqual( - [] + [], ); }); }); @@ -59,7 +59,7 @@ describe.each(modes)('produce method: %s', mode => { dummyTest.passing(); }); expect(getRes().getErrorsByGroup('group_name', 'field_name')).toEqual( - [] + [], ); }); }); @@ -128,7 +128,7 @@ describe.each(modes)('produce method: %s', mode => { describe('When fieldName passed', () => { it('Should return an empty array', () => { expect( - getRes().getWarningsByGroup('group_name', 'field_name') + getRes().getWarningsByGroup('group_name', 'field_name'), ).toEqual([]); }); }); @@ -158,7 +158,7 @@ describe.each(modes)('produce method: %s', mode => { dummyTest.passing(); }); expect( - getRes().getWarningsByGroup('group_name', 'field_name') + getRes().getWarningsByGroup('group_name', 'field_name'), ).toEqual([]); }); }); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts index a2bfe9e85..ef5b2efa4 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts @@ -79,7 +79,7 @@ describe('hasErrorsByGroup', () => { }); }); expect(suite().hasErrorsByGroup(groupName, 'non_matching_field')).toBe( - false + false, ); }); }); @@ -167,7 +167,7 @@ describe('hasWarningsByGroup', () => { }); }); expect( - suite().hasWarningsByGroup(groupName, 'non_matching_field') + suite().hasWarningsByGroup(groupName, 'non_matching_field'), ).toBe(false); }); }); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts index efa2b3b60..c5e4a5c7a 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts @@ -268,7 +268,7 @@ describe('isValid', () => { return true; }); }); - })().isValid() + })().isValid(), ).toBe(false); }); }); @@ -279,7 +279,7 @@ describe('isValid', () => { create(() => { skip('field_1'); test('field_1', () => true); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(false); }); @@ -287,7 +287,7 @@ describe('isValid', () => { expect( create(() => { test('field_1', () => {}); - })().isValid('field 2') + })().isValid('field 2'), ).toBe(false); }); @@ -302,7 +302,7 @@ describe('isValid', () => { return true; }); }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(false); }); @@ -312,7 +312,7 @@ describe('isValid', () => { test('field_1', () => { return false; }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(false); }); @@ -322,7 +322,7 @@ describe('isValid', () => { test('field_1', () => { return true; }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(true); }); @@ -333,7 +333,7 @@ describe('isValid', () => { warn(); return false; }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(true); }); @@ -344,7 +344,7 @@ describe('isValid', () => { skipWhen(true, () => { test('field_1', () => false); }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(true); }); }); @@ -354,7 +354,7 @@ describe('isValid', () => { expect( create(() => { test('field_1', () => true); - })().isValid('field_2') + })().isValid('field_2'), ).toBe(false); }); }); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts index 78a75f0f1..ac88b0bd9 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts @@ -50,19 +50,19 @@ describe('isValidByGroup', () => { it('Should return false when an optional test has errors', () => { expect(suite('field_2').isValidByGroup(GROUP_NAME)).toBe(false); expect(suite('field_2').isValidByGroup(GROUP_NAME, 'field_1')).toBe( - false + false, ); }); it('Should return false when a required test has errors', () => { expect(suite('field_1').isValidByGroup(GROUP_NAME)).toBe(false); expect(suite('field_1').isValidByGroup(GROUP_NAME, 'field_2')).toBe( - false + false, ); }); it('Should return false when the queried field is not optional and has errors', () => { expect(suite('field_2').isValidByGroup(GROUP_NAME, 'field_2')).toBe( - false + false, ); }); @@ -147,7 +147,7 @@ describe('isValidByGroup', () => { }); it('Should return false', () => { expect(suite(['field_2', 'field_3']).isValidByGroup(GROUP_NAME)).toBe( - false + false, ); }); }); @@ -310,7 +310,7 @@ describe('isValidByGroup', () => { }); }); }); - })().isValidByGroup(GROUP_NAME) + })().isValidByGroup(GROUP_NAME), ).toBe(false); }); }); @@ -323,7 +323,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => true); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(false); }); @@ -333,7 +333,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => {}); }); - })().isValidByGroup(GROUP_NAME, 'field 2') + })().isValidByGroup(GROUP_NAME, 'field 2'), ).toBe(false); }); @@ -350,7 +350,7 @@ describe('isValidByGroup', () => { }); }); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(false); }); @@ -360,7 +360,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => false); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(false); }); @@ -370,7 +370,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => {}); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(true); }); @@ -383,7 +383,7 @@ describe('isValidByGroup', () => { return false; }); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(true); }); @@ -396,7 +396,7 @@ describe('isValidByGroup', () => { test('field_1', () => false); }); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(true); }); }); @@ -408,7 +408,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => true); }); - })().isValidByGroup(GROUP_NAME, 'field_2') + })().isValidByGroup(GROUP_NAME, 'field_2'), ).toBe(false); }); }); @@ -435,7 +435,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => false); }); - })().isValidByGroup(GROUP_NAME) + })().isValidByGroup(GROUP_NAME), ).toBe(true); }); }); diff --git a/packages/vest/src/suiteResult/selectors/collectFailures.ts b/packages/vest/src/suiteResult/selectors/collectFailures.ts index 798d69c70..cc513060d 100644 --- a/packages/vest/src/suiteResult/selectors/collectFailures.ts +++ b/packages/vest/src/suiteResult/selectors/collectFailures.ts @@ -13,7 +13,7 @@ import { export function gatherFailures( testGroup: TestsContainer, severityKey: Severity, - fieldName?: TFieldName + fieldName?: TFieldName, ): string[] | FailureMessages { return fieldName ? getByFieldName(testGroup, severityKey, fieldName) @@ -23,14 +23,14 @@ export function gatherFailures( function getByFieldName( testGroup: TestsContainer, severityKey: Severity, - fieldName: TFieldName + fieldName: TFieldName, ): string[] { return testGroup?.[fieldName]?.[severityKey] || []; } function collectAll( testGroup: TestsContainer, - severityKey: Severity + severityKey: Severity, ): FailureMessages { const output: FailureMessages = {}; diff --git a/packages/vest/src/testUtils/partition.ts b/packages/vest/src/testUtils/partition.ts index 8af8050db..8dbbcbaed 100644 --- a/packages/vest/src/testUtils/partition.ts +++ b/packages/vest/src/testUtils/partition.ts @@ -1,12 +1,12 @@ export default function partition( array: T[], - predicate: (value: T, _index: number, array: T[]) => boolean + predicate: (value: T, _index: number, array: T[]) => boolean, ): [T[], T[]] { return array.reduce( (partitions: [T[], T[]], value, number) => { partitions[predicate(value, number, array) ? 0 : 1].push(value); return partitions; }, - [[], []] + [[], []], ); } diff --git a/packages/vest/src/testUtils/suiteDummy.ts b/packages/vest/src/testUtils/suiteDummy.ts index 59917a1d4..8a0f83b2b 100644 --- a/packages/vest/src/testUtils/suiteDummy.ts +++ b/packages/vest/src/testUtils/suiteDummy.ts @@ -31,7 +31,7 @@ export function passing(fields?: OneOrMoreOf) { export function passingWithUntestedOptional( optionals: OneOrMoreOf = 'optional_field', - required: OneOrMoreOf = 'field_1' + required: OneOrMoreOf = 'field_1', ) { return create(() => { optional(optionals); @@ -49,7 +49,7 @@ export function passingWithUntestedOptional( export function passingWithOptional( optionals: OneOrMoreOf = 'optional_field', - required: OneOrMoreOf = 'field_1' + required: OneOrMoreOf = 'field_1', ) { return create(() => { optional(optionals); @@ -66,7 +66,7 @@ export function passingWithOptional( export function failingOptional( optionals: OneOrMoreOf = 'optional_field', - required: OneOrMoreOf = 'field_1' + required: OneOrMoreOf = 'field_1', ) { return create(() => { optional(optionals); @@ -90,14 +90,14 @@ export function untested(fields?: OneOrMoreOf) { function createSuiteRunResult( fieldNames: Maybe, - callback: (_fieldName?: string) => void + callback: (_fieldName?: string) => void, ) { return createSuite(fieldNames, callback)(); } function createSuite( fieldNames: Maybe = 'field_1', - callback: (_fieldName?: string) => void + callback: (_fieldName?: string) => void, ) { return create(() => { asArray(fieldNames).forEach(fieldName => callback(fieldName)); @@ -105,7 +105,7 @@ function createSuite( } export function ser( - res: SuiteResult + res: SuiteResult, ) { return JSON.parse(JSON.stringify(res)); } diff --git a/packages/vest/src/testUtils/testDummy.ts b/packages/vest/src/testUtils/testDummy.ts index ab2f1fe85..fa018acaa 100644 --- a/packages/vest/src/testUtils/testDummy.ts +++ b/packages/vest/src/testUtils/testDummy.ts @@ -10,14 +10,14 @@ import { test as vestTest, warn } from 'vest'; const testDummy = () => { const failing = ( name: string = faker.lorem.word(), - message: string = faker.lorem.words() + message: string = faker.lorem.words(), ) => { const to = vestTest( name, message, jest.fn(() => { throw new Error(); - }) + }), ); return to; @@ -25,7 +25,7 @@ const testDummy = () => { const failingWarning = ( name = faker.lorem.word(), - message = faker.lorem.words() + message = faker.lorem.words(), ) => { const to = vestTest( name, @@ -33,7 +33,7 @@ const testDummy = () => { jest.fn(() => { warn(); throw new Error(); - }) + }), ); return to; @@ -41,7 +41,7 @@ const testDummy = () => { const passing = ( name = faker.lorem.word(), - message = faker.lorem.words() + message = faker.lorem.words(), ) => { const to = vestTest(name, message, jest.fn()); @@ -50,21 +50,21 @@ const testDummy = () => { const passingWarning = ( name = faker.lorem.word(), - message = faker.lorem.words() + message = faker.lorem.words(), ) => { const to = vestTest( name, message, jest.fn(() => { warn(); - }) + }), ); return to; }; const failingAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -73,13 +73,13 @@ const testDummy = () => { () => new Promise((_, reject) => { setTimeout(reject, time); - }) - ) + }), + ), ); const failingWarningAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -89,12 +89,12 @@ const testDummy = () => { return new Promise((_, reject) => { setTimeout(reject, time); }); - }) + }), ); const passingAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -103,13 +103,13 @@ const testDummy = () => { () => new Promise(resolve => { setTimeout(resolve, time); - }) - ) + }), + ), ); const passingWarningAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -119,7 +119,7 @@ const testDummy = () => { return new Promise(resolve => { setTimeout(resolve, time); }); - }) + }), ); return { diff --git a/packages/vest/src/testUtils/vestMocks.ts b/packages/vest/src/testUtils/vestMocks.ts index d6804e041..c33cbe3ec 100644 --- a/packages/vest/src/testUtils/vestMocks.ts +++ b/packages/vest/src/testUtils/vestMocks.ts @@ -4,7 +4,7 @@ import { IsolateTestBase, IsolateTestPayload, TIsolateTest } from 'IsolateTest'; import { VestIsolateType } from 'VestIsolateType'; export function mockIsolateTest( - payload: Partial = {} + payload: Partial = {}, ): TIsolateTest { const isolate = genTestIsolate({ ...IsolateTestBase(), diff --git a/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts b/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts index 98b42ae2b..ab43aa57f 100644 --- a/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts +++ b/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts @@ -26,7 +26,7 @@ export class IsolateInspector { } static allowsReorder>( - isolate: Nullable + isolate: Nullable, ): boolean { return isolate?.allowReorder === true; } @@ -40,7 +40,7 @@ export class IsolateInspector { static getChildByKey( isolate: Nullable, - key: string + key: string, ): Nullable { if (isNullish(isolate)) { return null; diff --git a/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts b/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts index 119e0f9f1..37c444d73 100644 --- a/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts +++ b/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts @@ -5,21 +5,21 @@ import { IsolateKeys } from 'IsolateKeys'; export function isIsolateType( node: Maybe, - type: string + type: string, ): node is I { return node?.[IsolateKeys.Type] === type; } export function isSameIsolateType( a: A, - b: B + b: B, ): boolean { return isIsolateType(a, b[IsolateKeys.Type]); } export function isSameIsolateIdentity( a: A, - b: B + b: B, ): boolean { return Object.is(a, b) || (isSameIsolateType(a, b) && a.key === b.key); } diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts index b34a9c6ba..a151b7ffc 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts @@ -39,7 +39,7 @@ describe('Isolate', () => { () => { return 'foo'; }, - {} + {}, ); }); expect(isolate.output).toBe('foo'); diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts index 61ee003bc..e18a8d9e5 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts @@ -32,15 +32,15 @@ describe('AsyncIsolate', () => { expect(root?.children?.[0].parent).toBe(root); expect(root?.children?.[0]?.children?.[0]?.$type).toBe('UGrandChild_1'); expect(root?.children?.[0]?.children?.[0].parent).toBe( - root?.children?.[0] + root?.children?.[0], ); expect(root?.children?.[0]?.children?.[1]?.$type).toBe('UGrandChild_2'); expect(root?.children?.[0]?.children?.[1].parent).toBe( - root?.children?.[0] + root?.children?.[0], ); expect(root?.children?.[0]?.children?.[2]?.$type).toBe('UGrandChild_3'); expect(root?.children?.[0]?.children?.[2].parent).toBe( - root?.children?.[0] + root?.children?.[0], ); expect(root).toMatchSnapshot(); @@ -88,6 +88,6 @@ async function genChildren() { Isolate.create('UGrandChild_1', () => {}); Isolate.create('UGrandChild_2', () => {}); Isolate.create('UGrandChild_3', () => {}); - }) + }), ); } diff --git a/packages/vestjs-runtime/src/VestRuntime.ts b/packages/vestjs-runtime/src/VestRuntime.ts index 7c4506268..402816a46 100644 --- a/packages/vestjs-runtime/src/VestRuntime.ts +++ b/packages/vestjs-runtime/src/VestRuntime.ts @@ -76,7 +76,7 @@ export function useXAppData() { export function createRef( Reconciler: IRecociler, - setter: DynamicValue> + setter: DynamicValue>, ): StateRefType { return Object.freeze({ Bus: bus.createBus(), diff --git a/vx/cli.js b/vx/cli.js index cdb25d88a..ecb606c08 100755 --- a/vx/cli.js +++ b/vx/cli.js @@ -68,14 +68,14 @@ logger.info( joinTruthy([ `Running command ${command}`, package && `for package ${package}`, - ]) + ]), ); ctx.withPackage(package, () => commands[command]({ fastBuild, cliOptions: cliOptions.join(' '), - }) + }), ); function insidePackageDir() { diff --git a/vx/commands/dev/dev.js b/vx/commands/dev/dev.js index cfa48789e..3efa28a32 100644 --- a/vx/commands/dev/dev.js +++ b/vx/commands/dev/dev.js @@ -5,7 +5,7 @@ module.exports = () => { exec( `${vxPath.vxRoot()}/node_modules/.bin/onchange -d 5000 -i -k ${vxPath.packageSrc( '*', - '**/*.ts' - )} ${vxPath.packageSrc('*', '**/*.ts')} -- vx prepare` + '**/*.ts', + )} ${vxPath.packageSrc('*', '**/*.ts')} -- vx prepare`, ); }; diff --git a/vx/commands/init/prompt/index.js b/vx/commands/init/prompt/index.js index 63aa6af9b..d32a4fbd1 100644 --- a/vx/commands/init/prompt/index.js +++ b/vx/commands/init/prompt/index.js @@ -81,7 +81,7 @@ function writeEntryPoint(packagePath, packageName) { fsExtra.writeFileSync( vxPath.packageSrc(packageName, `${packageName}.ts`), `export const main = () => "${packageName}";`, - 'utf8' + 'utf8', ); } @@ -93,7 +93,7 @@ function updateValues(packagePath, config) { Object.keys(configMapping).forEach(key => { content = content.replace( new RegExp(`{{${key}}}`, 'g'), - config[configMapping[key]] ?? configMapping[key] + config[configMapping[key]] ?? configMapping[key], ); }); diff --git a/vx/commands/test/test.js b/vx/commands/test/test.js index 241cff736..359132096 100644 --- a/vx/commands/test/test.js +++ b/vx/commands/test/test.js @@ -7,7 +7,7 @@ const vxPath = require('vx/vxPath'); const configOpt = `--config ${path.resolve( vxPath.JEST_CONFIG_PATH, - opts.fileNames.JEST_CONFIG + opts.fileNames.JEST_CONFIG, )}`; function test({ cliOptions }) { diff --git a/vx/config/jest/jest.config.js b/vx/config/jest/jest.config.js index e5eba8c46..4b19e3590 100644 --- a/vx/config/jest/jest.config.js +++ b/vx/config/jest/jest.config.js @@ -13,16 +13,16 @@ const setupPerPackage = glob.sync( vxPath.packageConfigPath( usePackage() ?? '*', opts.dir.JEST, - opts.fileNames.JEST_SETUP - ) + opts.fileNames.JEST_SETUP, + ), ); const setupAfterEnvPerPackage = glob.sync( vxPath.packageConfigPath( usePackage() ?? '*', opts.dir.JEST, - opts.fileNames.JEST_SETUP_AFTER_ENV - ) + opts.fileNames.JEST_SETUP_AFTER_ENV, + ), ); const projects = packageNames.list.map(packageName => ({ @@ -52,7 +52,7 @@ function baseConfig(packageName) { setupFilesAfterEnv: [ path.resolve( vxPath.JEST_CONFIG_PATH, - opts.fileNames.JEST_SETUP_AFTER_ENV + opts.fileNames.JEST_SETUP_AFTER_ENV, ), ].concat(setupAfterEnvPerPackage), testEnvironment: 'node', @@ -84,6 +84,6 @@ function genNameMapper(modules) { Object.assign(aliases, { [`^${name}$`]: absolute, }), - {} + {}, ); } diff --git a/vx/config/jest/jest.setupAfterEnv.ts b/vx/config/jest/jest.setupAfterEnv.ts index 034ac71e4..69b4d5ecf 100644 --- a/vx/config/jest/jest.setupAfterEnv.ts +++ b/vx/config/jest/jest.setupAfterEnv.ts @@ -5,7 +5,7 @@ import './globals.d'; // eslint-disable-next-line complexity const isDeepCopyOf = ( source: any, - clone: any + clone: any, ): { pass: boolean; message: () => string } => { const queue = [[source, clone]]; @@ -29,7 +29,7 @@ const isDeepCopyOf = ( pass: false, message: () => `Source and clone are the same object. Expected a deep copy. ${JSON.stringify( - source + source, )}===${JSON.stringify(clone)}`, }; } @@ -44,7 +44,7 @@ const isDeepCopyOf = ( pass: false, message: () => `Source and clone are not of the same type: ${JSON.stringify( - source + source, )} does not equal ${JSON.stringify(clone)}`, }; } @@ -56,7 +56,7 @@ const isDeepCopyOf = ( pass: false, message: () => `source and clone arrays are not identical. ${JSON.stringify( - source + source, )} does not equal ${JSON.stringify(clone)}`, }; } diff --git a/vx/config/rollup/format.js b/vx/config/rollup/format.js index 2fa630b96..f8945b361 100644 --- a/vx/config/rollup/format.js +++ b/vx/config/rollup/format.js @@ -7,7 +7,7 @@ const format = [].concat( opts.format.CJS, opts.format.ES, opts.format.UMD, - ] + ], ); const disallowExternals = format === opts.format.UMD; diff --git a/vx/config/rollup/getPlugins.js b/vx/config/rollup/getPlugins.js index 1b982fb33..e4b9ddbe7 100644 --- a/vx/config/rollup/getPlugins.js +++ b/vx/config/rollup/getPlugins.js @@ -42,7 +42,7 @@ module.exports = function getPlugins({ packageName, opts.dir.TYPES, namespace, - moduleName + '.d.ts' + moduleName + '.d.ts', ); if (kind === 'declaration') return basePath; @@ -82,7 +82,7 @@ module.exports = function getPlugins({ terser(), handleExports({ namespace }), addModulePackageJson(), - addCJSPackageJson() + addCJSPackageJson(), ); } diff --git a/vx/config/rollup/plugins/addCJSPackageJson.js b/vx/config/rollup/plugins/addCJSPackageJson.js index e68e41019..0b1efb152 100644 --- a/vx/config/rollup/plugins/addCJSPackageJson.js +++ b/vx/config/rollup/plugins/addCJSPackageJson.js @@ -16,7 +16,7 @@ function addEsPackageJson() { const packageJsonPath = path.join( path.dirname(file), - opts.fileNames.PACKAGE_JSON + opts.fileNames.PACKAGE_JSON, ); if (fse.existsSync(packageJsonPath)) { diff --git a/vx/config/rollup/plugins/addModulePackageJson.js b/vx/config/rollup/plugins/addModulePackageJson.js index cbe3be09d..0a1d21030 100644 --- a/vx/config/rollup/plugins/addModulePackageJson.js +++ b/vx/config/rollup/plugins/addModulePackageJson.js @@ -16,7 +16,7 @@ function addEsPackageJson() { const packageJsonPath = path.join( path.dirname(file), - opts.fileNames.PACKAGE_JSON + opts.fileNames.PACKAGE_JSON, ); if (fse.existsSync(packageJsonPath)) { diff --git a/vx/config/rollup/plugins/handleExports.js b/vx/config/rollup/plugins/handleExports.js index 0d5ce6a75..22b992d62 100644 --- a/vx/config/rollup/plugins/handleExports.js +++ b/vx/config/rollup/plugins/handleExports.js @@ -41,12 +41,12 @@ function writeEntry(name, namespace) { if (process.env.NODE_ENV === '${opts.env.PRODUCTION}') { module.exports = require('${prefix}/${path.relative( dist(), - dist(exportName(name, opts.env.PRODUCTION)) + dist(exportName(name, opts.env.PRODUCTION)), )}'); } else { module.exports = require('${prefix}/${path.relative( dist(), - dist(exportName(name, opts.env.DEVELOPMENT)) + dist(exportName(name, opts.env.DEVELOPMENT)), )}'); }`; @@ -77,7 +77,7 @@ function writePackageJson(name, exportPath, { namespace } = {}) { pkgJson, { spaces: 2, - } + }, ); } @@ -183,7 +183,7 @@ function genExportedFilesInMainPackageJson() { currentModule, genMainPackageJSONFileExports(moduleName, { namespace, - }) + }), ); return modules; @@ -192,7 +192,7 @@ function genExportedFilesInMainPackageJson() { function genMainPackageJSONFileExports( moduleName, - { env = opts.env.PRODUCTION, namespace = undefined } + { env = opts.env.PRODUCTION, namespace = undefined }, ) { const prefix = '.'; const cjsPath = genDistPath(moduleName, { @@ -261,7 +261,7 @@ function genDistPath( env = opts.env.PRODUCTION, format = opts.format.CJS, prefix, - } + }, ) { return joinPath( // add nesting level @@ -271,7 +271,7 @@ function genDistPath( format, namespace, exportName(moduleName, env), - ]) + ]), ); } @@ -283,7 +283,7 @@ function genTypesPath(moduleName, { namespace = undefined, prefix }) { opts.dir.TYPES, namespace, fileName(moduleName, 'd.ts'), - ]) + ]), ); } diff --git a/vx/config/rollup/rollup.config.cjs b/vx/config/rollup/rollup.config.cjs index ae39a3ac0..8517b6b1a 100644 --- a/vx/config/rollup/rollup.config.cjs +++ b/vx/config/rollup/rollup.config.cjs @@ -16,7 +16,7 @@ const { usePackage } = require('vx/vxContext'); const vxPath = require('vx/vxPath'); const fastBuild = JSON.parse( - process.env.ROLLUP_WATCH ?? process.env.VX_FAST_BUILD ?? false + process.env.ROLLUP_WATCH ?? process.env.VX_FAST_BUILD ?? false, ); module.exports = commandLineArgs => { @@ -42,10 +42,10 @@ module.exports = commandLineArgs => { `Invalid build entry: ${buildEntry}. Must be one of: ${[ opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN, opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS, - ].join(', ')}` + ].join(', ')}`, ); } - }) + }), ); }; @@ -72,14 +72,14 @@ function genBaseConfig({ // This turns the installed "internal" dependencies into external dependencies external: [ ...Object.keys( - disallowExternals ? {} : packageJson()?.dependencies ?? {} + disallowExternals ? {} : packageJson()?.dependencies ?? {}, ), moduleName === usePackage() ? null : usePackage(), ].filter(Boolean), input: getInputFile(packageName, moduleName, namespace), output: format.map(format => - genOutput({ env, format, moduleName, namespace }) + genOutput({ env, format, moduleName, namespace }), ), plugins: getPlugins({ env, moduleName, namespace, packageName }), }; @@ -89,7 +89,7 @@ function genBaseConfig({ function genExportsConfig(pkgName, env) { return listExportedModules(pkgName).map(([moduleName, namespace]) => - genBaseConfig({ env, moduleName, namespace }) + genBaseConfig({ env, moduleName, namespace }), ); } @@ -107,7 +107,7 @@ function genOutput({ // creates "globals" from the installed internal packages const globals = Object.keys( - disallowExternals ? {} : packageJson()?.dependencies ?? {} + disallowExternals ? {} : packageJson()?.dependencies ?? {}, ).reduce((g, c) => Object.assign(g, { [c]: c }), { ...{ [usePackage()]: usePackage() }, }); @@ -118,7 +118,7 @@ function genOutput({ usePackage(), format, namespace, - joinTruthy([moduleName, env, 'js'], '.') + joinTruthy([moduleName, env, 'js'], '.'), ), format, globals, @@ -128,7 +128,7 @@ function genOutput({ function getInputFile( packageName = usePackage(), moduleName = usePackage(), - namespace + namespace, ) { const moduleToResolve = getExportedModuleNames(namespace, moduleName); const packageModules = pathsPerPackage.packages[packageName]; diff --git a/vx/exec.js b/vx/exec.js index df7017e51..52e13c1d8 100644 --- a/vx/exec.js +++ b/vx/exec.js @@ -12,7 +12,7 @@ function exec( throwOnFailure = false, silent = false, raw = false, - } = {} + } = {}, ) { const cmd = joinTruthy(command?.flat?.() ?? command, ' '); diff --git a/vx/packageExports.js b/vx/packageExports.js index 09f730905..e1146942f 100644 --- a/vx/packageExports.js +++ b/vx/packageExports.js @@ -12,5 +12,5 @@ module.exports = packageNames.list.reduce( .sync(vxPath.packageSrcExports(packageName, '*.ts')) .map(packageExport => path.basename(packageExport, '.ts')), }), - {} + {}, ); diff --git a/vx/packageNames.js b/vx/packageNames.js index 6e41cfb42..8d7516a33 100644 --- a/vx/packageNames.js +++ b/vx/packageNames.js @@ -16,7 +16,7 @@ module.exports = Object.defineProperty( get: () => { return usePackage(); }, - } + }, ); packageList.pairs.forEach(([name, path]) => { diff --git a/vx/scripts/genTsConfig.js b/vx/scripts/genTsConfig.js index fa312219c..6b8d15a84 100644 --- a/vx/scripts/genTsConfig.js +++ b/vx/scripts/genTsConfig.js @@ -27,7 +27,7 @@ module.exports = function genTsConfig() { if (isConfigEqual(tsConfigPath, tsConfig)) { logger.log( - `✅ tsConfig for package '${packageName}' is up to date. Skipping.` + `✅ tsConfig for package '${packageName}' is up to date. Skipping.`, ); return; } diff --git a/vx/scripts/release/depsTree.js b/vx/scripts/release/depsTree.js index e1cf50bb3..af8501c6a 100644 --- a/vx/scripts/release/depsTree.js +++ b/vx/scripts/release/depsTree.js @@ -25,7 +25,7 @@ const buildDepsMemo = memoize(function (package, deps) { function buildDepsTree() { return packageList.names.reduce( (deps, packageName) => buildDepsMemo(packageName, deps), - {} + {}, ); } @@ -34,7 +34,7 @@ function sortDependencies(packagesList) { const deps = buildDepsTree(); return packagesList.sort( - (a, b) => countMaxDepth(deps[b]) - countMaxDepth(deps[a]) + (a, b) => countMaxDepth(deps[b]) - countMaxDepth(deps[a]), ); } diff --git a/vx/scripts/release/genDiffData.js b/vx/scripts/release/genDiffData.js index 39cb8f742..bf9a003bf 100644 --- a/vx/scripts/release/genDiffData.js +++ b/vx/scripts/release/genDiffData.js @@ -36,8 +36,8 @@ function genDiffData(commits) { versionToPublish: isReleaseKeepVersionBranch ? version : tag - ? tagId - : nextVersion, + ? tagId + : nextVersion, }; } diff --git a/vx/scripts/release/github/commitIgnorePattern.js b/vx/scripts/release/github/commitIgnorePattern.js index 6683bfc39..450b48458 100644 --- a/vx/scripts/release/github/commitIgnorePattern.js +++ b/vx/scripts/release/github/commitIgnorePattern.js @@ -1,7 +1,7 @@ const IGNORE_KEYWORDS = ['docs', 'conf', 'ci', 'build']; const IGNORE_PATTERN = new RegExp( `${IGNORE_KEYWORDS.join('|')}:|dependabot`, - 'i' + 'i', ); module.exports = IGNORE_PATTERN; diff --git a/vx/scripts/release/packagesToRelease.js b/vx/scripts/release/packagesToRelease.js index 50a3e3fb3..7a6b00238 100644 --- a/vx/scripts/release/packagesToRelease.js +++ b/vx/scripts/release/packagesToRelease.js @@ -30,8 +30,8 @@ function packagesToRelease() { } else { logger.info( `💡 The following packages were changed: \n - ${changedPackagesArray.join( - '\n - ' - )}\n` + '\n - ', + )}\n`, ); } @@ -59,7 +59,7 @@ function packagesToRelease() { logger.info( `🧱 The following packages did not change, but will be released because they are indirectly impacted by changes: \n - ${[ ...unchangedDependents, - ].join('\n - ')} \n` + ].join('\n - ')} \n`, ); } @@ -67,8 +67,8 @@ function packagesToRelease() { logger.info( `✅ The packages will be released in the following order: \n - ${allPackagesToRelease.join( - '\n - ' - )}\n` + '\n - ', + )}\n`, ); return { diff --git a/vx/scripts/release/steps/commitChangesToGit.js b/vx/scripts/release/steps/commitChangesToGit.js index ceea105d3..7b69eee4d 100644 --- a/vx/scripts/release/steps/commitChangesToGit.js +++ b/vx/scripts/release/steps/commitChangesToGit.js @@ -15,12 +15,12 @@ const vxPath = require('vx/vxPath'); const RELEASE_SCRIPTS = path.resolve( vxPath.VX_SCRIPTS_PATH, 'release', - 'steps' + 'steps', ); const PUSH_TO_LATEST_BRANCH = path.resolve( RELEASE_SCRIPTS, - 'push_to_latest_branch.sh' + 'push_to_latest_branch.sh', ); const CREATE_GIT_TAG = path.resolve(RELEASE_SCRIPTS, 'create_git_tag.sh'); @@ -66,7 +66,7 @@ function filterChangedPackages(commits) { function createCommitMessage(changedPackages) { const msg = changedPackages .map( - packageName => `[${packageName}]: (${packageJson(packageName).version})` + packageName => `[${packageName}]: (${packageJson(packageName).version})`, ) .join(', '); diff --git a/vx/scripts/release/steps/publishPackage.js b/vx/scripts/release/steps/publishPackage.js index 07374604b..a2b1ad503 100644 --- a/vx/scripts/release/steps/publishPackage.js +++ b/vx/scripts/release/steps/publishPackage.js @@ -41,14 +41,14 @@ function execCommandWithGitConfig(command) { logger.info( `Setting git config: Email "${EMAIL_ADDRESS}" - Name "${GIT_NAME}"` + Name "${GIT_NAME}"`, ); exec( `git config --global user.email "${EMAIL_ADDRESS}" git config --global user.name "${GIT_NAME}" ${joinTruthy(command, ' ')}`, - { exitOnFailure: false } + { exitOnFailure: false }, ); } diff --git a/vx/scripts/release/steps/setNextVersion.js b/vx/scripts/release/steps/setNextVersion.js index 15aa8fd52..028cbe434 100644 --- a/vx/scripts/release/steps/setNextVersion.js +++ b/vx/scripts/release/steps/setNextVersion.js @@ -27,7 +27,7 @@ function setNextVersion({ changeLevel: ${changeLevel} tagId: ${tagId} tag: ${tag} - versionToPublish: ${versionToPublish}` + versionToPublish: ${versionToPublish}`, ); return; } @@ -39,7 +39,7 @@ function setNextVersion({ existingPkgJson.version = versionToPublish; logger.info( - `🔢 Setting next version for ${usePackage()}. From ${prevVersion} to ${versionToPublish}` + `🔢 Setting next version for ${usePackage()}. From ${prevVersion} to ${versionToPublish}`, ); writeJSONSync(vxPath.packageJson(packageName), nextPackageJson, { @@ -50,7 +50,7 @@ function setNextVersion({ if (updated.version !== versionToPublish) { logger.error( - `🚨 Failed to update ${usePackage()} version to: ` + versionToPublish + `🚨 Failed to update ${usePackage()} version to: ` + versionToPublish, ); return process.exit(1); } diff --git a/vx/scripts/release/steps/updateLocalDepsToLatest.js b/vx/scripts/release/steps/updateLocalDepsToLatest.js index d37cbb2ad..1f64239f8 100644 --- a/vx/scripts/release/steps/updateLocalDepsToLatest.js +++ b/vx/scripts/release/steps/updateLocalDepsToLatest.js @@ -38,8 +38,8 @@ module.exports = function updateLocalDepsToLatest() { deps[name] = isNextBranch ? TAG_NEXT : isIntegrationBranch - ? TAG_DEV - : depPkgJson.version; + ? TAG_DEV + : depPkgJson.version; } else { deps[name] = isNextBranch || isIntegrationBranch diff --git a/vx/util/pathsPerPackage.js b/vx/util/pathsPerPackage.js index cd024647e..fe7908c4b 100644 --- a/vx/util/pathsPerPackage.js +++ b/vx/util/pathsPerPackage.js @@ -65,11 +65,11 @@ function findDuplicates() { const duplicatesPerPackage = []; for (const [packageName, { duplicates }] of Object.entries( - duplicatesContainer + duplicatesContainer, )) { if (duplicates.size > 0) { duplicatesPerPackage.push( - `${packageName}: ${[...duplicates].map(dup => `\n -${dup}`).join('')}` + `${packageName}: ${[...duplicates].map(dup => `\n -${dup}`).join('')}`, ); } } @@ -77,8 +77,8 @@ function findDuplicates() { if (duplicatesPerPackage.length > 0) { throw new Error( `VX: Duplicates found in the following packages:\n\n${duplicatesPerPackage.join( - '\n' - )}\n` + '\n', + )}\n`, ); } } diff --git a/vx/util/rootPackageJson.js b/vx/util/rootPackageJson.js index df0a33c3e..816640901 100644 --- a/vx/util/rootPackageJson.js +++ b/vx/util/rootPackageJson.js @@ -8,7 +8,7 @@ function rootPackageJson() { // Manually reading it instead of requiring to avoid caching const jsonString = fs.readFileSync( path.join(vxPath.ROOT_PATH, opts.fileNames.PACKAGE_JSON), - 'utf8' + 'utf8', ); return JSON.parse(jsonString); } diff --git a/vx/util/runOnActivePackages.js b/vx/util/runOnActivePackages.js index d12c60971..19edd4336 100644 --- a/vx/util/runOnActivePackages.js +++ b/vx/util/runOnActivePackages.js @@ -10,6 +10,6 @@ module.exports = (callback, ...args) => { return callback(...args); } packages.list.forEach(packageName => - ctx.withPackage(packageName, () => callback(...args)) + ctx.withPackage(packageName, () => callback(...args)), ); }; diff --git a/vx/util/taggedBranch.js b/vx/util/taggedBranch.js index 89bf82114..162df56ca 100644 --- a/vx/util/taggedBranch.js +++ b/vx/util/taggedBranch.js @@ -17,7 +17,7 @@ const isLatestBranch = CURRENT_BRANCH.startsWith(LATEST_BRANCH); const isStableBranch = CURRENT_BRANCH.startsWith(STABLE_BRANCH); const isReleaseBranch = CURRENT_BRANCH.startsWith(RELEASE_BRANCH); const isReleaseKeepVersionBranch = CURRENT_BRANCH.startsWith( - RELEASE_KEEP_VERSION_BRANCH + RELEASE_KEEP_VERSION_BRANCH, ); const [, target = undefined] = isIntegrationBranch || isNextBranch || isNightlyBranch diff --git a/vx/vxPath.js b/vx/vxPath.js index 7e132b6ea..5bb6080d6 100644 --- a/vx/vxPath.js +++ b/vx/vxPath.js @@ -27,7 +27,7 @@ vxPath.packageNameFromPath = pathSegment => { const packagesPosition = pathSegment.indexOf(opts.dir.PACKAGES); // 2 const withoutDir = pathSegment.substring( - packagesPosition + opts.dir.PACKAGES.length + packagesPosition + opts.dir.PACKAGES.length, ); // /vest/src/core/isolate/isolates/skipWhen.ts return withoutDir.split(path.sep)[1]; //vest }; @@ -106,19 +106,19 @@ vxPath.VX_COMMANDS_PATH = path.resolve(vxPath.VX_ROOT_PATH, opts.dir.COMMANDS); vxPath.ROLLUP_CONFIG_PATH = path.resolve( vxPath.VX_CONFIG_PATH, opts.dir.ROLLUP, - opts.fileNames.ROLLUP_CONFIG + opts.fileNames.ROLLUP_CONFIG, ); vxPath.JEST_CONFIG_PATH = path.resolve(vxPath.VX_CONFIG_PATH, opts.dir.JEST); vxPath.JEST_CONFIG_FILE_PATH = path.resolve( vxPath.JEST_CONFIG_PATH, - opts.fileNames.JEST_CONFIG + opts.fileNames.JEST_CONFIG, ); vxPath.TSCONFIG_PATH = path.resolve( vxPath.ROOT_PATH, - opts.fileNames.TSCONFIG_JSON + opts.fileNames.TSCONFIG_JSON, ); vxPath.PACKAGES_PATH = path.resolve(vxPath.ROOT_PATH, opts.dir.PACKAGES); diff --git a/website/docs/enforce/builtin-enforce-plugins/compound_rules.md b/website/docs/enforce/builtin-enforce-plugins/compound_rules.md index f14169e75..ede1dc9d2 100644 --- a/website/docs/enforce/builtin-enforce-plugins/compound_rules.md +++ b/website/docs/enforce/builtin-enforce-plugins/compound_rules.md @@ -48,7 +48,7 @@ enforce.oneOf can be used to determine if _exactly_ one of the rules applies. It enforce(value).oneOf( enforce.isString(), enforce.isNumber(), - enforce.longerThan(1) + enforce.longerThan(1), ); /* diff --git a/website/docs/enforce/builtin-enforce-plugins/schema_rules.md b/website/docs/enforce/builtin-enforce-plugins/schema_rules.md index 983ba1c70..221a48c47 100644 --- a/website/docs/enforce/builtin-enforce-plugins/schema_rules.md +++ b/website/docs/enforce/builtin-enforce-plugins/schema_rules.md @@ -105,7 +105,7 @@ enforce({}).shape( partial({ firstName: enforce.isString(), lastName: enforce.isString(), - }) + }), ); ``` diff --git a/website/docs/enforce/composing_enforce_rules.md b/website/docs/enforce/composing_enforce_rules.md index 02fcf669f..d74e5a432 100644 --- a/website/docs/enforce/composing_enforce_rules.md +++ b/website/docs/enforce/composing_enforce_rules.md @@ -45,8 +45,8 @@ enforce(userObj).shape({ middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) - ) + }), + ), ), }); ``` @@ -60,7 +60,7 @@ import 'vest/enforce/schema'; // for the schema rules const Entity = compose( enforce.loose({ id: enforce.number(), - }) + }), ); const Person = compose( @@ -70,7 +70,7 @@ const Person = compose( middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) + }), ); const User = compose( @@ -79,7 +79,7 @@ const User = compose( enforce.loose({ username: enforce.string(), friends: enforce.optional(enforce.arrayOf(User)), - }) + }), ); ``` diff --git a/website/docs/writing_tests/advanced_test_features/dynamic_tests.md b/website/docs/writing_tests/advanced_test_features/dynamic_tests.md index 279eb562c..8926f5a2f 100644 --- a/website/docs/writing_tests/advanced_test_features/dynamic_tests.md +++ b/website/docs/writing_tests/advanced_test_features/dynamic_tests.md @@ -48,7 +48,7 @@ const suite = create((data = {}) => { () => { enforce(field.price).isNumeric().greaterThan(0); }, - field.id // the key is used to guarantee state persistence on reordering + field.id, // the key is used to guarantee state persistence on reordering ); }); }); diff --git a/website/docs/writing_tests/advanced_test_features/grouping_tests.md b/website/docs/writing_tests/advanced_test_features/grouping_tests.md index 3af0b0563..623a2fbc6 100644 --- a/website/docs/writing_tests/advanced_test_features/grouping_tests.md +++ b/website/docs/writing_tests/advanced_test_features/grouping_tests.md @@ -63,7 +63,7 @@ create(data => { test( 'userName', 'User not found. Please check if you typed it correctly.', - findUserName(data.username) + findUserName(data.username), ); }); @@ -150,13 +150,13 @@ const suite = create(data => { 'promo code purchases are limited to one item only', () => { enforce(data.quantity).equals(1); - } + }, ); test( 'promoCode', 'Promo code can only be used once', - isPromoCodeUsed(data.usedPromo) + isPromoCodeUsed(data.usedPromo), ); }); }); diff --git a/website/docs/writing_tests/advanced_test_features/test.memo.md b/website/docs/writing_tests/advanced_test_features/test.memo.md index fd20757f0..884b0ac86 100644 --- a/website/docs/writing_tests/advanced_test_features/test.memo.md +++ b/website/docs/writing_tests/advanced_test_features/test.memo.md @@ -28,7 +28,7 @@ export default create(data => { 'username', 'username already exists', () => doesUserExist(data.username), - [data.username] + [data.username], ); }); ``` diff --git a/website/docs/writing_tests/warn_only_tests.md b/website/docs/writing_tests/warn_only_tests.md index 6e673e15d..3d66e2d89 100644 --- a/website/docs/writing_tests/warn_only_tests.md +++ b/website/docs/writing_tests/warn_only_tests.md @@ -23,7 +23,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/ + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/, ); }); // this test has a severity level of `warn` @@ -31,7 +31,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/ + /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/, ); }); // this test has a severity level of `warn` }); diff --git a/website/docs/writing_your_suite/including_and_excluding/omitWhen.md b/website/docs/writing_your_suite/including_and_excluding/omitWhen.md index ace08d6c7..6c0e8bbe6 100644 --- a/website/docs/writing_your_suite/including_and_excluding/omitWhen.md +++ b/website/docs/writing_your_suite/including_and_excluding/omitWhen.md @@ -72,7 +72,7 @@ omitWhen( // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); ``` @@ -98,6 +98,7 @@ omitWhen( 'You need at least one option', ); ``` + :::caution IMPORTANT The code within omitWhen will always run, regardless of whether the condition is met or not. `omitWhen` only affects the validation result, but if you call a function within `omitWhen`, it will run regardless of the condition. @@ -107,4 +108,4 @@ omitWhen(true, () => { }); ``` -::: \ No newline at end of file +::: diff --git a/website/docs/writing_your_suite/including_and_excluding/skipWhen.md b/website/docs/writing_your_suite/including_and_excluding/skipWhen.md index dd92d7f31..37f760cdb 100644 --- a/website/docs/writing_your_suite/including_and_excluding/skipWhen.md +++ b/website/docs/writing_your_suite/including_and_excluding/skipWhen.md @@ -44,7 +44,7 @@ export default create((data = {}) => { // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); }); ``` diff --git a/website/docs/writing_your_suite/optional_fields.md b/website/docs/writing_your_suite/optional_fields.md index 93f9ab7f1..a174e9274 100644 --- a/website/docs/writing_your_suite/optional_fields.md +++ b/website/docs/writing_your_suite/optional_fields.md @@ -126,7 +126,7 @@ const suite = create(data => { 'Pet Name may be left empty only if owner name is supplied', () => { enforce(data.pet_name).isNotEmpty(); - } + }, ); test( @@ -134,7 +134,7 @@ const suite = create(data => { 'Owner Name may be left empty only if pet name is supplied', () => { enforce(data.owner_name).isNotEmpty(); - } + }, ); }); ``` diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 348312d0e..ba94e8431 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -124,7 +124,7 @@ const config = { value: badgeLink( 'https://www.npmjs.com/package/vest', 'https://badgen.net/npm/v/vest?icon=npm&scale=1.2&color=red&label', - 'npm-badge' + 'npm-badge', ), }, { @@ -133,7 +133,7 @@ const config = { value: badgeLink( 'https://github.com/ealush/vest', 'https://badgen.net/github/stars/ealush/vest?scale=1.2&color=yellow&icon=github', - 'github-badge' + 'github-badge', ), }, { @@ -142,7 +142,7 @@ const config = { value: badgeLink( 'https://discord.gg/WmADZpJnSe', 'https://badgen.net/discord/online-members/WmADZpJnSe?icon=discord&scale=1.2&label=Discord', - 'discord-badge' + 'discord-badge', ), }, { diff --git a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md index 8abab9539..93ad2ccbf 100644 --- a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md +++ b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md @@ -48,7 +48,7 @@ enforce.oneOf can be used to determine if _exactly_ one of the rules applies. It enforce(value).oneOf( enforce.isString(), enforce.isNumber(), - enforce.longerThan(1) + enforce.longerThan(1), ); /* diff --git a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md index aa556e0f3..791a1835b 100644 --- a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md +++ b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md @@ -105,7 +105,7 @@ enforce({}).shape( partial({ firstName: enforce.isString(), lastName: enforce.isString(), - }) + }), ); ``` diff --git a/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md b/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md index 02fcf669f..d74e5a432 100644 --- a/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md +++ b/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md @@ -45,8 +45,8 @@ enforce(userObj).shape({ middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) - ) + }), + ), ), }); ``` @@ -60,7 +60,7 @@ import 'vest/enforce/schema'; // for the schema rules const Entity = compose( enforce.loose({ id: enforce.number(), - }) + }), ); const Person = compose( @@ -70,7 +70,7 @@ const Person = compose( middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) + }), ); const User = compose( @@ -79,7 +79,7 @@ const User = compose( enforce.loose({ username: enforce.string(), friends: enforce.optional(enforce.arrayOf(User)), - }) + }), ); ``` diff --git a/website/versioned_docs/version-4.x/upgrade_guide.md b/website/versioned_docs/version-4.x/upgrade_guide.md index bf752e27f..7ff3a5829 100644 --- a/website/versioned_docs/version-4.x/upgrade_guide.md +++ b/website/versioned_docs/version-4.x/upgrade_guide.md @@ -72,7 +72,7 @@ skipWhen( test('confirm', 'passwords do not match', () => { /*...*/ }); - } + }, ); // ... @@ -104,7 +104,7 @@ each(fields, field => { () => { enforce(field.value).isNotEmpty(); }, - field.id + field.id, ); }); ``` @@ -191,7 +191,7 @@ const suite = create('user_form', () => { res => res.hasErrors('username'), () => { /* ... */ - } + }, ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md index 279eb562c..8926f5a2f 100644 --- a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md +++ b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md @@ -48,7 +48,7 @@ const suite = create((data = {}) => { () => { enforce(field.price).isNumeric().greaterThan(0); }, - field.id // the key is used to guarantee state persistence on reordering + field.id, // the key is used to guarantee state persistence on reordering ); }); }); diff --git a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md index a17312d4a..2b143b15b 100644 --- a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md +++ b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md @@ -29,7 +29,7 @@ create(data => { test( 'userName', 'User not found. Please check if you typed it correctly.', - findUserName(data.username) + findUserName(data.username), ); }); @@ -107,7 +107,7 @@ const suite = create(data => { test( 'balance', 'Balance is lower than product price', - hasSufficientFunds(data.productId) + hasSufficientFunds(data.productId), ); test('quantity', `Quantity on this item is limited to ${data.limit}`, () => { @@ -120,13 +120,13 @@ const suite = create(data => { 'promo code purchases are limited to one item only', () => { enforce(data.quantity).equals(1); - } + }, ); test( 'promoCode', 'Promo code can only be used once', - isPromoCodeUsed(data.usedPromo) + isPromoCodeUsed(data.usedPromo), ); }); }); diff --git a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md index fd20757f0..884b0ac86 100644 --- a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md +++ b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md @@ -28,7 +28,7 @@ export default create(data => { 'username', 'username already exists', () => doesUserExist(data.username), - [data.username] + [data.username], ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md b/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md index 3b761ebed..ddeeac92e 100644 --- a/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md +++ b/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md @@ -23,7 +23,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/ + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/, ); }); // this test has a severity level of `warn` @@ -31,7 +31,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/ + /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/, ); }); // this test has a severity level of `warn` }); diff --git a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md index c44a9d879..9f07b7302 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md @@ -62,6 +62,6 @@ omitWhen( // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); ``` diff --git a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md index c3d5a488e..85aa281e1 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md @@ -42,7 +42,7 @@ export default create((data = {}) => { // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md index 87124d607..ea98f2eb0 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md @@ -28,7 +28,7 @@ create(data => { test( 'userName', 'User not found. Please check if you typed it correctly.', - findUserName(data.username) + findUserName(data.username), ); }); diff --git a/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md b/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md index 74177becb..112e080c1 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md @@ -96,7 +96,7 @@ const suite = create(data => { 'Pet Name may be left empty only if owner name is supplied', () => { enforce(data.pet_name).isNotEmpty(); - } + }, ); test( @@ -104,7 +104,7 @@ const suite = create(data => { 'Owner Name may be left empty only if pet name is supplied', () => { enforce(data.owner_name).isNotEmpty(); - } + }, ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_your_suite/result_object.md b/website/versioned_docs/version-4.x/writing_your_suite/result_object.md index 99d15689d..c01cb421d 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/result_object.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/result_object.md @@ -230,13 +230,13 @@ const suite = create(data => { test( 'UserEmail', 'Marked as spam address', - async () => await isKnownSpammer(data.address) + async () => await isKnownSpammer(data.address), ); test( 'UserName', 'must not be blacklisted', - async () => await isBlacklistedUser(data.username) + async () => await isBlacklistedUser(data.username), ); }); diff --git a/yarn.lock b/yarn.lock index 26182c83a..dbb6ab711 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13514,6 +13514,7 @@ __metadata: eslint-plugin-jest: ^27.9.0 husky: ^8.0.3 lodash: ^4.17.21 + prettier: ^3.3.1 pretty-quick: ^3.3.1 tsc: ^2.0.4 tslib: ^2.6.3