Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfaces not checked? #34

Open
SDohle opened this issue Aug 31, 2016 · 11 comments
Open

Interfaces not checked? #34

SDohle opened this issue Aug 31, 2016 · 11 comments
Labels

Comments

@SDohle
Copy link

SDohle commented Aug 31, 2016

Hi,

the tslint-loader doen't check Rules in my typescript interfaces:

import {Component} from '@angular/core';
export interface Test {
  Test : string;
}

Running tslint standalone results in two warnings:

src/app/home/home.interface.ts[1, 9]: Unused import: 'Component'
src/app/home/home.interface.ts[4, 7]: expected nospace before colon in property-declaration

I use emitErrors: true and failOnHint: true to break the build. But during the webpack build with tslint-loader as a preloader no warnings/errors are emitted for violations in interfaces.

@DarkXaHTeP
Copy link

DarkXaHTeP commented Oct 31, 2016

I also have this issue. Are there any plans for fixing?

@sonicoder86
Copy link
Collaborator

@SDohle @DarkXaHTeP is it still present with latest version?

@SDohle
Copy link
Author

SDohle commented Nov 23, 2016

I can't test it, version 3.2.0 isn't working with my setup:

10% 0/3 build modulesModuleBuildError: Module build failed: TypeError: Cannot read property 'findConfiguration' of undefined
    at resolveOptions (node_modules\tslint-loader\index.js:24:32)
    at Object.module.exports (node_modules\tslint-loader\index.js:109:17)
    at DependenciesBlock.onModuleBuildFailed (node_modules\webpack-core\lib\NormalModuleMixin.js:315:19)
    at nextLoader (node_modules\webpack-core\lib\NormalModuleMixin.js:270:31)
    at node_modules\webpack-core\lib\NormalModuleMixin.js:292:15
    at runSyncOrAsync (node_modules\webpack-core\lib\NormalModuleMixin.js:173:4)
    at nextLoader (node_modules\webpack-core\lib\NormalModuleMixin.js:290:3)
    at node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
    at Storage.finished (node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
    at node_modules\graceful-fs\graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

OK, updating to TSLint 4.0.1 fixes this problem. But i use the codelyzer package and that is not yet compatible with tslint 4.0.1.

@SDohle
Copy link
Author

SDohle commented Nov 23, 2016

Problem is fixed. Thank you!

@jrparish
Copy link

jrparish commented Jan 5, 2017

I seem to be running into this issue with tslint 4.2.0 and tslint-loader 3.3.0.
Really odd that it skips over modules with interfaces.

@GaryB432
Copy link

GaryB432 commented Jan 13, 2017

Like @jrparish I am having the problem with the same versions. I wonder if we can reopen. Is this project maintained? I see #40 is closed. using webpack 2.2.0-rc.3

edit: I see #40 is closed because somebody picked up the repo! thanks!

@SDohle
Copy link
Author

SDohle commented Jan 16, 2017

Got this issue again, too.
Running "tslint": "4.2.0" and "tslint-loader": "3.3.0".

Please reopen, @BlackSonic

@genaro-picazo
Copy link

+1 for reopening. Seeing the issue in tslint 4.4.2 and tslint-loader 3.3.0.

@sonicoder86 sonicoder86 reopened this Feb 18, 2017
@sonicoder86
Copy link
Collaborator

Can you add an example repository? There is a test for it also in the loader repository.

@GaryB432
Copy link

GaryB432 commented Mar 17, 2017

I didn't see the test for it in the loader repository. I cut and pasted a small project. I hope it helps.

Observe the console section to see the violations of interface-name only under npm run lint and not under npm run build.

console

$ npm run build && npm run lint

> issue-34@ build C:\issue\issue-34
> webpack

ts-loader: Using typescript@2.2.1 and C:\issue\issue-34\tsconfig.json
Hash: 91d65-redacted-6e6fe
Version: webpack 2.2.1
Time: 5182ms
                Asset     Size  Chunks             Chunk Names
   scripts/content.js  2.92 kB       0  [emitted]  content
scripts/background.js  2.81 kB       1  [emitted]  background
   [0] ./src/scripts/background.ts 163 bytes {1} [built] [1 warning]
   [1] ./src/scripts/content.ts 256 bytes {0} [built]

WARNING in ./src/scripts/background.ts
[7, 28]: block is empty


> issue-34@ lint C:\issue\issue-34
> tslint --format verbose --force src/**/*.ts

(no-empty) src/scripts/background.ts[7, 28]: block is empty
(interface-name) src/scripts/messages.ts[1, 18]: interface name must start with a capitalized I
(interface-name) src/scripts/messages.ts[5, 18]: interface name must start with a capitalized I

$ npm list --depth=0
issue-34@ build C:\issue\issue-34

+-- @types/chrome@0.0.42
+-- ts-loader@2.0.2
+-- tslint@4.5.1
+-- tslint-loader@3.4.3
+-- typescript@2.2.1
`-- webpack@2.2.1

src/scripts/background.ts

import { Message, Response } from "./messages";

function sendMessage(tabId: number, message: Message, responseCallback?: (response: Response) => void): void {
  alert(tabId);
}

sendMessage(1, null, () => { });

src/scripts/content.ts

import { Message, Response, ResponseCallback } from "./messages";

chrome.runtime.onMessage.addListener((msg: Message, sender, sendResponse: ResponseCallback) => {
  if (msg.action === "say_hello") {
    alert("Message recieved!");
    sendResponse({ command: "greetings!" });
  }
});

src/scripts/messages.ts

export interface Message {
  action: "say_hello";
}

export interface Response {
  command: string;
}

export type ResponseCallback = (response: Response) => void;

package.json

{
  "name": "issue-34",
  "private": true,
  "engines": {
    "node": ">=0.8.0"
  },
  "scripts": {
    "build": "webpack",
    "lint": "tslint --format verbose --force src/**/*.ts"
  },
  "devDependencies": {
    "@types/chrome": "0.0.42",
    "copy-webpack-plugin": "^4.0.1",
    "ts-loader": "^2.0.1",
    "tslint": "^4.5.1",
    "tslint-loader": "^3.4.3",
    "typescript": "^2.2.1",
    "webpack": "^2.2.1"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs"
  }
}

tslint.json

{
  "extends": "tslint:latest"
}

webpack.config.js

var path = require('path');

module.exports = {
  entry: {
    background: './src/scripts/background',
    content: './src/scripts/content'
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        loader: 'ts-loader'
      },
      {
        enforce: 'pre',
        test: /\.ts$/,
        loader: 'tslint-loader'
      }
    ],
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'scripts/[name].js'
  },
  resolve: {
    extensions: ['.ts']
  }
}

@zuzusik
Copy link

zuzusik commented Jun 6, 2017

Confirming having this issue too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants