eslint-plugin-lube 0.1.3 → 0.1.4

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.3"
26
+ "version": "0.1.4"
27
27
  }
@@ -30,6 +30,7 @@ module.exports = {
30
30
  const allow_regex = /^[_$]?[_$]?(?:[0-9a-z]+(?:_[0-9a-z]+)*\$?\$?)?$|^[A-Z][0-9A-Z_]*$|^(?:[0-9A-Z][0-9a-z]*)+$/
31
31
  const fixable_name_regex = /^[_$]?[_$]?(?:[0-9A-Za-z]+(?:_[0-9A-Za-z]+)*\$?\$?)?$/
32
32
  const fix_regex = /([0-9a-z]?)([A-Z][0-9A-Z]*)/g
33
+ const camel_case_regex = /^[0-9a-z]+([A-Z][0-9a-z]*)*$/
33
34
 
34
35
  /**
35
36
  * @param {string} _
@@ -206,7 +207,13 @@ module.exports = {
206
207
  }
207
208
  // function camelCase() {}
208
209
  if ("FunctionDeclaration" == type) {
209
- report(node)
210
+ if (
211
+ parent.parent?.type != "ExportNamedDeclaration"
212
+ || !camel_case_regex.test(name)
213
+ ) {
214
+ report(node)
215
+ }
216
+ // export function camelCase() {}
210
217
  return
211
218
  }
212
219
  /* FunctionExpression */
@@ -353,7 +360,13 @@ module.exports = {
353
360
  // var id = init
354
361
  if ("VariableDeclarator" == type) {
355
362
  if (parent.id == node) {
356
- report(node)
363
+ if (
364
+ parent.parent?.parent?.type != "ExportNamedDeclaration"
365
+ || !camel_case_regex.test(name)
366
+ ) {
367
+ report(node)
368
+ }
369
+ // export var camelCase
357
370
  } else {
358
371
  defer(node)
359
372
  }
@@ -561,13 +561,32 @@ exports.module = (valid, invalid) => {
561
561
  },
562
562
  // FunctionDeclaration
563
563
  {
564
- code: "function camelCase() {}",
565
- errors: [{
566
- ...error,
567
- line: 1,
568
- column: 10
569
- }],
570
- output: "function camel_case() {}"
564
+ code: `
565
+ function camelCase() {}
566
+ export function camelCase2() {}
567
+ export function camelCase$() {}
568
+ `,
569
+ errors: [
570
+ {
571
+ ...error,
572
+ line: 2,
573
+ column: 13
574
+ },
575
+ {
576
+ ...error,
577
+ line: 4,
578
+ column: 20
579
+ }
580
+ ],
581
+ output: `
582
+ function camel_case() {}
583
+ export function camelCase2() {}
584
+ export function camel_case$() {}
585
+ `,
586
+ parserOptions: {
587
+ ecmaVersion: "latest",
588
+ sourceType: "module"
589
+ }
571
590
  },
572
591
  // IfStatement
573
592
  {
@@ -1230,6 +1249,8 @@ exports.module = (valid, invalid) => {
1230
1249
  var snake_case = pendingA
1231
1250
  var pendingA
1232
1251
  var snake_case = pendingA
1252
+ export var camelCase2
1253
+ export var camelCase$
1233
1254
  `,
1234
1255
  errors: [
1235
1256
  {
@@ -1251,6 +1272,11 @@ exports.module = (valid, invalid) => {
1251
1272
  ...error,
1252
1273
  line: 5,
1253
1274
  column: 21
1275
+ },
1276
+ {
1277
+ ...error,
1278
+ line: 7,
1279
+ column: 15
1254
1280
  }
1255
1281
  ],
1256
1282
  options: [{ fixSameNames: true }],
@@ -1259,7 +1285,13 @@ exports.module = (valid, invalid) => {
1259
1285
  var snake_case = pending_a
1260
1286
  var pending_a
1261
1287
  var snake_case = pending_a
1262
- `
1288
+ export var camelCase2
1289
+ export var camel_case$
1290
+ `,
1291
+ parserOptions: {
1292
+ ecmaVersion: "latest",
1293
+ sourceType: "module"
1294
+ }
1263
1295
  },
1264
1296
  // WhileStatement
1265
1297
  {