eslint-plugin-lube 0.1.3 → 0.1.5
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
|
@@ -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
|
-
|
|
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 */
|
|
@@ -258,7 +265,6 @@ module.exports = {
|
|
|
258
265
|
/* MetaProperty */
|
|
259
266
|
// class Object { camelCase() {} }
|
|
260
267
|
if ("MethodDefinition" == type) {
|
|
261
|
-
report(node)
|
|
262
268
|
return
|
|
263
269
|
}
|
|
264
270
|
// new camelCase
|
|
@@ -280,11 +286,6 @@ module.exports = {
|
|
|
280
286
|
}
|
|
281
287
|
// class Object { key = value }
|
|
282
288
|
if ("PropertyDefinition" == type) {
|
|
283
|
-
if (parent.key == node) {
|
|
284
|
-
report(node)
|
|
285
|
-
} else {
|
|
286
|
-
defer(node)
|
|
287
|
-
}
|
|
288
289
|
return
|
|
289
290
|
}
|
|
290
291
|
// var [ ...camelCase ] = value
|
|
@@ -353,7 +354,13 @@ module.exports = {
|
|
|
353
354
|
// var id = init
|
|
354
355
|
if ("VariableDeclarator" == type) {
|
|
355
356
|
if (parent.id == node) {
|
|
356
|
-
|
|
357
|
+
if (
|
|
358
|
+
parent.parent?.parent?.type != "ExportNamedDeclaration"
|
|
359
|
+
|| !camel_case_regex.test(name)
|
|
360
|
+
) {
|
|
361
|
+
report(node)
|
|
362
|
+
}
|
|
363
|
+
// export var camelCase
|
|
357
364
|
} else {
|
|
358
365
|
defer(node)
|
|
359
366
|
}
|
|
@@ -374,24 +381,6 @@ module.exports = {
|
|
|
374
381
|
defer(node)
|
|
375
382
|
return
|
|
376
383
|
}
|
|
377
|
-
},
|
|
378
|
-
/** @param {import("../private").ASTNode} node */
|
|
379
|
-
PrivateIdentifier(node) {
|
|
380
|
-
const name = node.name
|
|
381
|
-
if (allow_regex.test(name)) return
|
|
382
|
-
const parent = node.parent
|
|
383
|
-
const type = parent.type
|
|
384
|
-
// class Object { #camelCase() {} }
|
|
385
|
-
if ("MethodDefinition" == type) {
|
|
386
|
-
report(node)
|
|
387
|
-
return
|
|
388
|
-
}
|
|
389
|
-
// class Object { #camelCase = value }
|
|
390
|
-
if ("PropertyDefinition" == type) {
|
|
391
|
-
report(node)
|
|
392
|
-
return
|
|
393
|
-
}
|
|
394
|
-
// TODO ?
|
|
395
384
|
}
|
|
396
385
|
}
|
|
397
386
|
}
|
|
@@ -561,13 +561,32 @@ exports.module = (valid, invalid) => {
|
|
|
561
561
|
},
|
|
562
562
|
// FunctionDeclaration
|
|
563
563
|
{
|
|
564
|
-
code:
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
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
|
{
|
|
@@ -767,13 +786,19 @@ exports.module = (valid, invalid) => {
|
|
|
767
786
|
},
|
|
768
787
|
// MethodDefinition
|
|
769
788
|
{
|
|
770
|
-
code:
|
|
789
|
+
code: `
|
|
790
|
+
class ObjectB { camelCase() {} }
|
|
791
|
+
var camelCase
|
|
792
|
+
`,
|
|
771
793
|
errors: [{
|
|
772
794
|
...error,
|
|
773
|
-
line:
|
|
774
|
-
column:
|
|
795
|
+
line: 3,
|
|
796
|
+
column: 8
|
|
775
797
|
}],
|
|
776
|
-
output:
|
|
798
|
+
output: `
|
|
799
|
+
class ObjectB { camelCase() {} }
|
|
800
|
+
var camel_case
|
|
801
|
+
`,
|
|
777
802
|
parserOptions: { ecmaVersion: "latest" }
|
|
778
803
|
},
|
|
779
804
|
// NewExpression
|
|
@@ -848,39 +873,25 @@ exports.module = (valid, invalid) => {
|
|
|
848
873
|
// PropertyDefinition
|
|
849
874
|
{
|
|
850
875
|
code: `
|
|
851
|
-
class
|
|
852
|
-
|
|
853
|
-
var pendingA
|
|
854
|
-
class ObjectC { snake_case = pendingA }
|
|
876
|
+
class ObjectB { camelCase = camelCase2 }
|
|
877
|
+
var camelCase, camelCase2
|
|
855
878
|
`,
|
|
856
879
|
errors: [
|
|
857
|
-
{
|
|
858
|
-
...error,
|
|
859
|
-
line: 2,
|
|
860
|
-
column: 20
|
|
861
|
-
},
|
|
862
880
|
{
|
|
863
881
|
...error,
|
|
864
882
|
line: 3,
|
|
865
|
-
column: 33
|
|
866
|
-
},
|
|
867
|
-
{
|
|
868
|
-
...error,
|
|
869
|
-
line: 4,
|
|
870
883
|
column: 8
|
|
871
884
|
},
|
|
872
885
|
{
|
|
873
886
|
...error,
|
|
874
|
-
line:
|
|
875
|
-
column:
|
|
887
|
+
line: 3,
|
|
888
|
+
column: 19
|
|
876
889
|
}
|
|
877
890
|
],
|
|
878
891
|
options: [{ fixSameNames: true }],
|
|
879
892
|
output: `
|
|
880
|
-
class
|
|
881
|
-
|
|
882
|
-
var pending_a
|
|
883
|
-
class ObjectC { snake_case = pending_a }
|
|
893
|
+
class ObjectB { camelCase = camelCase2 }
|
|
894
|
+
var camel_case, camel_case2
|
|
884
895
|
`,
|
|
885
896
|
parserOptions: { ecmaVersion: "latest" }
|
|
886
897
|
},
|
|
@@ -1230,6 +1241,8 @@ exports.module = (valid, invalid) => {
|
|
|
1230
1241
|
var snake_case = pendingA
|
|
1231
1242
|
var pendingA
|
|
1232
1243
|
var snake_case = pendingA
|
|
1244
|
+
export var camelCase2
|
|
1245
|
+
export var camelCase$
|
|
1233
1246
|
`,
|
|
1234
1247
|
errors: [
|
|
1235
1248
|
{
|
|
@@ -1251,6 +1264,11 @@ exports.module = (valid, invalid) => {
|
|
|
1251
1264
|
...error,
|
|
1252
1265
|
line: 5,
|
|
1253
1266
|
column: 21
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
...error,
|
|
1270
|
+
line: 7,
|
|
1271
|
+
column: 15
|
|
1254
1272
|
}
|
|
1255
1273
|
],
|
|
1256
1274
|
options: [{ fixSameNames: true }],
|
|
@@ -1259,7 +1277,13 @@ exports.module = (valid, invalid) => {
|
|
|
1259
1277
|
var snake_case = pending_a
|
|
1260
1278
|
var pending_a
|
|
1261
1279
|
var snake_case = pending_a
|
|
1262
|
-
|
|
1280
|
+
export var camelCase2
|
|
1281
|
+
export var camel_case$
|
|
1282
|
+
`,
|
|
1283
|
+
parserOptions: {
|
|
1284
|
+
ecmaVersion: "latest",
|
|
1285
|
+
sourceType: "module"
|
|
1286
|
+
}
|
|
1263
1287
|
},
|
|
1264
1288
|
// WhileStatement
|
|
1265
1289
|
{
|