NativeScript / NativeScript/nativescript-cli

Angular src/app/package.json causing tslint error

未關閉
#4,575 2 則留言 2 個 reaction 已指派 1 人 在 GitHub 檢視

@rosen-vladimirov 已經在處理了。

開始於 2019年5月7日。

主要語言
JavaScript
星號
1.1k
分支
204
平均合併
1 天 9 小時
30 天內合併 PR
8

描述

Environment

tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.3.4 version and is up to date.
✔ Component tns-core-modules has 5.3.1 version and is up to date.
✔ Component tns-android has 5.3.1 version and is up to date.
✔ Component tns-ios has 5.3.1 version and is up to date.

Describe the bug

Having a package.json in src/app/package.json causes no-implicit-dependencies tslint error

To Reproduce

  1. tns create ns-tab-example
  2. Choose Angular project AND tab navigation temlpate
  3. Open src/app/home/home.component.ts in a tslint supported IDE (like VS Code)
  4. See no-implicit-dependencies on the @angular/core import

Expected behavior

no-implicit-dependencies tslint errors should not exist on tns created templates.

Additional context

The problem is there are 2 package.json files in a TNS created Angular project. When tslint goes to find a TS imported module in package.json it 1st finds src/app/package.json with the following contents:

{
  "main": "main.js",
  "android": {
    "v8Flags": "--expose_gc"
  }
}

As you can see, the problem is this file has no dependencies defined. Dependencies are defined in the <project root>/package.json file (rightfully so).

So if you import { Component, OnInit } from '@angular/core'; tslint will throw an error like:

Module '@angular/core' is not listed as dependency in package.json (no-implicit-dependencies)

I'm hoping src/app/package.json can be deleted and its contents merged into <project root>/package.json.

tslint errors are a problem for workflows that prohibit commits that fail linting (like CI/CD envs).

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。