@vheissulabs/prettier-config 1.2.0 → 1.5.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
@@ -1,6 +1,6 @@
1
1
  # @vheissulabs/prettier-config
2
2
 
3
- Shared Prettier configuration for VheissuLabs projects.
3
+ Shared Prettier and ESLint configuration for VheissuLabs projects.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,7 +8,7 @@ Shared Prettier configuration for VheissuLabs projects.
8
8
  npm install --save-dev @vheissulabs/prettier-config
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Prettier Usage
12
12
 
13
13
  Run the init script to automatically add the config to your package.json:
14
14
 
@@ -24,13 +24,7 @@ Or manually add to your `package.json`:
24
24
  }
25
25
  ```
26
26
 
27
- Or create a `.prettierrc.js`:
28
-
29
- ```js
30
- module.exports = require('@vheissulabs/prettier-config')
31
- ```
32
-
33
- ### Extending the config
27
+ ### Extending Prettier config
34
28
 
35
29
  ```js
36
30
  module.exports = {
@@ -39,16 +33,52 @@ module.exports = {
39
33
  }
40
34
  ```
41
35
 
36
+ ## ESLint Usage (Vue)
37
+
38
+ Install peer dependencies:
39
+
40
+ ```bash
41
+ npm install --save-dev eslint eslint-plugin-vue
42
+ ```
43
+
44
+ Create `eslint.config.js` in your project:
45
+
46
+ ```js
47
+ const vheissuConfig = require('@vheissulabs/prettier-config/eslint')
48
+
49
+ module.exports = [
50
+ ...vheissuConfig,
51
+ // Your overrides here
52
+ ]
53
+ ```
54
+
55
+ ### What ESLint enforces
56
+
57
+ Forces Vue template content to new lines:
58
+
59
+ ```vue
60
+ <!-- Before (Prettier output) -->
61
+ <PrimaryButton @click="save">Save</PrimaryButton>
62
+
63
+ <!-- After (ESLint fix) -->
64
+ <PrimaryButton @click="save">
65
+ Save
66
+ </PrimaryButton>
67
+ ```
68
+
42
69
  ## What's included
43
70
 
71
+ ### Prettier
44
72
  - 4 space indentation
45
73
  - No semicolons
46
74
  - Single quotes
47
75
  - Vue script/style indentation
48
76
  - Single attribute per line
49
- - Import sorting (no blank lines between groups):
50
- 1. `vue`
51
- 2. `@laravel/*`
52
- 3. `@/layouts/*`
53
- 4. `@/components/*`
54
- 5. Relative imports
77
+ - HTML whitespace sensitivity: ignore
78
+ - Import sorting (no blank lines between groups)
79
+
80
+ ### ESLint (Vue)
81
+ - Single-line element content forced to new line
82
+ - Closing bracket on new line for multiline elements
83
+ - Max 1 attribute per line
84
+ - 4 space HTML indentation
package/bin/init.js CHANGED
@@ -4,6 +4,7 @@ const fs = require('fs')
4
4
  const path = require('path')
5
5
 
6
6
  const packageJsonPath = path.join(process.cwd(), 'package.json')
7
+ const eslintConfigPath = path.join(process.cwd(), 'eslint.config.js')
7
8
 
8
9
  if (!fs.existsSync(packageJsonPath)) {
9
10
  console.error('❌ No package.json found in current directory')
@@ -12,22 +13,34 @@ if (!fs.existsSync(packageJsonPath)) {
12
13
 
13
14
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
14
15
 
16
+ // Add Prettier config
15
17
  if (packageJson.prettier) {
16
18
  console.log('⚠️ Prettier config already exists in package.json')
17
- console.log(' Current value:', JSON.stringify(packageJson.prettier))
18
- process.exit(0)
19
- }
19
+ } else {
20
+ packageJson.prettier = '@vheissulabs/prettier-config'
21
+
22
+ const originalContent = fs.readFileSync(packageJsonPath, 'utf8')
23
+ const indent = originalContent.match(/^(\s+)/m)?.[1] || ' '
20
24
 
21
- packageJson.prettier = '@vheissulabs/prettier-config'
25
+ fs.writeFileSync(
26
+ packageJsonPath,
27
+ JSON.stringify(packageJson, null, indent.length) + '\n'
28
+ )
29
+ console.log('✅ Added prettier config to package.json')
30
+ }
22
31
 
23
- // Preserve formatting by detecting indent
24
- const originalContent = fs.readFileSync(packageJsonPath, 'utf8')
25
- const indent = originalContent.match(/^(\s+)/m)?.[1] || ' '
32
+ // Add ESLint config
33
+ if (fs.existsSync(eslintConfigPath)) {
34
+ console.log('⚠️ eslint.config.js already exists')
35
+ } else {
36
+ const eslintConfig = `const vheissuConfig = require('@vheissulabs/prettier-config/eslint')
26
37
 
27
- fs.writeFileSync(
28
- packageJsonPath,
29
- JSON.stringify(packageJson, null, indent.length) + '\n'
30
- )
38
+ module.exports = [...vheissuConfig]
39
+ `
40
+ fs.writeFileSync(eslintConfigPath, eslintConfig)
41
+ console.log('✅ Created eslint.config.js')
42
+ }
31
43
 
32
- console.log('✅ Added prettier config to package.json')
33
- console.log(' "prettier": "@vheissulabs/prettier-config"')
44
+ console.log('')
45
+ console.log('📦 Install peer dependencies:')
46
+ console.log(' npm install --save-dev eslint eslint-plugin-vue')
@@ -0,0 +1,28 @@
1
+ const vue = require('eslint-plugin-vue')
2
+
3
+ module.exports = [
4
+ ...vue.configs['flat/recommended'],
5
+ {
6
+ rules: {
7
+ // Force element content to new line
8
+ 'vue/singleline-html-element-content-newline': ['error', {
9
+ ignoreWhenNoAttributes: false,
10
+ ignoreWhenEmpty: true,
11
+ }],
12
+ // Force closing bracket to new line
13
+ 'vue/html-closing-bracket-newline': ['error', {
14
+ singleline: 'never',
15
+ multiline: 'always',
16
+ }],
17
+ // Max attributes per line
18
+ 'vue/max-attributes-per-line': ['error', {
19
+ singleline: 1,
20
+ multiline: 1,
21
+ }],
22
+ // Consistent indentation in templates
23
+ 'vue/html-indent': ['error', 4],
24
+ // Disable rules that conflict with Prettier
25
+ 'vue/html-self-closing': 'off',
26
+ },
27
+ },
28
+ ]
package/index.js CHANGED
@@ -4,7 +4,7 @@ module.exports = {
4
4
  singleQuote: true,
5
5
  vueIndentScriptAndStyle: true,
6
6
  singleAttributePerLine: true,
7
- htmlWhitespaceSensitivity: 'css',
7
+ htmlWhitespaceSensitivity: 'ignore',
8
8
  printWidth: 100,
9
9
  plugins: [
10
10
  '@trivago/prettier-plugin-sort-imports',
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "@vheissulabs/prettier-config",
3
- "version": "1.2.0",
4
- "description": "Shared Prettier configuration for VheissuLabs projects",
3
+ "version": "1.5.0",
4
+ "description": "Shared Prettier and ESLint configuration for VheissuLabs projects",
5
5
  "main": "index.js",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./eslint": "./eslint.config.js"
9
+ },
6
10
  "bin": {
7
11
  "vheissu-prettier-init": "./bin/init.js"
8
12
  },
9
13
  "keywords": [
10
14
  "prettier",
15
+ "eslint",
11
16
  "config",
12
17
  "vheissulabs",
13
- "tailwindcss"
18
+ "tailwindcss",
19
+ "vue"
14
20
  ],
15
21
  "author": "Karl Miller",
16
22
  "license": "MIT",
@@ -20,11 +26,19 @@
20
26
  },
21
27
  "peerDependencies": {
22
28
  "prettier": ">=3.0.0",
23
- "prettier-plugin-tailwindcss": ">=0.5.0"
29
+ "prettier-plugin-tailwindcss": ">=0.5.0",
30
+ "eslint": ">=9.0.0",
31
+ "eslint-plugin-vue": ">=9.0.0"
24
32
  },
25
33
  "peerDependenciesMeta": {
26
34
  "prettier-plugin-tailwindcss": {
27
35
  "optional": true
36
+ },
37
+ "eslint": {
38
+ "optional": true
39
+ },
40
+ "eslint-plugin-vue": {
41
+ "optional": true
28
42
  }
29
43
  },
30
44
  "dependencies": {