@itstandu/code-style 0.1.9 → 1.1.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/README.md CHANGED
@@ -10,6 +10,7 @@ Production-ready shared ESLint + Prettier configuration library for JavaScript a
10
10
  - **ESLint v9** (Flat Config)
11
11
  - **Prettier v3** with Tailwind CSS support
12
12
  - Supports **JavaScript** and **TypeScript**
13
+ - **Full file type support** - Formats all common file types: JS/JSX, TS/TSX, JSON, CSS/SCSS/LESS, HTML, Markdown, YAML, GraphQL, and more
13
14
  - Framework presets: **React**, **Next.js**, **Vue**, **Angular**, **NestJS**
14
15
  - **Node.js** backend support
15
16
  - Stable import sorting with `eslint-plugin-simple-import-sort`
@@ -48,79 +49,44 @@ bun add -d @itstandu/code-style
48
49
 
49
50
  **Note:** You do NOT need to install `eslint`, `prettier`, or any plugins separately. This package includes all dependencies.
50
51
 
51
- ## Usage
52
-
53
- ### ESLint
52
+ ## Quick Start
54
53
 
55
- Create `eslint.config.js` (or `eslint.config.mjs`) in your project root:
54
+ After installation, you only need to configure **2 files** to get started:
56
55
 
57
- #### Base Preset (Minimal)
58
-
59
- ```javascript
60
- const codeStyle = require('@itstandu/code-style')
56
+ ### 1. ESLint Config
61
57
 
62
- module.exports = [codeStyle.base, codeStyle.typescript, codeStyle.node]
63
- ```
64
-
65
- #### Recommended Preset (Better Safety)
58
+ Create `eslint.config.js` (or `eslint.config.mjs`) in your project root:
66
59
 
60
+ **For TypeScript projects:**
67
61
  ```javascript
68
62
  const codeStyle = require('@itstandu/code-style')
69
63
 
70
64
  module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.node]
71
65
  ```
72
66
 
73
- #### Strict Preset (Opt-in, includes boundaries)
74
-
75
- ```javascript
76
- const codeStyle = require('@itstandu/code-style')
77
-
78
- module.exports = [codeStyle.strict, codeStyle.typescript, codeStyle.node]
79
- ```
80
-
81
- ### Framework Presets
82
-
83
- #### React
84
-
67
+ **For React/Next.js:**
85
68
  ```javascript
86
69
  const codeStyle = require('@itstandu/code-style')
87
70
 
88
71
  module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.react]
72
+ // or codeStyle.next for Next.js
89
73
  ```
90
74
 
91
- #### Next.js
92
-
93
- ```javascript
94
- const codeStyle = require('@itstandu/code-style')
95
-
96
- module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.next]
97
- ```
98
-
99
- #### Vue
100
-
75
+ **For Vue:**
101
76
  ```javascript
102
77
  const codeStyle = require('@itstandu/code-style')
103
78
 
104
79
  module.exports = [codeStyle.recommended, codeStyle.vue]
105
80
  ```
106
81
 
107
- #### Angular
108
-
82
+ **For JavaScript-only projects:**
109
83
  ```javascript
110
84
  const codeStyle = require('@itstandu/code-style')
111
85
 
112
- module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.angular]
86
+ module.exports = [codeStyle.recommended, codeStyle.javascript, codeStyle.node]
113
87
  ```
114
88
 
115
- #### NestJS
116
-
117
- ```javascript
118
- const codeStyle = require('@itstandu/code-style')
119
-
120
- module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.nest]
121
- ```
122
-
123
- ### Prettier
89
+ ### 2. Prettier Config
124
90
 
125
91
  Create `.prettierrc.js` (or `.prettierrc.cjs`) in your project root:
126
92
 
@@ -136,61 +102,82 @@ Or add to `package.json`:
136
102
  }
