Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules/
dist
dist
coverage
jest.config.js
commitlint.config.js
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/array-type": [
"warn",
"generic"
{
"default": "generic"
}
],
"@typescript-eslint/no-explicit-any": "off",
"react/prop-types": "off",
"import/prefer-default-export": "off",
"no-undef": "off",
"no-unused-expressions": [
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint Commit Messages
on: [pull_request]

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v2
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: node --version
- run: yarn install
- run: yarn lint
- run: yarn test:ci
- run: yarn compile
release:
name: Release
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: yarn install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn semantic-release
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [10, 12]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: node --version
- run: yarn install
- run: yarn lint
- run: yarn test:ci
- run: yarn compile
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"language": "typescriptreact",
"autoFix": true
}
]
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# 🥨 fluent-builder
[![npm](https://img.shields.io/npm/v/@develohpanda/fluent-builder?logo=npm)](https://www.npmjs.com/package/@develohpanda/fluent-builder)
[![Azure DevOps builds](https://img.shields.io/azure-devops/build/develohpanda/5974ee25-e62e-483b-b9aa-c3560b2a7be1/1?label=Azure%20Pipelines&logo=Azure%20Pipelines)](https://dev.azure.com/develohpanda/develohpanda/_build?definitionId=1)

### Generate a fluent, typed object builder for any interface or type.

Expand Down
20 changes: 4 additions & 16 deletions test/FluentBuilder.test.ts → __tests__/FluentBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ describe('FluentBuilder', () => {
it('can track mutated function calls', () => {
const mutatedFunc = jest.fn();

const instance = createBuilder(schema)
.func(mutatedFunc)
.build();
const instance = createBuilder(schema).func(mutatedFunc).build();

expect(instance.func).not.toHaveBeenCalled();
mutatedFunc();
Expand All @@ -100,10 +98,7 @@ describe('FluentBuilder', () => {
it('can reset back to initial', () => {
const builder = createBuilder(schema);

const instance = builder
.numOpt(5)
.str('test')
.build();
const instance = builder.numOpt(5).str('test').build();

expect(instance).not.toEqual(expectedInitial);

Expand All @@ -119,11 +114,7 @@ describe('FluentBuilder', () => {
let str = 'test 1';
const func = jest.fn();

const instance = builder
.numOpt(numOpt)
.str(str)
.func(func)
.build();
const instance = builder.numOpt(numOpt).str(str).func(func).build();

expect(instance.numOpt).toEqual(numOpt);
expect(instance.str).toEqual(str);
Expand All @@ -134,10 +125,7 @@ describe('FluentBuilder', () => {

numOpt = 3;
str = 'test';
const rebuiltInstance = builder
.numOpt(numOpt)
.str(str)
.build();
const rebuiltInstance = builder.numOpt(numOpt).str(str).build();

expect(rebuiltInstance.numOpt).toEqual(numOpt);
expect(rebuiltInstance.str).toEqual(str);
Expand Down
111 changes: 0 additions & 111 deletions azure-pipelines.yml

This file was deleted.

1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']};
59 changes: 30 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@develohpanda/fluent-builder",
"version": "2.0.2",
"version": "0.0.0-development",
"description": "A typed, fluent builder for creating objects in Typescript",
"repository": "https://github.com/develohpanda/fluent-builder",
"author": "Opender Singh <opender94@gmail.com>",
"license": "MIT",
"main": "src/index.js",
"types": "src/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"files": [
"src"
"dist"
],
"keywords": [
"typescript",
Expand All @@ -20,45 +20,46 @@
"test": "jest",
"test:cover": "jest --coverage",
"test:watch": "jest --watch",
"test:ci": "jest --ci --reporters=jest-junit --coverage --coverageReporters=cobertura",
"compile": "tsc",
"lint": "eslint {src,test}/**/* --ext .{{t,j}s{,x}}",
"test:ci": "jest --ci --coverage",
"compile": "tsc -p tsconfig.build.json",
"lint": "eslint **/*.{t,j}s",
"lint:fix": "yarn lint --fix",
"local-pack": "rimraf ./*.tgz && yarn lint && yarn compile && yarn pack"
"semantic-release": "semantic-release"
},
"lint-staged": {
"*.{{t,j}s{,x}}": [
"eslint --fix",
"git add"
"*.{{t,j}s}": [
"eslint --fix"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"devDependencies": {
"@types/jest": "26.0.8",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@types/jest": "26.0.14",
"@types/prop-types": "^15.7.3",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"eslint": "^5.0.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jest": "23.20.0",
"eslint-plugin-prettier": "3.1.2",
"@typescript-eslint/eslint-plugin": "4.4.0",
"@typescript-eslint/parser": "4.4.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "6.12.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.1.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-simple-import-sort": "5.0.3",
"husky": "4.2.5",
"jest": "24.9.0",
"jest-junit": "^10.0.0",
"lint-staged": "8.2.1",
"prettier": "1.19.1",
"husky": "4.3.0",
"jest": "26.5.2",
"lint-staged": "10.4.0",
"prettier": "2.1.2",
"prop-types": "15.7.2",
"rimraf": "3.0.2",
"ts-jest": "24.3.0",
"typescript": "^3.5.3"
"semantic-release": "^17.1.2",
"ts-jest": "26.4.1",
"typescript": "4.0.3"
},
"peerDependencies": {
"prop-types": ">=15.7.2"
}
}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable no-prototype-builtins */
import {IsOptional} from 'prop-types';

export type Schema<T> = Readonly<InternalSchema<T>>;
Expand Down
Loading