lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

Linting issues on ionic-mocks #257

Closed lathonez closed 7 years ago

lathonez commented 7 years ago

Getting a ton of linting errors running

ion-app-scripts lint

From ionic-mocks. Not sure what the story is, they are in node_modules so shouldn't be linted.

https://stackoverflow.com/questions/42483922/exclude-node-modules-from-tslint-in-ionic-2-app

https://github.com/stonelasley/ionic-mocks/issues/5

Obviously ng-cli doesn't give the errors.

lathonez commented 7 years ago

2d6223f

hfwittmann commented 7 years ago

I just noticed that in the current setup when I run

npm run lint

it does not pick up linting errors for files in src's sub-directories. E.g deliberately introducing linting errors in say ./src/pages/clickerList/clickerList.ts leads to no complaints.

However, the following command notes the errors: ./node_modules/tslint/bin/tslint ./src/**/*.ts

I am not sure what's causing this.

lathonez commented 7 years ago

Hey Felix,

I can't replicate that behaviour here:

C:\Users\lathonez\code\clicker [master ≡ +0 ~1 -0 !]
λ  git pull origin master
From github.com:lathonez/clicker
 * branch            master     -> FETCH_HEAD
Already up-to-date.
C:\Users\lathonez\code\clicker [master ≡ +0 ~1 -0 !]
λ  git diff
diff --git a/src/pages/clickerList/clickerList.ts b/src/pages/clickerList/clickerList.ts
index f1e7adf..c21a15b 100644
--- a/src/pages/clickerList/clickerList.ts
+++ b/src/pages/clickerList/clickerList.ts
@@ -15,6 +15,6 @@ export class ClickerList {
   constructor(nav: NavController, clickerService: ClickersService) {
     this.nav = nav;
     this.clickerService = clickerService;
-    this.title = 'Clickers';
+    this.title = 'Clickers'
   }
 }
C:\Users\lathonez\code\clicker [master ≡ +0 ~1 -0 !]
λ  npm run lint

> Clicker@2.17.0 lint C:\Users\lathonez\code\clicker
> tslint ./src/**/*.ts

Warning: The 'no-unused-variable' rule requires type checking
Warning: The 'no-use-before-declare' rule requires type checking

ERROR: src/pages/clickerList/clickerList.ts[18, 28]: Missing semicolon

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint"
npm ERR! node v7.6.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! Clicker@2.17.0 lint: `tslint ./src/**/*.ts`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the Clicker@2.17.0 lint script 'tslint ./src/**/*.ts'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Clicker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tslint ./src/**/*.ts
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs Clicker
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls Clicker
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\lathonez\code\clicker\npm-debug.log

Do you have a repro?

Stephen

hfwittmann commented 7 years ago

Hey Stephen,

I have a repro, please find below. my system is ubuntu linux

Other system variables are uname -a

Linux felix-tuxedo 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

ionic -v 3.5.0

npm -v 4.2.0

node -v v7.10.0

Here's the repro

# prepare

 npm -g remove ionic cordova
 npm -g install ionic cordova

 git clone https://github.com/lathonez/clicker
 cd clicker
 npm install
 npm install
 # 2nd necessary due to cordova errors

 # now manually change line in file clickerList.ts to introduce linting error

# end : prepare
    --- a/src/pages/clickerList/clickerList.ts
    +++ b/src/pages/clickerList/clickerList.ts
    @@ -15,6 +15,6 @@ export class ClickerList {
       constructor(nav: NavController, clickerService: ClickersService) {
         this.nav = nav;
         this.clickerService = clickerService;
    -    this.title = 'Clickers';
    +    this.title = 'Clickers'
       }
     }
npm run lint

    > Clicker@2.17.0 lint /home/hfwittmann/Development/clicker
    > tslint ./src/**/*.ts

    Warning: The 'no-unused-variable' rule requires type checking
    Warning: The 'no-use-before-declare' rule requires type checking

./node_modules/tslint/bin/tslint ./src/**/*.ts

    Warning: The 'no-unused-variable' rule requires type checking
    Warning: The 'no-use-before-declare' rule requires type checking

    ERROR: src/pages/clickerList/clickerList.ts[18, 28]: Missing semicolon

So it's a mystery.

lathonez commented 7 years ago

Weird - maybe an ubuntu thing

lathonez commented 7 years ago

I can replicate, ish, on ubuntu. It doesn't pick up the error, but using via node_modules doesn't either

lathonez commented 7 years ago

guess it's a directory depth thing. I thought ** did all dirs:

DEV:~/clicker$ ./node_modules/tslint/bin/tslint ./src/**/**/*.ts
Warning: The 'no-unused-variable' rule requires type checking
Warning: The 'no-use-before-declare' rule requires type checking

ERROR: src/pages/clickerList/clickerList.ts[18, 28]: Missing semicolon
hfwittmann commented 7 years ago

This is bizarrre. I get

./node_modules/tslint/bin/tslint ./src/**/*.ts Warning: The 'no-unused-variable' rule requires type checking Warning: The 'no-use-before-declare' rule requires type checking

ERROR: src/pages/clickerList/clickerList.ts[18, 28]: Missing semicolon

but with the /// I get the result several times

./node_modules/tslint/bin/tslint ./src/**/**/*.ts
Warning: The 'no-unused-variable' rule requires type checking Warning: The 'no-use-before-declare' rule requires type checking

ERROR: src/pages/clickerList/clickerList.ts[18, 28]: Missing semicolon ERROR: src/pages/clickerList/clickerList.ts[18, 28]: Missing semicolon ERROR: src/pages/clickerList/clickerList.ts[18, 28]: Missing semicolon

lathonez commented 7 years ago

@hfwittmann

can you add single quotes around the path in package.json and see if it resolves for you (it does for me on ubuntu):

@@ -7,7 +7,7 @@
         "ionic_enable_lint": false
     },
     "scripts": {
-        "lint": "tslint ./src/**/*.ts",
+        "lint": "tslint './src/**/*.ts'",
         "clean": "ionic-app-scripts clean",
         "build": "ionic-app-scripts build",
         "ionic:build": "ionic-app-scripts build",
hfwittmann commented 7 years ago

Yes it does!

With the single quotes it works as expected

lathonez commented 7 years ago

excellent, thanks for raising this

hfwittmann commented 7 years ago

thank you for solving it!

lathonez commented 7 years ago

2e0c3a4