137
103
  ```
138
104
 
139
- **Optional:** Copy `.prettierignore` from this package to your project root to ignore common files:
105
+ **That's it!** You're ready to use ESLint and Prettier. Run `npx eslint .` and `npx prettier --write .` to test.
140
106
 
141
- ```bash
142
- cp node_modules/@itstandu/code-style/.prettierignore .prettierignore
107
+ ## Usage
108
+
109
+ ### Available Presets
110
+
111
+ #### Base Preset (Minimal)
112
+ ```javascript
113
+ module.exports = [codeStyle.base, codeStyle.typescript, codeStyle.node]
114
+ ```
115
+
116
+ #### Recommended Preset (Default, Better Safety)
117
+ ```javascript
118
+ module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.node]
119
+ ```
120
+
121
+ #### Strict Preset (Opt-in, includes boundaries)
122
+ ```javascript
123
+ module.exports = [codeStyle.strict, codeStyle.typescript, codeStyle.node]
143
124
  ```
144
125
 
145
- ### Setup Scripts
126
+ ### Framework Presets
127
+
128
+ - **React**: `codeStyle.react`
129
+ - **Next.js**: `codeStyle.next`
130
+ - **Vue**: `codeStyle.vue`
131
+ - **Angular**: `codeStyle.angular`
132
+ - **NestJS**: `codeStyle.nest`
133
+
134
+ See [Available Configs](#available-configs) section for full list.
135
+
136
+ ## Optional Setup
137
+
138
+ ### Package Scripts (Optional)
146
139
 
147
140
  Add these scripts to your `package.json` for convenient formatting and linting:
148
141
 
149
142
  ```json
150
143
  {
151
144
  "scripts": {
152
- "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
153
- "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
145
+ "format": "prettier --write .",
146
+ "format:check": "prettier --check .",
154
147
  "lint": "eslint .",
155
148
  "lint:fix": "eslint . --fix"
156
149
  }
157
150
  }
158
151
  ```
159
152
 
160
- **Usage:**
153
+ **Note:** Prettier automatically formats all supported file types (JS/JSX, TS/TSX, JSON, CSS/SCSS/LESS, HTML, Markdown, YAML, GraphQL, Vue, SVG, etc.). Files listed in `.prettierignore` will be excluded.
161
154
 
162
- - `npm run format` - Format all files with Prettier
163
- - `npm run format:check` - Check formatting without modifying files (useful for CI)
164
- - `npm run lint` - Check code for linting errors
165
- - `npm run lint:fix` - Auto-fix linting issues (including import sorting)
155
+ ### .prettierignore (Optional)
166
156
 
167
- **Recommended workflow:**
168
-
169
- Run both format and lint:fix to ensure consistent code style:
157
+ Copy `.prettierignore` from this package to exclude common files:
170
158
 
171
159
  ```bash
172
- npm run format && npm run lint:fix
160
+ cp node_modules/@itstandu/code-style/.prettierignore .prettierignore
173
161
  ```
174
162
 
175
- Or create a combined script:
163
+ ## Advanced
176
164
 
177
- ```json
178
- {
179
- "scripts": {
180
- "style": "npm run format && npm run lint:fix"
181
- }
182
- }
183
- ```
165
+ ### Supported File Types
184
166
 
185
- ### Ensuring Consistent Formatting
167
+ Prettier automatically formats all common file types:
186
168
 
187
- This package ensures **100% Prettier coverage** for all formatting:
169
+ **Built-in support:**
170
+ - JavaScript/TypeScript: `.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs`
171
+ - JSON: `.json`, `.jsonc`
172
+ - CSS: `.css`, `.scss`, `.sass`, `.less`
173
+ - HTML: `.html`, `.htm`
174
+ - Markdown: `.md`, `.mdx`
175
+ - YAML: `.yaml`, `.yml`
176
+ - GraphQL: `.graphql`, `.gql`
188
177
 
189
- - All ESLint formatting rules are disabled via `eslint-config-prettier`
190
- - ✅ React/JSX formatting rules are disabled (Prettier handles JSX)
191
- - Vue template formatting rules are disabled (Prettier handles Vue)
192
- - ✅ Comprehensive Prettier options cover all formatting scenarios
193
- - ✅ Tailwind CSS class sorting is automatic (via `prettier-plugin-tailwindcss`)
178
+ **Plugin support (included):**
179
+ - XML/SVG: `.xml`, `.svg` (via `@prettier/plugin-xml`)
180
+ - Vue: `.vue` (built-in Prettier support)
194
181
 
195
182
  ### Import Sorting Philosophy
196
183
 
@@ -212,12 +199,19 @@ This package ensures **100% Prettier coverage** for all formatting:
212
199
 
213
200
  **Result:** Clean separation of concerns, no conflicts, battle-tested approach.
214
201
 
215
- **Important:** Make sure your editor/IDE:
202
+ ### Ensuring Consistent Formatting
216
203
 
217
- - Uses Prettier as default formatter with `formatOnSave`
218
- - Runs ESLint auto-fix on save (`source.fixAll.eslint`) for import sorting
204
+ This package ensures **100% Prettier coverage** for all formatting:
219
205
 
220
- ### Editor Configuration
206
+ - All ESLint formatting rules are disabled via `eslint-config-prettier`
207
+ - ✅ React/JSX formatting rules are disabled (Prettier handles JSX)
208
+ - ✅ Vue template formatting rules are disabled (Prettier handles Vue)
209
+ - ✅ Comprehensive Prettier options cover all formatting scenarios
210
+ - ✅ Tailwind CSS class sorting is automatic (via `prettier-plugin-tailwindcss`)
211
+
212
+ ### Editor Configuration (Optional)
213
+
214
+ For the best experience, configure your editor to format on save:
221
215
 
222
216
  #### VS Code / Cursor
223
217
 
@@ -241,6 +235,36 @@ Add to your workspace `.vscode/settings.json` or user settings:
241
235
  },
