eslint-plugin-lube 0.1.5 → 0.1.7

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
@@ -23,5 +23,5 @@
23
23
  "test": "mocha"
24
24
  },
25
25
  "type": "commonjs",
26
- "version": "0.1.5"
26
+ "version": "0.1.7"
27
27
  }
@@ -9,8 +9,7 @@ module.exports = {
9
9
  },
10
10
  fixable: "code",
11
11
  messages: {
12
- not_match: "Identifier '{{name}}' does not match for svelte's naming conventions.",
13
- not_match_private: "PrivateIdentifier '#{{name}}' does not match for svelte's naming conventions."
12
+ not_match: "Identifier '{{name}}' does not match for svelte's naming conventions."
14
13
  },
15
14
  schema: [{
16
15
  properties: {
@@ -45,6 +44,8 @@ module.exports = {
45
44
  const reported_declarations = new Set()
46
45
  /** @type {Map<string, import("../private").ASTNode[]>} */
47
46
  const pending_usages = new Map()
47
+ /** @type {Set<import("../private").ASTNode>} */
48
+ const shortand_properties = new Set()
48
49
 
49
50
  /** @param {import("../private").ASTNode} node */
50
51
  function defer(node) {
@@ -71,7 +72,8 @@ module.exports = {
71
72
  if (fixable_name_regex.test(name)) {
72
73
  return fixer.replaceTextRange(
73
74
  node.range,
74
- node.name.replace(fix_regex, fix_callback)
75
+ (shortand_properties.has(node) ? node.name + ": " : "")
76
+ + node.name.replace(fix_regex, fix_callback)
75
77
  )
76
78
  }
77
79
  return null
@@ -122,7 +124,10 @@ module.exports = {
122
124
  // (left = right) => {}
123
125
  if ("AssignmentPattern" == type) {
124
126
  if (parent.left == node) {
125
- report(node)
127
+ // function func({ camelCase = true }) {}
128
+ if (parent.parent?.type != "Property") {
129
+ report(node)
130
+ }
126
131
  } else {
127
132
  defer(node)
128
133
  }
@@ -279,12 +284,15 @@ module.exports = {
279
284
  // var value = { key: value }
280
285
  // var { key: value } = value
281
286
  if ("Property" == type) {
282
- if (parent.value == node && parent.key.name != parent.value.name) {
287
+ if (parent.value == node) {
288
+ if (parent.key.name == parent.value.name) {
289
+ shortand_properties.add(node)
290
+ }
283
291
  defer(node)
284
292
  }
285
293
  return
286
294
  }
287
- // class Object { key = value }
295
+ // class Object { camelCase = value }
288
296
  if ("PropertyDefinition" == type) {
289
297
  return
290
298
  }
@@ -70,6 +70,7 @@ exports.module = (valid, invalid) => {
70
70
  pendingA = pendingB
71
71
  var pendingA, pendingB
72
72
  pendingA = pendingB
73
+ function func({ pendingA = 123 }) {}
73
74
  `,
74
75
  errors: [
75
76
  {
@@ -109,7 +110,9 @@ exports.module = (valid, invalid) => {
109
110
  pending_a = pending_b
110
111
  var pending_a, pending_b
111
112
  pending_a = pending_b
112
- `
113
+ function func({ pendingA = 123 }) {}
114
+ `,
115
+ parserOptions: { ecmaVersion: "latest" }
113
116
  },
114
117
  // AssignmentPattern
115
118
  {
@@ -858,6 +861,11 @@ exports.module = (valid, invalid) => {
858
861
  ...error,
859
862
  line: 5,
860
863
  column: 23
864
+ },
865
+ {
866
+ ...error,
867
+ line: 6,
868
+ column: 18
861
869
  }
862
870
  ],
863
871
  options: [{ fixSameNames: true }],
@@ -866,7 +874,7 @@ exports.module = (valid, invalid) => {
866
874
  var value = { key: pending_a }
867
875
  var pending_a
868
876
  var value = { key: pending_a }
869
- var value = { pendingA }
877
+ var value = { pendingA: pending_a }
870
878
  `,
871
879
  parserOptions: { ecmaVersion: "latest" }
872
880
  },