Skip to content

Commit

Permalink
feat(spaced-comment): ignore typescript triple-slash directive (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
suiyun39 committed Mar 14, 2024
1 parent 75e03cf commit 9d1b285
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,20 @@ ruleTester.run('spaced-comment', rule, {
code: '/***/', // "*" is a marker by default
options: ['always'],
},

// ignore typescript triple-slash directive
{
code: '/// <reference types="node" />',
options: ['always'],
},
{
code: '/// <reference path="path/to/file" />',
options: ['always'],
},
{
code: '/// <amd-module name="moduleName" />',
options: ['always'],
},
],

invalid: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ export default createRule<MessageIds, RuleOptions>({
if (node.value.length === 0 || rule.markers.has(node.value))
return

// Ignores typescript triple-slash directive.
if (type === 'line' && (node.value.startsWith('/ <reference') || node.value.startsWith('/ <amd')))
return

const beginMatch = rule.beginRegex.exec(node.value)
const endMatch = rule.endRegex.exec(node.value)

Expand Down

0 comments on commit 9d1b285

Please sign in to comment.