Tslint: 2 tests fail on just cloned repo

Created on 2 Nov 2017  Â·  11Comments  Â·  Source: palantir/tslint

Bug Report

  • __TSLint version__: master d1caf11
  • __TypeScript version__: 2.6.1
  • __Running TSLint via__: CLI (yarn test)

Actual behavior

I cloned the repo and followed the instructions in the readme, i.e. executed yarn compile and then yarn test. Two tests keep failing:

  ...

  137 passing (58s)
  2 failing

  1) Executable Files exits with code 0 if correct file is passed:
     Uncaught AssertionError: process should exit without an error: expected [Error: Command failed: X:\tslint\test\executable\npm-like-executable.cmd src/configuration.ts
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
] to equal null
      at Function.assert.isNull (node_modules\chai\lib\chai\interface\assert.js:407:32)
      at build\test\executable\executableTests.js:52:31
      at build\test\executable\executableTests.js:482:9
      at ChildProcess.exithandler (child_process.js:213:5)
      at maybeClose (internal/child_process.js:877:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

  2) Executable Files exits with code 0 if several files passed without `-f` flag:
     Uncaught AssertionError: process should exit without an error: expected [Error: Command failed: X:\tslint\test\executable\npm-like-executable.cmd src/configuration.ts src/formatterLoader.ts
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
] to equal null
      at Function.assert.isNull (node_modules\chai\lib\chai\interface\assert.js:407:32)
      at build\test\executable\executableTests.js:58:31
      at build\test\executable\executableTests.js:482:9
      at ChildProcess.exithandler (child_process.js:213:5)
      at maybeClose (internal/child_process.js:877:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Expected behavior

139 passing (60s)

Most helpful comment

I get those errors on lots of different projects, really annoying

Warning: The 'await-promise' rule requires type information.
Warning: The 'no-unused-variable' rule requires type information.
Warning: The 'no-use-before-declare' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-unnecessary-qualifier' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'strict-type-predicates' rule requires type information.

All 11 comments

I cannot reproduce this on Ubuntu 17.10
This must be specific to windows.

Please modify test/executableTests.ts at line 50 to hopefully get more useful output:

-execCli(["src/configuration.ts"], (err) => {
+execCli(["src/configuration.ts"], (err, stdout, stderr) => {
+    console.log(stdout);
+    console.log(stderr);
+    console.log(err);
     assert.isNull(err, "process should exit without an error");
     done();
 });

then run yarn compile and yarn test:mocha again

I'm afraid nothing helpfull:

  Executable
    √ finds configuration above current directory
    Files
      √ exits with code 1 if no arguments passed
ERROR: src/configuration.ts[1, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[2, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[3, 1]: Expected linebreak to be 'LF'
    ... repeats for each line ...
ERROR: src/configuration.ts[523, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[524, 1]: Expected linebreak to be 'LF'
ERROR: src/configuration.ts[525, 1]: Expected linebreak to be 'LF'
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
{ Error: Command failed: X:\tslint\test\executable\npm-like-executable.cmd src/configuration.ts
Warning: The 'promise-function-async' rule requires type information.
Warning: The 'await-promise' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-for-in-array' rule requires type information.
Warning: The 'no-inferred-empty-object-type' rule requires type information.
Warning: The 'no-unsafe-any' rule requires type information.
Warning: The 'restrict-plus-operands' rule requires type information.
Warning: The 'strict-boolean-expressions' rule requires type information.
Warning: The 'use-default-type-parameter' rule requires type information.
Warning: The 'deprecation' rule requires type information.
Warning: The 'match-default-export-name' rule requires type information.
Warning: The 'no-boolean-literal-compare' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'return-undefined' rule requires type information.

    at ChildProcess.exithandler (child_process.js:206:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
  killed: false,
  code: 2,
  signal: null,
  cmd: 'X:\\tslint\\test\\executable\\npm-like-executable.cmd src/configuration.ts' }
      1) exits with code 0 if correct file is passed
      2) exits with code 0 if several files passed without `-f` flag
      √ exits with code 1 if removed `-f` flag is passed

Actually this helps a lot. Somehow your cloned repo has the wrong line endings.
I guess you have a global git config that has core.autocrlf=true.

Try this command to clone: git clone [email protected]:palantir/tslint.git --config core.autocrlf=input --config core.eol=lf

Thanks, after I fixed EOLs in configuration.ts and in formatterLoader.ts all tests passed.

Any idea why wrong EOLs lead to Warning: The 'promise-function-async' rule requires type information.?

The warnings are not relevant here. That's because the test runs tslint without --project which would be needed for promise-function-async and other rules to function correctly.

The relevant part is prefixed with ERROR:. The test expects that the repo contains no lint errors. You can make sure there are no more failures with yarn lint:from-bin. Append --fix to the command to automatically fix the remaining failures.

OK, looks like when a spawned process exits with a non-0 error code, nodejs appends its stderr to the message in the returned error. Otherwise the stderr is ignored, even if it contains something.

But this raises a question: why the actual errors are not copied to the stderr?

Because TSLint outputs all failures to stdout. Changing that would break users

I get those errors on lots of different projects, really annoying

Warning: The 'await-promise' rule requires type information.
Warning: The 'no-unused-variable' rule requires type information.
Warning: The 'no-use-before-declare' rule requires type information.
Warning: The 'return-undefined' rule requires type information.
Warning: The 'no-floating-promises' rule requires type information.
Warning: The 'no-unnecessary-qualifier' rule requires type information.
Warning: The 'no-unnecessary-type-assertion' rule requires type information.
Warning: The 'strict-type-predicates' rule requires type information.

@QuantumInformation got a solution there: https://github.com/palantir/tslint/issues/1481#issuecomment-367264966

yeha got it thx

Was this page helpful?
0 / 5 - 0 ratings