nklayman / vue-cli-plugin-electron-builder

Easily Build Your Vue.js App For Desktop With Electron
https://nklayman.github.io/vue-cli-plugin-electron-builder/
MIT License
4.12k stars 279 forks source link

Require statement not part of import statement (@typescript-eslint/no-var-requires) at tests/unit/electron.spec.js #759

Closed pattrickrice closed 4 years ago

pattrickrice commented 4 years ago

Describe the bug When adding the plugin to a project that has typescript enabled:

  1. electron.spec is in JavaScript, not TypeScript
  2. vue add electron-builder ends with a failure
    
    ➜  ~ vue create hello-world           

Vue CLI v4.3.1 ? Please pick a preset: Manually select features ? Check the features needed for your project: Babel, TS, PWA, Router, Vuex, CSS Pre-processors, Linter, Unit, E2E ? Use class-style component syntax? Yes ? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes ? Use history mode for router? (Requires proper server setup for index fallback in production) Yes ? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with dart-sass ) ? Pick a linter / formatter config: Prettier ? Pick additional lint features: Lint on save ? Pick a unit testing solution: Jest ? Pick an E2E testing solution: Cypress ? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files ? Save this as a preset for future projects? No

Vue CLI v4.3.1 ✨ Creating project in /home/patrick/hello-world. πŸ—ƒ Initializing git repository... βš™οΈ Installing CLI plugins. This might take a while...

