@naturalcycles/dev-lib 20.10.0 → 20.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,12 +66,19 @@ function insertBlankLineBeforeNext(fixer, sourceCode, prevNode, nextNode) {
66
66
  if (!prevNode.range || !nextNode.range) return null
67
67
  if (prevNode.range[1] >= nextNode.range[0]) return null
68
68
 
69
- const between = sourceCode.text.slice(prevNode.range[1], nextNode.range[0])
69
+ const commentsBetween = sourceCode
70
+ .getCommentsBefore(nextNode)
71
+ ?.filter(comment => comment.range && comment.range[0] >= prevNode.range[1])
72
+ ?.sort((a, b) => a.range[0] - b.range[0])
73
+ const insertionTarget =
74
+ commentsBetween && commentsBetween.length > 0 ? commentsBetween[0].range[0] : nextNode.range[0]
75
+
76
+ const between = sourceCode.text.slice(prevNode.range[1], insertionTarget)
70
77
  const hasLinebreak = /\r?\n/.test(between)
71
78
  const linebreak = sourceCode.text.includes('\r\n') ? '\r\n' : '\n'
72
79
  const text = hasLinebreak ? linebreak : linebreak + linebreak
73
80
 
74
- return fixer.insertTextBeforeRange([nextNode.range[0], nextNode.range[0]], text)
81
+ return fixer.insertTextBeforeRange([insertionTarget, insertionTarget], text)
75
82
  }
76
83
 
77
84
  function matchesSelector(selector, candidate) {
@@ -103,7 +110,7 @@ const paddingLineBetweenStatementsRule = {
103
110
  },
104
111
  defaultOptions: [],
105
112
  messages: {
106
- expectedBlankLine: 'Expected blank line between {prev} and {next}.',
113
+ expectedBlankLine: 'Expected blank line between {{prev}} and {{next}}.',
107
114
  },
108
115
  },
109
116
  create(context) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "20.10.0",
4
+ "version": "20.10.1",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^2",
7
7
  "@commitlint/cli": "^20",