Skip to content

[Quality] KISS: package.json references non-existent files and scripts #30

Description

@newtontech

实际问题

文件: package.json:5

代码:

{
  "main": "src/main/main.js",
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "eslint src/",
    "test": "jest"
  }
}

问题:

  1. "main": "src/main/main.js" - This file does not exist (no src/ directory)
  2. No build script defined, but workflow tries npm run build
  3. eslint src/ - No src/ directory, and no ESLint configuration file
  4. jest - No Jest configuration file
  5. Missing config.forge section required by electron-forge

改进建议

Create the missing files or update package.json:

{
  "main": "src/main.js",
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package", 
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "eslint src/ --ext .js,.ts,.tsx",
    "test": "jest",
    "build": "electron-forge package"
  },
  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": ["darwin"]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {}
        }
      ]
    }
  }
}

Also create:

  • .eslintrc.js or eslint.config.js - ESLint configuration
  • jest.config.js - Jest configuration
  • src/main.js - Actual entry point (or change main path)

为什么重要

  • Severity: MEDIUM - Commands will fail when developers try to run them
  • npm run lint will fail (no src/ directory)
  • npm run test will fail (no jest config)
  • Missing forge config causes electron-forge to use defaults which may not match expectations
  • Violates KISS: Configuration should be explicit, not implicit

优先级

  • 高 - 影响系统稳定性/安全性
  • 中 - 影响代码质量
  • 低 - 改进建议

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions