SonarQube excluding TypeScript Declaration Files (.d.ts) automatically?

we thought that they are usually not written by hand, but generated

No, .d.ts files can very well be written by hand, although the TypeScript compiler can also generate them for .ts files. The use cases for writing declaration files by hand are adding type support for untyped APIs that should be used from within TypeScript. This is typically the case for pure JavaScript APIs.

For example, the complete “Definitely Typed” project (see typescript - What is "DefinitelyTyped"? - Stack Overflow for a high-level description of the project) consists of hand-written .d.ts files for pure JavaScript npm packages.

What is the origin of your .d.ts files?

They are written by hand. They provide type information for a Java API which can be accessed via JavaScript (Nashorn or GraalJS).

Do you find eslint issues valuable?

Sure! Having all code quality related issues in one place makes total sense IMO.
And ESLint also provides an easy way to create custom rules by detecting undesired constructs via the AST (no-restricted-syntax - ESLint - Pluggable JavaScript Linter).

1 Like