yarn install v1.22.4 info No lockfile found. [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@2.1.3: The platform "linux" is incompatible with this module. info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.

success Saved lockfile. Done in 23.97s. πŸš€ Invoking generators... πŸ“¦ Installing additional dependencies... [5/5] β’€ cypress yarn install v1.22.4 [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@2.1.3: The platform "linux" is incompatible with this module. info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.13: The platform "linux" is incompatible with this module. info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... [4/4] Building fresh packages...

success Saved lockfile. Done in 11.34s. βš“ Running completion hooks...

πŸ“„ Generating README.md...

πŸŽ‰ Successfully created project hello-world. πŸ‘‰ Get started with the following commands:

$ cd hello-world $ yarn serve

➜ ~ cd hello-world ➜ hello-world git:(master) vue add electron-builder

πŸ“¦ Installing vue-cli-plugin-electron-builder...

yarn add v1.22.4 [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@2.1.3: The platform "linux" is incompatible with this module. info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.13: The platform "linux" is incompatible with this module. info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. success Saved 109 new dependencies. info Direct dependencies └─ vue-cli-plugin-electron-builder@1.4.6 info All dependencies β”œβ”€ @develar/schema-utils@2.1.0 β”œβ”€ @sindresorhus/is@0.14.0 β”œβ”€ @szmarczak/http-timer@1.1.2 β”œβ”€ @types/debug@4.1.5 β”œβ”€ ansi-align@3.0.0 β”œβ”€ app-builder-bin@3.4.3 β”œβ”€ app-builder-lib@21.2.0 β”œβ”€ archiver@2.1.1 β”œβ”€ array-find-index@1.0.2 β”œβ”€ bl@1.2.2 β”œβ”€ boxen@3.2.0 β”œβ”€ buffer-alloc-unsafe@1.1.0 β”œβ”€ buffer-alloc@1.2.0 β”œβ”€ buffer-fill@1.0.0 β”œβ”€ cacheable-request@6.1.0 β”œβ”€ camelcase-keys@2.1.0 β”œβ”€ chromium-pickle-js@0.2.0 β”œβ”€ cli-boxes@2.2.0 β”œβ”€ clone-response@1.0.2 β”œβ”€ compress-commons@1.2.2 β”œβ”€ configstore@4.0.0 β”œβ”€ crc@3.8.0 β”œβ”€ crc32-stream@2.0.0 β”œβ”€ crypto-random-string@1.0.0 β”œβ”€ css-parse@2.0.0 β”œβ”€ css-value@0.0.1 β”œβ”€ currently-unhandled@0.4.1 β”œβ”€ decompress-response@3.3.0 β”œβ”€ deep-extend@0.6.0 β”œβ”€ defer-to-connect@1.1.3 β”œβ”€ dev-null@0.1.1 β”œβ”€ dmg-builder@21.2.0 β”œβ”€ dot-prop@4.2.0 β”œβ”€ duplexer3@0.1.4 β”œβ”€ electron-builder@21.2.0 β”œβ”€ electron-chromedriver@5.0.1 β”œβ”€ electron-download@4.1.1 β”œβ”€ electron-publish@21.2.0 β”œβ”€ env-paths@1.0.0 β”œβ”€ friendly-errors-webpack-plugin@1.7.0 β”œβ”€ fs-constants@1.0.0 β”œβ”€ gaze@1.1.3 β”œβ”€ globule@1.3.1 β”œβ”€ got@9.6.0 β”œβ”€ grapheme-splitter@1.0.4 β”œβ”€ has-yarn@2.1.0 β”œβ”€ http-cache-semantics@4.1.0 β”œβ”€ immediate@3.0.6 β”œβ”€ import-lazy@2.1.0 β”œβ”€ is-npm@3.0.0 β”œβ”€ is-utf8@0.2.1 β”œβ”€ is-yarn-global@0.3.0 β”œβ”€ isbinaryfile@4.0.6 β”œβ”€ json-buffer@3.0.0 β”œβ”€ jszip@3.4.0 β”œβ”€ keyv@3.1.0 β”œβ”€ latest-version@5.1.0 β”œβ”€ lazystream@1.0.0 β”œβ”€ lie@3.3.0 β”œβ”€ lodash.merge@4.6.2 β”œβ”€ loud-rejection@1.6.0 β”œβ”€ lowercase-keys@1.0.1 β”œβ”€ map-obj@1.0.1 β”œβ”€ meow@3.7.0 β”œβ”€ npm-install-package@2.1.0 β”œβ”€ nugget@2.0.1 β”œβ”€ optimist@0.6.1 β”œβ”€ p-cancelable@1.1.0 β”œβ”€ package-json@6.5.0 β”œβ”€ progress-stream@1.2.0 β”œβ”€ redent@1.0.0 β”œβ”€ registry-auth-token@4.1.1 β”œβ”€ registry-url@5.1.0 β”œβ”€ responselike@1.0.2 β”œβ”€ rgb2hex@0.1.10 β”œβ”€ rx-lite-aggregates@4.0.8 β”œβ”€ rx-lite@4.0.8 β”œβ”€ semver-diff@2.1.0 β”œβ”€ set-immediate-shim@1.0.1 β”œβ”€ shebang-loader@0.0.1 β”œβ”€ single-line-log@1.1.2 β”œβ”€ spectron@7.0.0 β”œβ”€ speedometer@0.1.4 β”œβ”€ split@1.0.1 β”œβ”€ split2@3.1.1 β”œβ”€ stat-mode@0.3.0 β”œβ”€ sumchecker@2.0.2 β”œβ”€ tar-stream@1.6.2 β”œβ”€ term-size@1.2.0 β”œβ”€ through2-filter@3.0.0 β”œβ”€ through2-map@3.0.0 β”œβ”€ to-buffer@1.1.1 β”œβ”€ to-readable-stream@1.0.0 β”œβ”€ trim-newlines@1.0.0 β”œβ”€ truncate-utf8-bytes@1.0.2 β”œβ”€ unique-string@1.0.0 β”œβ”€ unzip-crx@0.2.0 β”œβ”€ update-notifier@3.0.1 β”œβ”€ url-parse-lax@3.0.0 β”œβ”€ utf8-byte-length@1.0.4 β”œβ”€ vue-cli-plugin-electron-builder@1.4.6 β”œβ”€ wdio-dot-reporter@0.0.10 β”œβ”€ webdriverio@4.14.4 β”œβ”€ webpack-chain@5.2.4 β”œβ”€ wgxpath@1.0.0 β”œβ”€ widest-line@2.0.1 β”œβ”€ wordwrap@0.0.3 β”œβ”€ yaku@0.16.7 └─ zip-stream@1.2.0 Done in 22.74s. βœ” Successfully installed plugin: vue-cli-plugin-electron-builder

? Choose Electron Version ^6.0.0 ? Add tests with Spectron to your project? Yes

πŸš€ Invoking generator for vue-cli-plugin-electron-builder... WARN Devtools extensions are broken in Electron 6.0.0 and greater WARN Vue Devtools have been disabled, see the comments in your background file for more info πŸ“¦ Installing additional dependencies...

yarn install v1.22.4 [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@2.1.3: The platform "linux" is incompatible with this module. info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.13: The platform "linux" is incompatible with this module. info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. $ electron-builder install-app-deps β€’ electron-builder version=21.2.0 Done in 18.00s. β ‹ Running completion hooks...

WARN It is detected that you are using Vue Router. If you are using history mode, you must push the default route when the root component is loaded. Learn more at https://goo.gl/GM1xZG . error: Require statement not part of import statement (@typescript-eslint/no-var-requires) at tests/unit/electron.spec.js:1:30:

1 | const { testWithSpectron } = require("vue-cli-plugin-electron-builder"); | ^ 2 | jest.setTimeout(50000); 3 | 4 | test("Window Loads Properly", async () => {

1 error found.


**To Reproduce**
Steps to reproduce the behavior:
```bash
➜  ~ vue create hello-world
Vue CLI v4.3.1
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, TS, PWA, Router, Vuex, CSS Pre-processors, Linter, Unit, E2E
? Use class-style component syntax? Yes
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with dart-sass
)
? Pick a linter / formatter config: Prettier
? Pick additional lint features: Lint on save
? Pick a unit testing solution: Jest
? Pick an E2E testing solution: Cypress
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? No
➜  ~ cd hello-world
➜  ~ vue add electron-builder   
βœ”  Successfully installed plugin: vue-cli-plugin-electron-builder

? Choose Electron Version ^6.0.0
? Add tests with Spectron to your project? Yes

Expected behavior

  1. spec is generated in typescript
  2. spec does not throw errors from @typescript-eslint

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

nklayman commented 4 years ago

Will be fixed in v2.0.