tslint-loader icon indicating copy to clipboard operation
tslint-loader copied to clipboard

Interfaces not checked?

Open SDohle opened this issue 8 years ago • 11 comments

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.

SDohle avatar Aug 31 '16 09:08 SDohle

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

DarkXaHTeP avatar Oct 31 '16 15:10 DarkXaHTeP

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

sonicoder86 avatar Nov 22 '16 20:11 sonicoder86

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 avatar Nov 23 '16 10:11 SDohle

Problem is fixed. Thank you!

SDohle avatar Nov 23 '16 11:11 SDohle

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.

jrparish avatar Jan 05 '17 16:01 jrparish

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!

GaryB432 avatar Jan 13 '17 21:01 GaryB432

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

Please reopen, @blacksonic

SDohle avatar Jan 16 '17 14:01 SDohle

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

genaro-picazo avatar Feb 17 '17 16:02 genaro-picazo

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

sonicoder86 avatar Feb 18 '17 14:02 sonicoder86

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 [email protected] 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/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

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']
  }
}

GaryB432 avatar Mar 17 '17 18:03 GaryB432

Confirming having this issue too.

zuzusik avatar Jun 06 '17 09:06 zuzusik