242
236
  "[typescriptreact]": {
243
237
  "editor.defaultFormatter": "esbenp.prettier-vscode"
238
+ },
239
+ "[json]": {
240
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
241
+ },
242
+ "[jsonc]": {
243
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
244
+ },
245
+ "[css]": {
246
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
247
+ },
248
+ "[scss]": {
249
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
250
+ },
251
+ "[less]": {
252
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
253
+ },
254
+ "[html]": {
255
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
256
+ },
257
+ "[markdown]": {
258
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
259
+ },
260
+ "[yaml]": {
261
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
262
+ },
263
+ "[graphql]": {
264
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
265
+ },
266
+ "[vue]": {
267
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
244
268
  }
245
269
  }
246
270
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itstandu/code-style",
3
- "version": "0.1.9",
3
+ "version": "1.1.0",
4
4
  "description": "Production-ready shared ESLint + Prettier configuration for JavaScript and TypeScript projects",
5
5
  "type": "commonjs",
6
6
  "main": "index.js",
@@ -62,6 +62,7 @@
62
62
  "eslint-plugin-unused-imports": "^4.0.0",
63
63
  "eslint-plugin-vue": "^10.0.0",
64
64
  "@prettier/plugin-oxc": "^0.1.0",
65
+ "@prettier/plugin-xml": "^4.1.0",
65
66
  "prettier": "^3.8.0",
66
67
  "prettier-plugin-tailwindcss": "^0.7.0",
67
68
  "vue-eslint-parser": "^10.0.0"
@@ -76,5 +77,12 @@
76
77
  },
77
78
  "scripts": {
78
79
  "test": "echo \"Error: no test specified\" && exit 1"
80
+ },
81
+ "pnpm": {
82
+ "peerDependencyRules": {
83
+ "allowAny": [
84
+ "@prettier/plugin-oxc"
85
+ ]
86
+ }
79
87
  }
80
- }
88
+ }
@@ -34,6 +34,16 @@ module.exports = {
34
34
  // Embedded language formatting
35
35
  embeddedLanguageFormatting: 'auto',
36
36
 
37
+ // XML/SVG specific options
38
+ xmlQuoteAttributes: 'preserve',
39
+ xmlSelfClosingSpace: true,
40
+ xmlSortAttributesByKey: false,
41
+ xmlWhitespaceSensitivity: 'strict',
42
+
37
43
  // Plugins - order matters: oxc first for parsing, tailwindcss last for class sorting
38
- plugins: ['@prettier/plugin-oxc', 'prettier-plugin-tailwindcss'],
44
+ plugins: [
45
+ '@prettier/plugin-oxc',
46
+ '@prettier/plugin-xml',
47
+ 'prettier-plugin-tailwindcss',
48
+ ],
39
49
  }