Skip to content

Commit

Permalink
Support TypeScript triple-slash directives
Browse files Browse the repository at this point in the history
TypeScript uses triple-slash directives [1] (single-line comments
containing a single XML tag) to define compiler directives.
The `@arcticicestudio/eslint-config-base` configures the ESLint core
rule `spaced-comment` [2] and already defines exceptions and comment
markers for special use cases, but did not support triple-slash
directives. When running `eslint --fix` these comments in `*.d.ts` files
got malformed (`///` → `// /`) which resulted in invalid TypeScript
syntax.

To support triple-slash directives, the `/` marker has been added to the
`line` field.

[1]: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html
[2]: https://eslint.org/docs/rules/spaced-comment

Co-authored-by: Sven Greb <development@svengreb.de>

GH-50
  • Loading branch information
arcticicestudio committed Apr 8, 2021
1 parent 90953d7 commit 956e651
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/@arcticicestudio/eslint-config-base/rules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,14 @@ module.exports = {
{
line: {
exceptions: ["+-"],
markers: ["!"],
markers: [
"!",
/*
* Support for TypeScript triple-slash directives.
* See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html for more details.
*/
"/",
],
},
block: {
exceptions: ["+-"],
Expand Down

0 comments on commit 956e651

Please sign in to comment.