@lqbach/prettier-config 0.1.0 โ 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +12 -0
- package/dist/index.cjs +11 -9
- package/dist/index.js +11 -9
- package/package.json +9 -2
- package/src/index.ts +11 -7
- package/src/types.ts +5 -0
- package/src/utils.ts +27 -0
- package/test/utils.spec.ts +32 -0
- package/tsconfig.json +13 -15
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.3.0](https://github.com/lqbach/eslint-prettier-config/compare/prettier-config-v0.2.2...prettier-config-v0.3.0) (2023-11-21)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features ๐
|
|
7
|
+
|
|
8
|
+
* add perfectionist sorting for eslint ([b2d8205](https://github.com/lqbach/eslint-prettier-config/commit/b2d8205314b5fe72675afd87a960864018e10782))
|
|
9
|
+
* prettier sorted imports ([c12ede2](https://github.com/lqbach/eslint-prettier-config/commit/c12ede2941863b767810495ee8b5c3cc6691e430))
|
|
10
|
+
* remove import sorting with Prettier ([e099751](https://github.com/lqbach/eslint-prettier-config/commit/e099751d8349b561a15df711e09cfc6763e6b48a))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Chores ๐งน
|
|
14
|
+
|
|
15
|
+
* add husky pre-commit ([db5cdfa](https://github.com/lqbach/eslint-prettier-config/commit/db5cdfa5ce036cebbdbf1edd23885aa1719c27cd))
|
|
16
|
+
* add licensing to package ([e18f4f3](https://github.com/lqbach/eslint-prettier-config/commit/e18f4f36cf44fac1da5906094f2dc9ca2ea2f2d9))
|
|
17
|
+
* add peerDependency for prettier plugin sort ([bf72608](https://github.com/lqbach/eslint-prettier-config/commit/bf72608f71af816b29825ae914514565870f5a84))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Documentation ๐
|
|
21
|
+
|
|
22
|
+
* align badges ([8e7c4e1](https://github.com/lqbach/eslint-prettier-config/commit/8e7c4e1bcbd7ac7321ae02b21ce0ccf19e70a471))
|
|
23
|
+
|
|
24
|
+
## [0.2.2](https://github.com/lqbach/eslint-prettier-config/compare/prettier-config-v0.2.1...prettier-config-v0.2.2) (2023-11-14)
|
|
25
|
+
|
|
26
|
+
### Documentation ๐
|
|
27
|
+
|
|
28
|
+
- add new readme docs ([b2b0044](https://github.com/lqbach/eslint-prettier-config/commit/b2b004442723e81299e10a2945e9f616324ac06a))
|
|
29
|
+
|
|
30
|
+
## [0.2.1](https://github.com/lqbach/eslint-prettier-config/compare/prettier-config-v0.2.0...prettier-config-v0.2.1) (2023-11-14)
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
- update package visiblity ([2c332e1](https://github.com/lqbach/eslint-prettier-config/commit/2c332e19165da93881d6ee61b75560041f9a5397))
|
|
35
|
+
|
|
36
|
+
## [0.2.0](https://github.com/lqbach/eslint-prettier-config/compare/prettier-config-v0.1.0...prettier-config-v0.2.0) (2023-11-14)
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
- add new repository key to package ([d63ceb7](https://github.com/lqbach/eslint-prettier-config/commit/d63ceb7e9a348efc322ecdcb5d462cee6a2b05b8))
|
|
41
|
+
|
|
42
|
+
## 0.1.0 (2023-11-14)
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
- update name in package descriptions ([103aeb8](https://github.com/lqbach/eslint-prettier-config/commit/103aeb876f9ef22177e66a6946f8a257dc7479cd))
|
|
47
|
+
|
|
48
|
+
### Miscellaneous Chores
|
|
49
|
+
|
|
50
|
+
- release 0.1.0 ([7cb7162](https://github.com/lqbach/eslint-prettier-config/commit/7cb7162ec233343991bdcfeaadb1caff612c5c9f))
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<h1 align="center">@lqbach/prettier-config</h1>
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@lqbach/prettier-config">
|
|
5
|
+
<img src="https://img.shields.io/npm/v/@lqbach/prettier-config?color=444E5F&label=version&labelColor=BDD4E7" alt="npm-package"/>
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@lqbach/prettier-config">
|
|
8
|
+
<img src="https://img.shields.io/github/license/lqbach/eslint-prettier-config?labelColor=BDD4E7&color=444E5F" alt="license"/>
|
|
9
|
+
</a>
|
|
10
|
+
<img src="https://img.shields.io/github/release-date/lqbach/eslint-prettier-config?labelColor=BDD4E7&color=444E5F" alt="release-date"/>
|
|
11
|
+
|
|
12
|
+
</div>
|
package/dist/index.cjs
CHANGED
|
@@ -20,14 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
-
default: () =>
|
|
23
|
+
default: () => config
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
function config() {
|
|
27
|
+
return {
|
|
28
|
+
bracketSpacing: true,
|
|
29
|
+
printWidth: 80,
|
|
30
|
+
semi: false,
|
|
31
|
+
singleQuote: false,
|
|
32
|
+
tabWidth: 2,
|
|
33
|
+
useTabs: false
|
|
34
|
+
};
|
|
35
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
function config() {
|
|
3
|
+
return {
|
|
4
|
+
bracketSpacing: true,
|
|
5
|
+
printWidth: 80,
|
|
6
|
+
semi: false,
|
|
7
|
+
singleQuote: false,
|
|
8
|
+
tabWidth: 2,
|
|
9
|
+
useTabs: false
|
|
10
|
+
};
|
|
11
|
+
}
|
|
10
12
|
export {
|
|
11
|
-
|
|
13
|
+
config as default
|
|
12
14
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lqbach/prettier-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"private": false,
|
|
6
|
+
"description": "lqbach's Personal Prettier Config",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/lqbach/eslint-prettier-config.git",
|
|
11
|
+
"directory": "packages/prettier-config"
|
|
12
|
+
},
|
|
6
13
|
"main": "./dist/index.js",
|
|
7
14
|
"scripts": {
|
|
8
15
|
"build": "tsup src/index.ts --format esm,cjs --clean"
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Config } from "prettier"
|
|
2
|
+
|
|
3
|
+
export default function config(): Config {
|
|
4
|
+
return {
|
|
5
|
+
bracketSpacing: true,
|
|
6
|
+
printWidth: 80,
|
|
7
|
+
semi: false,
|
|
8
|
+
singleQuote: false,
|
|
9
|
+
tabWidth: 2,
|
|
10
|
+
useTabs: false,
|
|
11
|
+
}
|
|
8
12
|
}
|
package/src/types.ts
ADDED
package/src/utils.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes in an array of import order strings and groups them into chunks by adding an empty string between each item in the array.
|
|
3
|
+
*
|
|
4
|
+
* Reference: [README `prettier-plugin-sort-imports`](https://github.com/IanVS/prettier-plugin-sort-imports#3-add-spaces-between-import-groups)
|
|
5
|
+
* @param arr an array of import order strings
|
|
6
|
+
* @returns same array item separated by exactly one empty string between each item
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const cleanSortImportsArray = (arr: Array<string>): Array<string> => {
|
|
10
|
+
// remove empty strings
|
|
11
|
+
const arrRemoveEmpty = arr.filter((val) => val !== "")
|
|
12
|
+
|
|
13
|
+
// clean array
|
|
14
|
+
const clean: Array<string> = arrRemoveEmpty.reduce(
|
|
15
|
+
(result: Array<string>, item: string, index: number) => {
|
|
16
|
+
result.push(item)
|
|
17
|
+
|
|
18
|
+
if (index < arrRemoveEmpty.length - 1) {
|
|
19
|
+
result.push("")
|
|
20
|
+
}
|
|
21
|
+
return result
|
|
22
|
+
},
|
|
23
|
+
[],
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
return clean
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest"
|
|
2
|
+
|
|
3
|
+
import { cleanSortImportsArray } from "../src/utils"
|
|
4
|
+
|
|
5
|
+
const inputA1 = ["hey", "jude"]
|
|
6
|
+
const inputA2 = ["hey", "", "", "jude"]
|
|
7
|
+
const inputA3 = ["hey", "", "jude", ""]
|
|
8
|
+
const inputA4 = ["", "hey", "", "jude", ""]
|
|
9
|
+
|
|
10
|
+
const outputExpectedA = ["hey", "", "jude"]
|
|
11
|
+
|
|
12
|
+
describe("cleanSortImportsArray", () => {
|
|
13
|
+
test("test with ['hey', 'jude']", async () => {
|
|
14
|
+
const output = cleanSortImportsArray(inputA1)
|
|
15
|
+
expect(output).toStrictEqual(outputExpectedA)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test("test with ['hey', '', '', 'jude']", async () => {
|
|
19
|
+
const output = cleanSortImportsArray(inputA2)
|
|
20
|
+
expect(output).toStrictEqual(outputExpectedA)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test("test with ['hey', '', 'jude', '']", async () => {
|
|
24
|
+
const output = cleanSortImportsArray(inputA3)
|
|
25
|
+
expect(output).toStrictEqual(outputExpectedA)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test("test with ['', 'hey', '', 'jude', '']", async () => {
|
|
29
|
+
const output = cleanSortImportsArray(inputA4)
|
|
30
|
+
expect(output).toStrictEqual(outputExpectedA)
|
|
31
|
+
})
|
|
32
|
+
})
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"composite": true
|
|
15
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"incremental": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"outDir": "./dist",
|
|
13
|
+
"composite": true
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
}
|