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

display better error messages #108

Open
dagda1 opened this issue Oct 16, 2018 · 4 comments
Open

display better error messages #108

dagda1 opened this issue Oct 16, 2018 · 4 comments

Comments

@dagda1
Copy link

dagda1 commented Oct 16, 2018

I have my tslint-loader configured like this:

        {
          test: /\.tsx$/,
          enforce: 'pre',
          use: [
            {
              loader: 'tslint-loader',
              options: {
                configFile: paths.tsLintConfig,
                tsConfig: paths.tsConfig,
                emitError: true,
                failOnHint: true,
                fix: false
              }
            }
          ]
        },

Is there a way to improve the error messages from this:

tslint

@almondtools
Copy link

almondtools commented Feb 15, 2019

Problems occur with webpack 4 together with gulp/webpack-stream. In this case the fileName is omitted completely leaving:

[3, 17]: Type boolean trivially inferred from a boolean literal, remove type annotation

while e.g ts-loader displays:

 [tsl] ERROR in path/to.ts(35,5)
      TS2531: Object is possibly 'null'.

@crenshaw-dev
Copy link

@almondtools any workaround? I'm experiencing the same issue. Super frustrating when enabling tslint on an existing codebase. Could take a long time to hunt down these errors.

@almondtools
Copy link

I tried to fix this issue in a fork, yet this lets every unit test fail. So this would have meant a complete API change and I think it should be confirmed by the project owner.

However I found out that a custom formatter has access to more information. Look at the file customFormatter.js and prepend failure.fileName to positionTuple. To include a custom formatter you have to configure the formatter directory and the name of the new formatter.

@crenshaw-dev
Copy link

Took some trial-and-error to get it right.

Options:

{
    formatter: 'michael',
    formattersDirectory: 'tslint-formatters'
}

I created the file tslint-formatters/michaelFormatter.js and copied/pasted the contents of customFormatter.js linked above. I made the one tweak @almondtools mentioned. No need to change the Formatter name in the file.

Thanks for the help!

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

No branches or pull requests

3 participants