Skip to content

Commit

Permalink
style(*): Setup prettier and apply formatting (#24)
Browse files Browse the repository at this point in the history
* chore: add prettierrc

* chore: apply format with prettier config

* chore: eslint error fix
  • Loading branch information
minsoo-web authored Jun 4, 2024
1 parent 21fa121 commit cf65b2c
Show file tree
Hide file tree
Showing 224 changed files with 890 additions and 884 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ workflows:
- check-peer:
filters:
branches:
ignore: main
ignore: main
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ Note that we value performance, simplicity of implementation, and detailed docum

### 1.1 Performance

All functions es-toolkit provides should be more performant than or similar with that of alternative libraries provide.
All functions es-toolkit provides should be more performant than or similar with that of alternative libraries provide.

We measure the performance of our library every time our code is edited. We are using [vitest's benchmark feature](https://vitest.dev/api/#bench). For our benchmark code, please refer to our [benchmark directory](https://github.com/toss/es-toolkit/tree/main/benchmarks).

When a new functionality is added, a benchmark code should be added. Please add screenshots of the benchmarks when opening a pull request for easy reference and history tracking.

### 1.2 Simplicity

We value implementation and interface simplicity over a variety of features for performance, code readability, and easy maintenance. Our functions will not provide complex options to suit every usecase.
We value implementation and interface simplicity over a variety of features for performance, code readability, and easy maintenance. Our functions will not provide complex options to suit every usecase.

In this manner, instead of having complex options of making full use of overloading, etc, to support edge cases, we aim to provide the most simplest interface and implementation for the most common 85% usecases.

### 1.3 Documentation

All of our functions should be documented in detail for easy reference. All functions should have the jsdoc and corresponding documents [in our documentation directory](https://github.com/toss/es-toolkit/tree/main/docs) for all of their features.
All of our functions should be documented in detail for easy reference. All functions should have the jsdoc and corresponding documents [in our documentation directory](https://github.com/toss/es-toolkit/tree/main/docs) for all of their features.

We use English as our primary language, but we aim to support Korean documents in our best effort. If you have difficulties writing Korean documents, please let our contributors know so that we can provide the corresponding Korean documents for you.

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/broken-link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v4
with:
cache: "yarn"
cache-dependency-path: "yarn.lock"
node-version-file: ".nvmrc"
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
node-version-file: '.nvmrc'
- run: yarn install
- run: yarn blc ${{ github.event.inputs.url }} --ro
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Release
on:
push:
branches:
- "*"
- '*'
tags:
- "v*.*.*"
- 'v*.*.*'

jobs:
release:
Expand All @@ -20,9 +20,9 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v4
with:
cache: "yarn"
cache-dependency-path: "yarn.lock"
node-version-file: ".nvmrc"
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
node-version-file: '.nvmrc'
- if: github.ref_type == 'branch'
run: |
jq \
Expand All @@ -41,7 +41,7 @@ jobs:
heading-title-text: version ${{ github.ref_name }}
ignore-case: true
omit-heading: true
- run: "cat ${{ steps.extract-changelog.outputs.output-file }}"
- run: 'cat ${{ steps.extract-changelog.outputs.output-file }}'
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
Expand Down
13 changes: 13 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.yarn/*

.pnp.cjs
.pnp.loader.mjs

node_modules
coverage
dist
esm
.junit
out
*.d.ts
*.tgz
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"endOfLine": "lf",
"jsxSingleQuote": false,
"printWidth": 120,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}
6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
"recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
}
}
1 change: 0 additions & 1 deletion README-ko_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ es-toolkit은 높은 성능과 작은 번들 사이즈, 강력한 타입을 자
- es-toolkit은 TypeScript 타입이 내장되어 있고, 직관적이고 정확한 타입을 추구해요. [isNotNil](https://es-toolkit.slash.page/ko/reference/predicate/isNotNil.html) 같은 사용하기 편리한 유틸리티 함수도 제공해요.
- es-toolkit은 100% 테스트 커버리지를 유지하면서, 높은 안정성을 자랑해요.


## 기여하기

커뮤니티에 있는 모든 분들에게 기여를 환영해요. 아래에 작성되어 있는 기여 가이드를 확인하세요.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ es-toolkit is a state-of-the-art, high-performance JavaScript utility library wi
- es-toolkit includes built-in TypeScript support, with straightforward yet robust types. It also provides useful type guards such as [isNotNil](https://es-toolkit.slash.page/reference/predicate/isNotNil.html).
- es-toolkit is battle-tested with 100% test coverage, ensuring reliability and robustness.


## Contributing

We welcome contribution from everyone in the community. Read below for detailed contribution guide.
Expand Down
5 changes: 1 addition & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
module.exports = {
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-typescript'),
],
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-typescript')],
};
6 changes: 3 additions & 3 deletions benchmarks/chunk.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { chunk as chunkLodash } from 'lodash';
describe('chunk', () => {
bench('es-toolkit', () => {
chunkToolkit([1, 2, 3, 4, 5, 6], 3);
})
});

bench('lodash', () => {
chunkLodash([1, 2, 3, 4, 5, 6], 3);
})
});
});
});
14 changes: 7 additions & 7 deletions benchmarks/clamp.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { clamp as clampLodash } from 'lodash';

describe('clamp', () => {
bench('es-toolkit', () => {
clampToolkit(10, 5, 15)
clampToolkit(10, 5)
})
clampToolkit(10, 5, 15);
clampToolkit(10, 5);
});

bench('lodash', () => {
clampLodash(10, 5, 15)
clampLodash(10, 5)
})
});
clampLodash(10, 5, 15);
clampLodash(10, 5);
});
});
6 changes: 3 additions & 3 deletions benchmarks/difference.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { difference as differenceLodash } from 'lodash';
describe('difference', () => {
bench('es-toolkit', () => {
differenceToolkit([1, 2, 3], [2]);
})
});

bench('lodash', () => {
differenceLodash([1, 2, 3], [2]);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/differenceBy.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { differenceBy as differenceByLodash } from 'lodash';
describe('differenceBy', () => {
bench('es-toolkit', () => {
differenceByToolkit([1.2, 2.3, 3.4], [1.2], Math.floor);
})
});

bench('lodash', () => {
differenceByLodash([1.2, 2.3, 3.4], [1.2], Math.floor);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/differenceWith.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { differenceWith as differenceWithLodash } from 'lodash';
describe('differenceWith', () => {
bench('es-toolkit', () => {
differenceWithToolkit([1.2, 2.3, 3.4], [1.2], (x, y) => Math.floor(x) === Math.floor(y));
})
});

bench('lodash', () => {
differenceWithLodash([1.2, 2.3, 3.4], [1.2], (x, y) => Math.floor(x) === Math.floor(y));
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/drop.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { drop as dropLodash } from 'lodash';
describe('drop', () => {
bench('es-toolkit', () => {
dropToolkit([1, 2, 3, 4, 5, 6], 3);
})
});

bench('lodash', () => {
dropLodash([1, 2, 3, 4, 5, 6], 3);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/dropRight.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { dropRight as dropRightLodash } from 'lodash';
describe('dropRight', () => {
bench('es-toolkit', () => {
dropRightToolkit([1, 2, 3, 4, 5, 6], 3);
})
});

bench('lodash', () => {
dropRightLodash([1, 2, 3, 4, 5, 6], 3);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/dropRightWhile.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { dropRightWhile as dropRightWhileLodash } from 'lodash';
describe('dropRightWhile', () => {
bench('es-toolkit', () => {
dropRightWhileToolkit([1.2, 2.3, 3.4], x => x < 2);
})
});

bench('lodash', () => {
dropRightWhileLodash([1.2, 2.3, 3.4], x => x < 2);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/dropWhile.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { dropWhile as dropWhileLodash } from 'lodash';
describe('dropWhile', () => {
bench('es-toolkit', () => {
dropWhileToolkit([1.2, 2.3, 3.4], x => x < 2);
})
});

bench('lodash', () => {
dropWhileLodash([1.2, 2.3, 3.4], x => x < 2);
})
});
});
});
14 changes: 7 additions & 7 deletions benchmarks/groupBy.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ describe('groupBy', () => {
{ category: 'fruit', name: 'banana' },
{ category: 'vegetable', name: 'carrot' },
{ category: 'fruit', name: 'pear' },
{ category: 'vegetable', name: 'broccoli' }
{ category: 'vegetable', name: 'broccoli' },
];

groupByToolkit(array, item => item.category);
})
});

bench('lodash', () => {
const array = [
{ category: 'fruit', name: 'apple' },
{ category: 'fruit', name: 'banana' },
{ category: 'vegetable', name: 'carrot' },
{ category: 'fruit', name: 'pear' },
{ category: 'vegetable', name: 'broccoli' }
{ category: 'vegetable', name: 'broccoli' },
];

groupByLodash(array, item => item.category);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/intersection.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { intersection as intersectionLodash } from 'lodash';
describe('intersection', () => {
bench('es-toolkit', () => {
intersectionToolkit([1, 2, 3], [2, 4]);
})
});

bench('lodash', () => {
intersectionLodash([1, 2, 3], [2, 4]);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/intersectionBy.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe('intersectionBy', () => {
const array2 = [{ id: 2 }, { id: 4 }];
const mapper = item => item.id;
intersectionByToolkit(array1, array2, mapper);
})
});

bench('lodash', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const mapper = item => item.id;
intersectionByLodash(array1, array2, mapper);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/intersectionWith.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe('intersectionWith', () => {
const array2 = [{ id: 2 }, { id: 4 }];
const areItemsEqual = (a, b) => a.id === b.id;
intersectionWithToolkit(array1, array2, areItemsEqual);
})
});

bench('lodash', () => {
const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
const array2 = [{ id: 2 }, { id: 4 }];
const areItemsEqual = (a, b) => a.id === b.id;
intersectionWithLodash(array1, array2, areItemsEqual);
})
});
});
});
6 changes: 3 additions & 3 deletions benchmarks/isNil.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe('isNil', () => {
isNilToolkit(undefined);
isNilToolkit(123);
isNilToolkit([1, 2, 3]);
})
});

bench('lodash', () => {
isNilLodash(null);
isNilLodash(undefined);
isNilLodash(123);
isNilLodash([1, 2, 3]);
})
});
});
});
10 changes: 5 additions & 5 deletions benchmarks/omit.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { omit as omitLodash } from 'lodash';

describe('omit', () => {
bench('es-toolkit', () => {
omitToolkit({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar'])
})
omitToolkit({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});

bench('lodash', () => {
omitLodash({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar'])
})
});
omitLodash({ foo: 1, bar: 2, baz: 3 }, ['foo', 'bar']);
});
});
Loading

1 comment on commit cf65b2c

@JerryTurner3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version Control: This summary is often generated when reviewing the outcome of a commit or merge operation in a version control system.
Tracking Changes: It helps track the scale and impact of changes made to a codebase or project over a period, showing the net effect of additions and deletions.
Example Scenario: https://rslhelper.com/
Imagine you are a software developer working on a project:

You have made modifications across 224 files.
In total, you've added 890 new lines of code or content to these files.
You've also removed 884 lines of existing code or content during these modifications.

Please sign in to comment.