eslint-plugin-lube 0.3.1 → 0.3.3

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.
package/package.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "test": "mocha"
23
23
  },
24
24
  "type": "commonjs",
25
- "version": "0.3.1"
25
+ "version": "0.3.3"
26
26
  }
@@ -54,6 +54,8 @@ module.exports = {
54
54
  const temp_indexes = [...text_indexes]
55
55
  /** @type {(string | undefined)[]} */
56
56
  const types = []
57
+ /** @type {true[]} */
58
+ const extras = []
57
59
  /**
58
60
  * @param {number} start
59
61
  * @param {number} end
@@ -72,6 +74,7 @@ module.exports = {
72
74
  let open = 0
73
75
  let close = 0
74
76
  let prev_open = 0
77
+ let prev_close = 0
75
78
  let [left, right] = node.range
76
79
  W: while (left > 0) {
77
80
  if (comments[left - 1]) {
@@ -100,9 +103,11 @@ module.exports = {
100
103
  } else {
101
104
  if (origin_text[right] == ")") {
102
105
  prev_open = left--
106
+ prev_close = right
103
107
  temp_text_changes(left, left + 1)
104
108
  close++
105
109
  if (temp_text.slice(temp_indexes[right + 1], temp_indexes[right + 5]) == "/**/") {
110
+ extras[right] = true
106
111
  temp_text_changes(right, right += 5)
107
112
  } else {
108
113
  temp_text_changes(right, ++right)
@@ -122,11 +127,11 @@ module.exports = {
122
127
  if (close && !types[close - 1]) {
123
128
  close--
124
129
  temp_text_changes(prev_open, prev_open, "(")
125
- temp_text_changes(right, right, ")")
130
+ temp_text_changes(prev_close, prev_close, ")")
126
131
  }
127
132
  const start = temp_indexes[node.range[0]]
128
133
  let end = temp_indexes[node.range[1]]
129
- if (temp_text.slice(end, end + 4) == "/**/") {
134
+ if (extras[end] || open && temp_text.slice(end, end + 4) == "/**/") {
130
135
  end += 4
131
136
  }
132
137
  let corrected_text = temp_text.slice(start, end)
@@ -5,10 +5,13 @@
5
5
  exports.module = (valid, invalid) => {
6
6
  valid.push(
7
7
  {
8
- code: `var v = func(
8
+ code: `func(
9
9
  a
10
10
  )`
11
11
  },
12
+ {
13
+ code: "a((b - c) / d)"
14
+ },
12
15
  {
13
16
  code: "var v = /** @type {{}} */(a)/**/"
14
17
  },
@@ -21,6 +24,9 @@ exports.module = (valid, invalid) => {
21
24
  {
22
25
  code: "var v = { b: /** @type {A} */(a)/**/ }"
23
26
  },
27
+ {
28
+ code: "a = /** @type {A} */((b.c || d).e(f))/**/"
29
+ },
24
30
  {
25
31
  code: `var v = /** @type {V} */({
26
32
  a: /** @type {A} */([/** @type {B} */(b)/**/, /** @type {C} */(c)/**/, /** @type {D} */(d)/**/])/**/,