@itstandu/code-style 1.2.0 → 1.2.2
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/README.md +21 -1
- package/eslint/javascript.js +1 -0
- package/eslint/typescript.js +1 -0
- package/package.json +1 -1
- package/prettier/index.cjs +22 -6
- package/prettier/index.mjs +31 -6
package/README.md
CHANGED
|
@@ -48,7 +48,27 @@ yarn add -D @itstandu/code-style
|
|
|
48
48
|
bun add -d @itstandu/code-style
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
**Note:**
|
|
51
|
+
**Note:**
|
|
52
|
+
- ESLint plugins are bundled and don't need separate installation.
|
|
53
|
+
- Prettier plugins are included but **Prettier requires plugins to be installed in your project's `node_modules`** (not in dependencies of this package).
|
|
54
|
+
|
|
55
|
+
**For pnpm users:** You need to install Prettier plugins in your project:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pnpm add -D prettier @prettier/plugin-oxc @prettier/plugin-xml prettier-plugin-tailwindcss
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**For npm/yarn users:** Plugins should work automatically, but if you encounter issues, install them explicitly:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# npm
|
|
65
|
+
npm install -D prettier @prettier/plugin-oxc @prettier/plugin-xml prettier-plugin-tailwindcss
|
|
66
|
+
|
|
67
|
+
# yarn
|
|
68
|
+
yarn add -D prettier @prettier/plugin-oxc @prettier/plugin-xml prettier-plugin-tailwindcss
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The config automatically detects and only loads plugins that are available, so it won't crash if some are missing.
|
|
52
72
|
|
|
53
73
|
## Quick Start
|
|
54
74
|
|
package/eslint/javascript.js
CHANGED
package/eslint/typescript.js
CHANGED
package/package.json
CHANGED
package/prettier/index.cjs
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
// Helper function to try requiring a plugin, returns null if not found
|
|
2
|
+
function tryRequire(pluginName) {
|
|
3
|
+
try {
|
|
4
|
+
return require(pluginName)
|
|
5
|
+
} catch (e) {
|
|
6
|
+
return null
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Build plugins array - only include plugins that are installed
|
|
11
|
+
const plugins = []
|
|
12
|
+
const oxcPlugin = tryRequire('@prettier/plugin-oxc')
|
|
13
|
+
const xmlPlugin = tryRequire('@prettier/plugin-xml')
|
|
14
|
+
const tailwindPlugin = tryRequire('prettier-plugin-tailwindcss')
|
|
15
|
+
|
|
16
|
+
if (oxcPlugin) plugins.push('@prettier/plugin-oxc')
|
|
17
|
+
if (xmlPlugin) plugins.push('@prettier/plugin-xml')
|
|
18
|
+
if (tailwindPlugin) plugins.push('prettier-plugin-tailwindcss')
|
|
19
|
+
|
|
1
20
|
module.exports = {
|
|
2
21
|
// Basic formatting
|
|
3
22
|
semi: true,
|
|
@@ -40,10 +59,7 @@ module.exports = {
|
|
|
40
59
|
xmlSortAttributesByKey: false,
|
|
41
60
|
xmlWhitespaceSensitivity: 'strict',
|
|
42
61
|
|
|
43
|
-
// Plugins -
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'@prettier/plugin-xml',
|
|
47
|
-
'prettier-plugin-tailwindcss',
|
|
48
|
-
],
|
|
62
|
+
// Plugins - automatically detected, only loaded if installed
|
|
63
|
+
// Order matters: oxc first for parsing, tailwindcss last for class sorting
|
|
64
|
+
plugins,
|
|
49
65
|
}
|
package/prettier/index.mjs
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
3
|
+
import { dirname } from 'path'
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
6
|
+
const __dirname = dirname(__filename)
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
|
|
9
|
+
// Helper function to try requiring a plugin, returns null if not found
|
|
10
|
+
function tryRequire(pluginName) {
|
|
11
|
+
try {
|
|
12
|
+
require.resolve(pluginName)
|
|
13
|
+
return pluginName
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Build plugins array - only include plugins that are installed
|
|
20
|
+
const plugins = []
|
|
21
|
+
const oxcPlugin = tryRequire('@prettier/plugin-oxc')
|
|
22
|
+
const xmlPlugin = tryRequire('@prettier/plugin-xml')
|
|
23
|
+
const tailwindPlugin = tryRequire('prettier-plugin-tailwindcss')
|
|
24
|
+
|
|
25
|
+
if (oxcPlugin) plugins.push(oxcPlugin)
|
|
26
|
+
if (xmlPlugin) plugins.push(xmlPlugin)
|
|
27
|
+
if (tailwindPlugin) plugins.push(tailwindPlugin)
|
|
28
|
+
|
|
1
29
|
export default {
|
|
2
30
|
// Basic formatting
|
|
3
31
|
semi: true,
|
|
@@ -40,10 +68,7 @@ export default {
|
|
|
40
68
|
xmlSortAttributesByKey: false,
|
|
41
69
|
xmlWhitespaceSensitivity: 'strict',
|
|
42
70
|
|
|
43
|
-
// Plugins -
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'@prettier/plugin-xml',
|
|
47
|
-
'prettier-plugin-tailwindcss',
|
|
48
|
-
],
|
|
71
|
+
// Plugins - automatically detected, only loaded if installed
|
|
72
|
+
// Order matters: oxc first for parsing, tailwindcss last for class sorting
|
|
73
|
+
plugins,
|
|
49
74
|
}
|