Bram's Dev Blog

home

100 Days of Code Day 86 - TSLint issues

20 Nov 2018

IntelliJ Insert Pair brackets / auto-parenthesis generation

Whenever I type a [ o (, Intellij IDEA would be clever and immediately also type the closing one. Even though it is sometimes handy, it more than often is not for me, to the point that it was driving my crazy.

As with so many things in this editor, it was easily disabled. After of course googling for it and learning what the name of the option was.

How do I turn off auto-parenthesis generation in Intellij IDEA?

Trying out -t stylish instead of -t verbose

I received a recommendation on Twitter for the -t stylish TSLint formatter.

I tried it out and it’s indeed very neat to see all problems organised per source file. However, I did not yet find a way to also have it display the TSLint rule that is being offended.

Offending rule not clearly visible

Edit The guy who was kind enough to react in the first place immediately responded and made clear that -t stylish also includes the offending rule, but due to a styling issue that I currently don’t understand, the text was hidden in my own terminal

Offending rule visible when highlighted in zsh

Getting TSLint configured in IntelliJ IDEA

In order to fix a whole bunch of these problems after writing the offending code. I want to see how I can get IDEA pick up the DSpace 7 Angular TSLint file, and maybe give me pointers in real time. I already have the SonarLint plugin configured, so maybe the DSpace TSLint file it can be somehow part of it.

The TSLint page on jetbrains.com seems to indicate that TSLint is natively supported.

TSLint activated in Intellij IDEA

Shadowed name

ERROR: (no-shadowed-variable) src/app/shared/lang-switch/lang-switch.component.spec.ts[141, 55]: Shadowed name: 'LangConfig'

No Shadowed Variable

Read the explanation two times and still don’t understand it.

Making Sense of ‘No Shadowed Variable’ tslint Warning

In that stackoverflow post, they refer to the ESLint explanation. So the basic tl;dr on this is: if you have defined a variable in a higher (or global) scope, don’t redefine it in a local scope because then it can be confusing what it will actually contain + you can’t access the global variable anymore.

Array type

ERROR: (array-type) src/app/shared/lang-switch/lang-switch.component.ts[19, 16]: Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead.

Not sure why a strongly typed array of objects is a bad thing.

What’s the rationale for the array-type rule?

Apparently it’s a style thing, e.g. assistance to ensure that you adhere to the same style across the project.

Day 87 Plan

Evaluate the latest build results of the fixes I pushed upstream.

Future days - DSpace 7 Angular

Future days - Analyzer.atmire.com work

Future Days - Productivity

Future days - Jekyll http://bram-atmire.github.io/ site

Future Days - Atmire.com work

Investigate and work on search engine optimization (SEO) for the main atmire.com website.

Future Days - Learning just for learning

Sustainability challenge - Finish before Christmas

If I continue like October, I could hit day 68 by end of October and day 98 by end of November.