@vheissulabs/prettier-config 1.5.0 → 1.7.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/bin/init.js CHANGED
@@ -4,7 +4,6 @@ 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')
8
7
 
9
8
  if (!fs.existsSync(packageJsonPath)) {
10
9
  console.error('❌ No package.json found in current directory')
@@ -13,6 +12,16 @@ if (!fs.existsSync(packageJsonPath)) {
13
12
 
14
13
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
15
14
 
15
+ // Detect if project uses ES modules
16
+ const isESModule = packageJson.type === 'module'
17
+ const eslintExt = isESModule ? 'cjs' : 'js'
18
+ const eslintConfigPath = path.join(process.cwd(), `eslint.config.${eslintExt}`)
19
+
20
+ // Check for existing eslint config (either .js or .cjs)
21
+ const existingConfigs = ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
22
+ .map(f => path.join(process.cwd(), f))
23
+ .filter(f => fs.existsSync(f))
24
+
16
25
  // Add Prettier config
17
26
  if (packageJson.prettier) {
18
27
  console.log('⚠️ Prettier config already exists in package.json')
@@ -30,17 +39,17 @@ if (packageJson.prettier) {
30
39
  }
31
40
 
32
41
  // Add ESLint config
33
- if (fs.existsSync(eslintConfigPath)) {
34
- console.log('⚠️ eslint.config.js already exists')
42
+ if (existingConfigs.length > 0) {
43
+ console.log(`⚠️ ESLint config already exists: ${path.basename(existingConfigs[0])}`)
35
44
  } else {
36
45
  const eslintConfig = `const vheissuConfig = require('@vheissulabs/prettier-config/eslint')
37
46
 
38
47
  module.exports = [...vheissuConfig]
39
48
  `
40
49
  fs.writeFileSync(eslintConfigPath, eslintConfig)
41
- console.log('✅ Created eslint.config.js')
50
+ console.log(`✅ Created eslint.config.${eslintExt}${isESModule ? ' (CommonJS for ES module project)' : ''}`)
42
51
  }
43
52
 
44
53
  console.log('')
45
54
  console.log('📦 Install peer dependencies:')
46
- console.log(' npm install --save-dev eslint eslint-plugin-vue')
55
+ console.log(' npm install --save-dev eslint eslint-plugin-vue typescript-eslint')
package/eslint.config.js CHANGED
@@ -1,6 +1,14 @@
1
1
  const vue = require('eslint-plugin-vue')
2
2
 
3
- module.exports = [
3
+ // Try to load typescript-eslint if available
4
+ let tseslint = null
5
+ try {
6
+ tseslint = require('typescript-eslint')
7
+ } catch (e) {
8
+ // typescript-eslint not installed, skip TS support
9
+ }
10
+
11
+ const baseConfig = [
4
12
  ...vue.configs['flat/recommended'],
5
13
  {
6
14
  rules: {
@@ -23,6 +31,22 @@ module.exports = [
23
31
  'vue/html-indent': ['error', 4],
24
32
  // Disable rules that conflict with Prettier
25
33
  'vue/html-self-closing': 'off',
34
+ // Allow single-word component names (common in page components)
35
+ 'vue/multi-word-component-names': 'off',
26
36
  },
27
37
  },
28
38
  ]
39
+
40
+ // Add TypeScript support for Vue files if typescript-eslint is available
41
+ if (tseslint) {
42
+ baseConfig.push({
43
+ files: ['**/*.vue'],
44
+ languageOptions: {
45
+ parserOptions: {
46
+ parser: tseslint.parser,
47
+ },
48
+ },
49
+ })
50
+ }
51
+
52
+ module.exports = baseConfig
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vheissulabs/prettier-config",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Shared Prettier and ESLint configuration for VheissuLabs projects",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -28,7 +28,8 @@
28
28
  "prettier": ">=3.0.0",
29
29
  "prettier-plugin-tailwindcss": ">=0.5.0",
30
30
  "eslint": ">=9.0.0",
31
- "eslint-plugin-vue": ">=9.0.0"
31
+ "eslint-plugin-vue": ">=9.0.0",
32
+ "typescript-eslint": ">=8.0.0"
32
33
  },
33
34
  "peerDependenciesMeta": {
34
35
  "prettier-plugin-tailwindcss": {
@@ -39,6 +40,9 @@
39
40
  },
40
41
  "eslint-plugin-vue": {
41
42
  "optional": true
43
+ },
44
+ "typescript-eslint": {
45
+ "optional": true
42
46
  }
43
47
  },
44
48
  "dependencies": {