@lqbach/prettier-config 0.5.0 โ 0.6.1
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 +14 -0
- package/dist/index.cjs +7 -2
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +7 -2
- package/package.json +3 -2
- package/src/index.ts +11 -1
- package/src/types.ts +3 -3
- package/test/tailwind.spec.ts +61 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.1](https://github.com/lqbach/eslint-prettier-config/compare/prettier-config-v0.6.0...prettier-config-v0.6.1) (2024-10-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Chores ๐งน
|
|
7
|
+
|
|
8
|
+
* **prettier-config:** Synchronize ESLint Prettier Configuration versions
|
|
9
|
+
|
|
10
|
+
## [0.6.0](https://github.com/lqbach/eslint-prettier-config/compare/prettier-config-v0.5.0...prettier-config-v0.6.0) (2024-08-26)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features ๐
|
|
14
|
+
|
|
15
|
+
* add prettier tailwind configuration ([da88ac1](https://github.com/lqbach/eslint-prettier-config/commit/da88ac1a5c77d33d50f1530416d06d2b981e8f1e))
|
|
16
|
+
|
|
3
17
|
## [0.5.0](https://github.com/lqbach/eslint-prettier-config/compare/prettier-config-v0.4.0...prettier-config-v0.5.0) (2024-08-23)
|
|
4
18
|
|
|
5
19
|
|
package/dist/index.cjs
CHANGED
|
@@ -23,13 +23,18 @@ __export(src_exports, {
|
|
|
23
23
|
default: () => config
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
function config() {
|
|
26
|
+
function config(params) {
|
|
27
|
+
const tailwind = params?.tailwind;
|
|
28
|
+
const plugins = [...tailwind ? ["prettier-plugin-tailwindcss"] : []];
|
|
29
|
+
const tailwindOptions = typeof tailwind !== "boolean" ? tailwind : {};
|
|
27
30
|
return {
|
|
28
31
|
bracketSpacing: true,
|
|
32
|
+
plugins,
|
|
29
33
|
printWidth: 80,
|
|
30
34
|
semi: false,
|
|
31
35
|
singleQuote: false,
|
|
32
36
|
tabWidth: 2,
|
|
33
|
-
useTabs: false
|
|
37
|
+
useTabs: false,
|
|
38
|
+
...tailwindOptions
|
|
34
39
|
};
|
|
35
40
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Config } from 'prettier';
|
|
2
|
+
import { PluginOptions } from 'prettier-plugin-tailwindcss';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
interface PrettierConfigParams {
|
|
5
|
+
tailwind?: boolean | PluginOptions;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function config(params?: PrettierConfigParams): Config;
|
|
4
9
|
|
|
5
10
|
export { config as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Config } from 'prettier';
|
|
2
|
+
import { PluginOptions } from 'prettier-plugin-tailwindcss';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
interface PrettierConfigParams {
|
|
5
|
+
tailwind?: boolean | PluginOptions;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function config(params?: PrettierConfigParams): Config;
|
|
4
9
|
|
|
5
10
|
export { config as default };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
function config() {
|
|
2
|
+
function config(params) {
|
|
3
|
+
const tailwind = params?.tailwind;
|
|
4
|
+
const plugins = [...tailwind ? ["prettier-plugin-tailwindcss"] : []];
|
|
5
|
+
const tailwindOptions = typeof tailwind !== "boolean" ? tailwind : {};
|
|
3
6
|
return {
|
|
4
7
|
bracketSpacing: true,
|
|
8
|
+
plugins,
|
|
5
9
|
printWidth: 80,
|
|
6
10
|
semi: false,
|
|
7
11
|
singleQuote: false,
|
|
8
12
|
tabWidth: 2,
|
|
9
|
-
useTabs: false
|
|
13
|
+
useTabs: false,
|
|
14
|
+
...tailwindOptions
|
|
10
15
|
};
|
|
11
16
|
}
|
|
12
17
|
export {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lqbach/prettier-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "lqbach's Personal Prettier Config",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"prettier": "^3.1.0"
|
|
21
|
+
"prettier": "^3.1.0",
|
|
22
|
+
"prettier-plugin-tailwindcss": "^0.6.6"
|
|
22
23
|
},
|
|
23
24
|
"scripts": {
|
|
24
25
|
"build": "tsup src/index.ts --format esm,cjs --clean --dts"
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Config } from "prettier"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { PrettierConfigParams } from "./types"
|
|
4
|
+
|
|
5
|
+
export default function config(params?: PrettierConfigParams): Config {
|
|
6
|
+
const tailwind = params?.tailwind
|
|
7
|
+
|
|
8
|
+
const plugins = [...(tailwind ? ["prettier-plugin-tailwindcss"] : [])]
|
|
9
|
+
|
|
10
|
+
const tailwindOptions = typeof tailwind !== "boolean" ? tailwind : {}
|
|
11
|
+
|
|
4
12
|
return {
|
|
5
13
|
bracketSpacing: true,
|
|
14
|
+
plugins,
|
|
6
15
|
printWidth: 80,
|
|
7
16
|
semi: false,
|
|
8
17
|
singleQuote: false,
|
|
9
18
|
tabWidth: 2,
|
|
10
19
|
useTabs: false,
|
|
20
|
+
...tailwindOptions,
|
|
11
21
|
}
|
|
12
22
|
}
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest"
|
|
2
|
+
|
|
3
|
+
import prettierConfig from "../src"
|
|
4
|
+
|
|
5
|
+
// test tailwind configuration
|
|
6
|
+
describe("test tailwind plugin configuration", () => {
|
|
7
|
+
describe("if tailwind option not given", () => {
|
|
8
|
+
const config = prettierConfig()
|
|
9
|
+
|
|
10
|
+
test("should not have anything in `plugin` options", () => {
|
|
11
|
+
expect(config.plugins).toHaveLength(0)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test("should not add extra options", () => {
|
|
15
|
+
expect(config).not.toHaveProperty("tailwindConfig")
|
|
16
|
+
expect(config).not.toHaveProperty("tailwindEntryPoint")
|
|
17
|
+
expect(config).not.toHaveProperty("tailwindAttributes")
|
|
18
|
+
expect(config).not.toHaveProperty("tailwindFunctions")
|
|
19
|
+
expect(config).not.toHaveProperty("tailwindPreserveWhitespace")
|
|
20
|
+
expect(config).not.toHaveProperty("tailwindPreserveDuplicates")
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe("if tailwind option is true", () => {
|
|
25
|
+
const config = prettierConfig({ tailwind: true })
|
|
26
|
+
|
|
27
|
+
test("should have `plugin` options", () => {
|
|
28
|
+
expect(config.plugins).toHaveLength(1)
|
|
29
|
+
expect(config.plugins).toContain("prettier-plugin-tailwindcss")
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test("should not add extra options", () => {
|
|
33
|
+
expect(config).not.toHaveProperty("tailwindConfig")
|
|
34
|
+
expect(config).not.toHaveProperty("tailwindEntryPoint")
|
|
35
|
+
expect(config).not.toHaveProperty("tailwindAttributes")
|
|
36
|
+
expect(config).not.toHaveProperty("tailwindFunctions")
|
|
37
|
+
expect(config).not.toHaveProperty("tailwindPreserveWhitespace")
|
|
38
|
+
expect(config).not.toHaveProperty("tailwindPreserveDuplicates")
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
describe("if tailwind option is an option object", () => {
|
|
43
|
+
const config = prettierConfig({
|
|
44
|
+
tailwind: { tailwindAttributes: ["myClassList"] },
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test("should have `plugin` options", () => {
|
|
48
|
+
expect(config.plugins).toHaveLength(1)
|
|
49
|
+
expect(config.plugins).toContain("prettier-plugin-tailwindcss")
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test("should not add extra options", () => {
|
|
53
|
+
expect(config).not.toHaveProperty("tailwindConfig")
|
|
54
|
+
expect(config).not.toHaveProperty("tailwindEntryPoint")
|
|
55
|
+
expect(config).toHaveProperty("tailwindAttributes")
|
|
56
|
+
expect(config).not.toHaveProperty("tailwindFunctions")
|
|
57
|
+
expect(config).not.toHaveProperty("tailwindPreserveWhitespace")
|
|
58
|
+
expect(config).not.toHaveProperty("tailwindPreserveDuplicates")
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
})
|