Skip to content

Commit

Permalink
chore: reduce complexity, remove all lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 10, 2021
1 parent 746ec47 commit 26af06b
Show file tree
Hide file tree
Showing 67 changed files with 305 additions and 250 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration.yml
Expand Up @@ -24,6 +24,8 @@ jobs:
run: yarn install --frozen-lockfile
- name: Test
run: yarn test
- name: Lint
run: yarn lint
- name: Set npmrc
run: echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > ~/.npmrc
env:
Expand Down
54 changes: 30 additions & 24 deletions packages/anyone/CHANGELOG.md
Expand Up @@ -5,34 +5,40 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.1.21 - 2021-07-02

### Fixed and improved
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

## 0.1.20 - 2021-07-02

### Fixed and improved
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

## 0.1.19 - 2021-07-02

### Fixed and improved
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)
1 change: 0 additions & 1 deletion packages/anyone/src/__tests__/none.test.ts
Expand Up @@ -4,7 +4,6 @@ import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues';

import none from 'none';


describe('methods/none', () => {
describe('When only falsy values', () => {
it('Should return true', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/anyone/src/__tests__/one.test.ts
Expand Up @@ -4,7 +4,6 @@ import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues';

import one from 'one';


describe('methods/one', () => {
describe('When only falsy values', () => {
it('Should return false', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/anyone/src/__tests__/runAnyoneMethods.test.ts
Expand Up @@ -2,7 +2,6 @@ import { FALSY_VALUES, TRUTHY_VALUES } from './anyoneTestValues';

import run from 'runAnyoneMethods';


describe('lib/run', () => {
describe('When value is falsy', () => {
it.each([FALSY_VALUES])('Should return `false` ("%s")', value =>
Expand Down
6 changes: 1 addition & 5 deletions packages/anyone/src/exports/one.ts
Expand Up @@ -16,9 +16,5 @@ export default function one(...args: unknown[]): boolean {
}
}

if (count !== 1) {
return false;
}

return true;
return count === 1;
}
40 changes: 22 additions & 18 deletions packages/context/CHANGELOG.md
Expand Up @@ -5,25 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.1.16 - 2021-07-02

### Fixed and improved
- 34e0414 improved conditions (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

- 34e0414 improved conditions (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

## 1.1.15 - 2021-07-02

### Fixed and improved
- 34e0414 improved conditions (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)

- 34e0414 improved conditions (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)
26 changes: 14 additions & 12 deletions packages/n4s/CHANGELOG.md
Expand Up @@ -5,16 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.1.14 - 2021-07-02

### Fixed and improved
- 34e0414 improved conditions (undefined)
- 26c28c6 all tests pass (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c2cfb65 better typing (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)
- b6db1c6 transform any to unknowns (ealush)

- 34e0414 improved conditions (undefined)
- 26c28c6 all tests pass (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c2cfb65 better typing (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)
- b6db1c6 transform any to unknowns (ealush)
5 changes: 1 addition & 4 deletions packages/n4s/docs/README.md
Expand Up @@ -33,10 +33,7 @@ npm i n4s
If you wish to use enforce's functionality safely with a boolean return interface instead, you can use its lazy validation interface:

```js
enforce
.isArray()
.longerThan(3)
.test([1,2,3])
enforce.isArray().longerThan(3).test([1, 2, 3]);
```

## Content
Expand Down
1 change: 1 addition & 0 deletions packages/n4s/src/enforce.ts
Expand Up @@ -35,6 +35,7 @@ function EnforceBase(value: TRuleValue): TEagerRules {
`enforce/${ruleName} failed with ${JSON.stringify(value)}`
);
} else {
// Explicitly throw a string so that vest.test can pick it up as the validation error message
throw transformedResult.message;
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/n4s/src/lib/compounds/oneOf.ts
@@ -1,3 +1,4 @@
import { lengthEquals } from 'lengthEquals';
import type { TRuleDetailedResult, TLazyRuleMethods } from 'ruleReturn';

export default function oneOf(
Expand All @@ -19,5 +20,5 @@ export default function oneOf(
return result.pass;
});

return { pass: passing.length === 1 };
return { pass: lengthEquals(passing, 1) };
}
6 changes: 1 addition & 5 deletions packages/n4s/src/lib/transformResult.ts
Expand Up @@ -44,11 +44,7 @@ function validateResult(result: TRuleReturn): void {
return;
}

if (__DEV__) {
throwError('Incorrect return value for rule: ' + JSON.stringify(result));
} else {
throwError();
}
throwError('Incorrect return value for rule: ' + JSON.stringify(result));
}

function getDefaultResult(value: TRuleValue): {
Expand Down
1 change: 0 additions & 1 deletion packages/n4s/src/rules.ts
@@ -1,4 +1,3 @@

import { endsWith, doesNotEndWith } from 'endsWith';
import { equals, notEquals } from 'equals';
import { greaterThan } from 'greaterThan';
Expand Down
3 changes: 1 addition & 2 deletions packages/n4s/src/rules/inside.ts
@@ -1,9 +1,8 @@
import bindNot from 'bindNot';
import isString from 'isStringValue';


export function inside(value: unknown, arg1: string | unknown[]): boolean {
if (Array.isArray(arg1) && /^[s|n|b]/.test(typeof value)) {
if (Array.isArray(arg1)) {
return arg1.indexOf(value) !== -1;
}

Expand Down
1 change: 0 additions & 1 deletion packages/n4s/src/rules/isBoolean.ts
@@ -1,6 +1,5 @@
import bindNot from 'bindNot';
import isBoolean from 'isBooleanValue';


export const isNotBoolean = bindNot(isBoolean);
export { isBoolean };
1 change: 0 additions & 1 deletion packages/n4s/src/rules/isString.ts
@@ -1,6 +1,5 @@
import bindNot from 'bindNot';
import isString from 'isStringValue';


export const isNotString = bindNot(isString);
export { isString };
1 change: 0 additions & 1 deletion packages/n4s/src/rules/matches.ts
@@ -1,7 +1,6 @@
import bindNot from 'bindNot';
import isString from 'isStringValue';


export function matches(value: string, regex: RegExp | string): boolean {
if (regex instanceof RegExp) {
return regex.test(value);
Expand Down
1 change: 0 additions & 1 deletion packages/n4s/src/rules/startsWith.ts
@@ -1,7 +1,6 @@
import bindNot from 'bindNot';
import isString from 'isStringValue';


export function startsWith(value: string, arg1: string): boolean {
return isString(value) && isString(arg1) && value.startsWith(arg1);
}
Expand Down
32 changes: 30 additions & 2 deletions packages/shared/src/__tests__/throwError.test.ts
Expand Up @@ -2,12 +2,40 @@ import throwError from 'throwError';

const message = 'message string';

const dev = global.__DEV__;

describe('throwError', () => {
afterEach(() => {
// reset dev mode after each test
global.__DEV__ = dev;
});

it('Should throw with passed message', () => {
expect(() => throwError(message)).toThrow(message);
});

it('Should throw provided error type', () => {
expect(() => throwError(message, TypeError)).toThrow(TypeError);
describe('When production message passed in dev mode', () => {
it('Should throw with dev message', () => {
global.__DEV__ = true;
expect(() => throwError('dev message!', 'production message!')).toThrow(
'dev message'
);
});
});

describe('When production message passed in prod mode', () => {
it('Should throw with prod message', () => {
global.__DEV__ = false;
expect(() => throwError('dev message!', 'production message!')).toThrow(
'production message!'
);
});
});

describe('When no production message passed in prod mode', () => {
it('Should throw with dev message', () => {
global.__DEV__ = false;
expect(() => throwError('dev message!')).toThrow('dev message!');
});
});
});
6 changes: 3 additions & 3 deletions packages/shared/src/throwError.ts
Expand Up @@ -2,8 +2,8 @@
* Throws a timed out error.
*/
export default function throwError(
message?: string,
type: ErrorConstructor = Error
devMessage?: string,
productionMessage?: string | null
): never {
throw new type(message);
throw new Error(__DEV__ ? devMessage : productionMessage ?? devMessage);
}
24 changes: 13 additions & 11 deletions packages/vast/CHANGELOG.md
Expand Up @@ -5,15 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.0.11 - 2021-07-02

### Fixed and improved
- 34e0414 improved conditions (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)
- b6db1c6 transform any to unknowns (ealush)
- 81aad51 fix most tests (ealush)

- 34e0414 improved conditions (undefined)
- 33f4e46 release (undefined)
- 6fe40c7 better bundle (undefined)
- c6387ab before ts settings (undefined)
- c0e9708 generate correct d.ts file (undefined)
- 8e01b8e x (undefined)
- afb3960 x (undefined)
- e0a8463 add changelog support (undefined)
- cc46c38 current (undefined)
- b6db1c6 transform any to unknowns (ealush)
- 81aad51 fix most tests (ealush)

0 comments on commit 26af06b

Please sign in to comment.