NativeScript / NativeScript/nativescript-cli

Angular src/app/package.json causing tslint error

Open
#4,575 2 comments 2 reactions 1 assignee View on GitHub

@rosen-vladimirov is already working on this.

Since May 7, 2019.

Dominant language
JavaScript
Stars
1.1k
Forks
204
Avg merge
1d 9h
Merged PRs (30d)
8

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.