tslint-eslint-rules icon indicating copy to clipboard operation
tslint-eslint-rules copied to clipboard

Expected indentation of "NaN" spaces but found 0.

Open BadgerBadgerBadgerBadger opened this issue 7 years ago • 5 comments

Redirected from: https://github.com/palantir/tslint/issues/3077

Bug Report

  • TSLint version: 5.5.0
  • TypeScript version: 2.4.2
  • Running TSLint via: CLI

TypeScript code being linted

'use strict'

import { betalistUtil, logger as Logger } from '@crowdfire/cf-util'

import * as Constants from '../constants'

export const init = function () {
  return betalistUtil.initializeClient()
    .then(() => Logger.info(null, null, `Betalist initialized.`))
    .catch(err => {

      Logger.fatal(null, null, `Betalist failed to initialized.`, err)
      return false
    })
}

export const isUserQrEligible = function (userId: string) {
  return betalistUtil.isAllowed(userId, Constants.BETALIST.DAILY_IN_APP_QR)
    .catch(err => {

      Logger.err(null, userId, `Betalist encountered an error.`, err)
      return false
    })
}

with tslint.json configuration:

{
  "extends": "tslint-config-airbnb",
  "rules": {
    "semicolon": [true, "never"],
    "trailing-comma": [false, {"multiline": "always", "singleline": "always"}],
    "max-line-length": [true, 120],
    "arrow-parens": [true, "ban-single-arg-parens"],
    "ter-arrow-parens": [true, "as-needed"],
    "object-shorthand-properties-first": false,
    "import-name": false
  }
}

Actual behavior

On the last line of the file I'm getting Expected indentation of "NaN" spaces but found 0.

Expected behavior

This linting error shouldn't happen :/

Note: This happened when I updated Typescript from 2.3.3 to 2.4.2. On 2.3.3 this doesn't happen.

This error happens to me when i add more than one @params in my jsdoc.

Typescript: 2.5.3 Tslint: 5.8.0 Running in vscode

Error: Expected indentation of "NaN" spaces but found 0.

/**
 * Some doc.
 *
 * @param foo
 * @param bar
 */
export const someFunc = (foo: string, bar: string) => {
 //
}

No error:

/**
 * Some doc.
 *
 * @param foo
 */
export const someFunc = (foo: string, bar: string) => {
 //
}

ricklancee avatar Nov 19 '17 19:11 ricklancee

Is this still an issue? Checked both examples provided with the latest typescript and tslint and the errors are not present. Perhaps one of the updates fixed it at some point? I'll close this for now as this is working in

tsc 3.0.1 tslint 5.11.0

Reopen if needed.

jmlopez-rod avatar Aug 15 '18 15:08 jmlopez-rod

I still see the problem (in TS code):

const truthy = (value) => !!value;

/**
 * Return true if some rights are allowed.
 * @param currentRights A map of rights
 * @param checkedRights An list of rights to check
 * @returns true if some rights are allowed
 */
export const someRights = (currentRights: { [rightName: string]: boolean }, checkedRights: string[]) =>
	Object.keys(currentRights)
		.filter((rightName) => checkedRights.includes(rightName))
		.map((rightName) => currentRights[rightName])
		.some(truthy)
;

Error on the last semi-colon: "Expected indentation of NaN tabs but found 0" (or 1 or 2, if I change indentation). The error disappears if I put the semi-colon right after the closing brace, or if I remove a @param line...

$ npx tsc -version Version 2.9.2 But also seen in Visual Studio Code reporting TypeScript 3.1.3

$ npx tslint --version 5.11.0

PhiLhoSoft avatar Nov 06 '18 10:11 PhiLhoSoft

Reopening before I forget. @PhiLhoSoft I'm not sure what the error message should be. Can you do a check with eslint to see what it gives you? should it just ignore that lonely semicolon?

jmlopez-rod avatar Nov 13 '18 21:11 jmlopez-rod

I'm not sure what the error message should be

Well, no error message at all, as the file is perfectly fine. The fact the error message disappears when I remove part of the comment (OK, doc comment, but still!) is particularly puzzling.

PhiLhoSoft avatar Dec 13 '18 20:12 PhiLhoSoft